You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sapslaj opened this issue
Feb 21, 2024
· 1 comment
Labels
bugSomething isn't workingnewAn issue that has not yet been triaged by maintainersstaleAn issue or pull request that has not been updated in a very long time
Attempting to invoke synth multiple times causes the adapter to attempt to re-convert existing resources. For most practical cases there's no reason to run synth multiple times, with the major exception being tests. It's not too uncommon to see Testing.synth(stack) multiple times in a test in my experience, so having synth be essentially non-idempotent was a nasty surprise for me.
The most brute-force approach would be to simply mark any resources that have already been converted during convert() and just ignore them, but that's not super great if you synth, mutate a construct, then run synth again.
Perhaps a better approach would be to remove any existing resource that matches the logical ID and then define a new one. Somewhere right here:
// pseudo-code, untested// remove any child that matches the logical ID so we can overwrite itscope.tryRemoveChild(logicalId);// create new resourceconstres=m.resource(scope,logicalId,props);
Workarounds
I messed around with trying to unregister the Aspect that the adapter uses after it finishes, but that's egregiously fragile and has other downsides.
The best workaround is... to just not synth twice!
Yes, this is very much an edge case, but it was quite surprising and took a good hour of debugging before I realized what was happening 😅.
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
The text was updated successfully, but these errors were encountered:
sapslaj
added
bug
Something isn't working
new
An issue that has not yet been triaged by maintainers
labels
Feb 21, 2024
Hi there! 👋 We haven't heard from you in 30 days and would like to know if the problem has been resolved or if you still need help. If we don't hear from you before then, I'll auto-close this issue in 30 days.
bugSomething isn't workingnewAn issue that has not yet been triaged by maintainersstaleAn issue or pull request that has not been updated in a very long time
Description
Attempting to invoke
synth
multiple times causes the adapter to attempt to re-convert existing resources. For most practical cases there's no reason to runsynth
multiple times, with the major exception being tests. It's not too uncommon to seeTesting.synth(stack)
multiple times in a test in my experience, so having synth be essentially non-idempotent was a nasty surprise for me.CDKTF AWS Adapter Version
v0.13.5
AWS CDK Version
v2.128.0
Gist
https://gist.github.com/sapslaj/017ed9ec3265d062e8207df408a0564c
Possible Solutions
The most brute-force approach would be to simply mark any resources that have already been converted during
convert()
and just ignore them, but that's not super great if yousynth
, mutate a construct, then runsynth
again.Perhaps a better approach would be to remove any existing resource that matches the logical ID and then define a new one. Somewhere right here:
cdktf-aws-cdk/src/aws-adapter.ts
Line 157 in c0ac04d
Workarounds
I messed around with trying to unregister the Aspect that the adapter uses after it finishes, but that's egregiously fragile and has other downsides.
The best workaround is... to just not
synth
twice!Anything Else?
Yes, this is very much an edge case, but it was quite surprising and took a good hour of debugging before I realized what was happening 😅.
References
No response
Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: