I know the AWS CDK uses generated names, but I’m curious why generate names here?
I could see it help with possible conflicts, but it seems harder to view normal terraform plan/apply output and harder to reference remote state.
yes, it’s for uniqueness reasons.
The output for diff / deploy / destroy gets parsed and beautified, so that it’s easier to read.
In regards to referencing outputs: The unique names are stable, as long as resources are not moved around in the constructs tree (and even then, they could be forced by overwriting it with the old name). I think it’s on the agenda to allow forcing a static name for outputs (for the case where you’d wanna manually reference the value). Doing this by default, would most probably lead to naming conflicts.
In addition to this, I think there will be some way of dealing with output references automatically in multi stack scenarios. However, that’s only a vague idea at this point.
Good to hear that the names can be overriden.
I think it would be useful to provide an option to override for the entire Stack. The use case I’m thinking of is converting an existing HCL Terraform deployment to CDKTF. It’s not always an option to destroy your stack and rebuild, but being able to transition over would be very nice.
I’m also looking to convert multiple existing stacks without fully destroying state to the CDK and would be curious what the recommended approach here is.
I don’t believe there is a practical way of converting an existing stack without destruction at this time. It’s something on my personal todo list to add, but if anyone is interested, I think this would be a useful contribution to the project.
That said, I think it may be possible to do this currently by importing state. It would be quite tedious, but perhaps could be scripted.