cdktf deploy should run without errors, properly recognizing the replace_triggered_by lifecycle configuration when using a dynamic value.
Actual Behavior
I'm encountering the following errors when running terraform initcdktf deploy
test-stack Initializing the backend...
test-stack
Successfully configured the backend "local"! Terraform will automatically
use this backend unless the backend configuration changes.
test-stack Terraform encountered problems during initialisation, including problems
with the configuration, described below.
The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
╷
│ Error: Invalid character
│
│ on cdk.tf.json line 54, in resource.aws_internet_gateway.VpcConstruct_InternetGateway_962A2FFB (VpcConstruct/InternetGateway/InternetGateway).lifecycle.replace_triggered_by:
│ 54: "${aws_vpc.VpcConstruct_Vpc_test2-cdktf-app-vpc_576D1A6F (VpcConstruct/Vpc/test2-cdktf-app-vpc).id}"
│
│ This character is not used within the language.
╵
test-stack ╷
│ Error: Invalid expression
│
│ on cdk.tf.json line 54, in resource.aws_internet_gateway.VpcConstruct_InternetGateway_962A2FFB (VpcConstruct/InternetGateway/InternetGateway).lifecycle.replace_triggered_by:
│ 54: "${aws_vpc.VpcConstruct_Vpc_test2-cdktf-app-vpc_576D1A6F (VpcConstruct/Vpc/test2-cdktf-app-vpc).id}"
│
│ Expected the start of an expression, but found an invalid expression token.
╵
0 Stacks deploying 0 Stacks done 1 Stack waiting
Error: terraform init failed with exit code 1
This issue occurs only when using the replaceTriggeredBy lifecycle property with a dynamic value. It works fine if a static value is provided, such as replaceTriggeredBy: ["aws_vpc.VpcConstruct_Vpc_test2-cdktf-app-vpc_576D1A6F.id"]. The error seems to be caused by the ${} syntax when using dynamic values.
Define the InternetGatewayConstruct as shown in the code snippet above.
Add the lifecycle property to the InternetGateway resource with replaceTriggeredBy using a dynamic value (props.vpcId).
Run cdktf deploy.
Versions
typescriptVersion: "~5.3.3"
jsiiVersion: "~5.3.3"
NodeVersion: '20.13.0'
constructsVersion: '^10.3.0'
cdktfVersion: '0.20.7'
ProductName: macOS
ProductVersion: 14.3
BuildVersion: 23D56
Providers
provider-aws@^19.12.0
Gist
No response
Possible Solutions
No response
Workarounds
No response
Anything Else?
No response
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
Expected Behavior
cdktf deploy
should run without errors, properly recognizing the replace_triggered_by lifecycle configuration when using a dynamic value.Actual Behavior
I'm encountering the following errors when running
terraform init
cdktf deploy
This issue occurs only when using the replaceTriggeredBy lifecycle property with a dynamic value. It works fine if a static value is provided, such as replaceTriggeredBy: ["aws_vpc.VpcConstruct_Vpc_test2-cdktf-app-vpc_576D1A6F.id"]. The error seems to be caused by the ${} syntax when using dynamic values.
Code Snippet
Here is the relevant code snippet:
cdk.tf.json Snippet
Steps to Reproduce
Versions
Providers
provider-aws@^19.12.0
Gist
No response
Possible Solutions
No response
Workarounds
No response
Anything Else?
No response
References
No response
Help Wanted
Community Note