hashicorp/terraform-cdk

Forceable Static Name for Outputs

skorfmann opened this issue ยท 5 comments

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

Description

When aiming to build a Terraform module with cdktf, or reference the remote state in a non automated environment, it would be good to be able to force a static name.

Given this output:

new TerraformOutput(this, 'arn', {
      value: custom.instance.arn
    })

This generates a name like this cdktfhybridmodule_arn_788D4ED0.

A new option could be:

new TerraformOutput(this, 'arn', {
      value: custom.instance.arn,
      staticName: "arn"
    })

Which wouldn't generate a name but use the input and would be referenceable as arn.

Or perhaps just use the construct id?

new TerraformOutput(this, 'arn', {
      value: custom.instance.arn,
      static: true
    })

=> arn

I think the construct id would work well.

This can already be achieved by using a feature flag (default for new apps) - It was implemented in #329

This applies to all root level resources. Since it's not really granular manageable, I'll leave this issue open for now.

#329 also added overrideLogicalId which can control the name for individual resources.

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.