Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMPONENT: Add support for optional objects in variable definitions with non-trivial default values #3595

Open
1 task done
zoonage opened this issue Apr 19, 2024 · 1 comment
Labels
enhancement New feature or request new Un-triaged issue

Comments

@zoonage
Copy link

zoonage commented Apr 19, 2024

Description

I'd like to be able to define a variable like this in cdktf, where a is optional but b is not.

variable "complex" {
  type = object({
    a = optional(number, 1)
    b = string
  })
  default = {}
}

Background context: I'm looking into cdktf adoption to try and simplify a large existing Terraform codebase.

The first area I'm looking at is removing duplicated complex variable type signatures. These can be up to ~30 lines that we manually keep in sync to work around this issue.

I'm planning on doing this by synthesising a bit of the module (such as specific variable definitions) by using a shared library but keeping the rest of the existing Terraform in place.

Happy to try and implement this

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@zoonage zoonage added enhancement New feature or request new Un-triaged issue labels Apr 19, 2024
@zoonage
Copy link
Author

zoonage commented Apr 19, 2024

Happy to have a shot at implementing this. The only question I have is I'm not sure if there is a way to build a complex type for a default like

{
  otel-agent = { image = "quay.io/zoonage/otel-agent:latest" }
  some-sidecar = { image = "quay.io/zoonage/otel-agent:latest", resources = { cpu = 1 } }
}

or if that's some extra functionality that'll be needed for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new Un-triaged issue
Projects
None yet
Development

No branches or pull requests

1 participant