terraform-cdk
terraform-cdk copied to clipboard
Reduce/document differences between cdktf synth and running app directly
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
We should document the differences between cdktf synth
vs running application directly and then eliminate differences where it makes sense.
Starting list of differences:
- Feature flags aren't applied when running app directly. This impacts the naming of resources. I don't have a good reason for the discrepancy.
- Terraform Cloud automation. There's quite a bit to make using Terraform Cloud easier. Probably best to just leave alone
- #682 proposes adding hooks which would be cli only
References
For the use case of writing a cdktf script that generates Terraform code, it looks like the CLI is not needed. I haven't used feature flags so far, so the output from cdktf-cli and running scripts directly has been the same for me.
I'm processing the generated JSON with Terraform afterwards. cdktf still requires Terraform to do the grunt work too, so the added benefit is somewhat limited.
It's understandable that more advanced features, such as Terraform Cloud integration, wouldn't work, but I think it would make sense to support the basic use case described above as well.
Comparison with other IaC toolkits:
- Pulumi: CLI required, plus either running agent or state storage required
- AWS CDK: CLI required, plus CloudFormation as deployment infrastructure required. Although, there's a similar discussion here: https://github.com/aws/aws-cdk-rfcs/issues/300
- Feature flags aren't applied when running app directly. This impacts the naming of resources. I don't have a good reason for the discrepancy.
This just bit me hard and essentially destroyed an entire stack with lots of stuff requiring manual fixes now. That's really something we'll have to address.
- Feature flags aren't applied when running app directly. This impacts the naming of resources. I don't have a good reason for the discrepancy.
This just bit me hard and essentially destroyed an entire stack with lots of stuff requiring manual fixes now. That's really something we'll have to address.
Is there any workaround for this? I was developing my app using 'cdktf synth' and wrote quite a large infrasctructure with it, now i'm trying to run the app and I think i'm hitting the situation youre describing.
the modules names changed from:
module.quero2pay-dataplatform-eks-eks-cluster.module.node_groups.aws_launch_template.workers["main"]
to module.baseinfrastructurestack_quero2paydataplatformeksekscluster_F8C7987B.module.node_groups.aws_launch_template.workers["main"]
Not sure it's the same situation but it looks like it.
thank you!
Is there any workaround for this? I was developing my app using 'cdktf synth' and wrote quite a large infrasctructure with it, now i'm trying to run the app and I think i'm hitting the situation youre describing.
You could try setting the CDKTF_CONTEXT_JSON
environment variable to a json string of your cdktf.json
file.
hi, I'm hit by https://github.com/hashicorp/terraform-cdk/issues/2550 issue which looks like related to this one. Any news about this issue?
I saw a great work around for naming inconsistencies in another issue: https://github.com/hashicorp/terraform-cdk/issues/2341#issuecomment-1326760534
Hi. What are the actual differences of running the cdktf code directly vs using the cdktf cli? (Apart from the CLI flags ofc)
I just did a quick comparison and I can't tell the difference.
Both yarn run cdktf synth --app 'yarn run tsx main.ts'
and yarn run tsx main.ts
still generated the cdktf json files.