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
When using ec2.InitFile.fromAsset(targetFileName, path) more than once in the same stack, using the same targetFileName value, an error is raised during synthesis:
VPC_ID=vpc-03d0fd37XXXXX ACCOUNT=101010101010 npx cdk deploy --all
/Users/spg/cdk-error-repo/node_modules/constructs/src/construct.ts:423
throw new Error(`There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? ' [' + name + ']' : ''}`);
^
Error: There is already a Construct with name '--etc--test.txtAsset' in MyStack [MyStack-test]
at Node.addChild (/Users/spg/cdk-error-repo/node_modules/constructs/src/construct.ts:423:13)
at new Node (/Users/spg/cdk-error-repo/node_modules/constructs/src/construct.ts:71:17)
at new Construct (/Users/spg/cdk-error-repo/node_modules/constructs/src/construct.ts:483:17)
at new Asset (/Users/spg/cdk-error-repo/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:473)
at Object._doBind (/Users/spg/cdk-error-repo/node_modules/aws-cdk-lib/aws-ec2/lib/cfn-init-elements.js:1:7114)
at Object._bind (/Users/spg/cdk-error-repo/node_modules/aws-cdk-lib/aws-ec2/lib/cfn-init-elements.js:1:8579)
at /Users/spg/cdk-error-repo/node_modules/aws-cdk-lib/aws-ec2/lib/cfn-init.js:1:7758
at Array.map (<anonymous>)
at InitConfig.bindForType (/Users/spg/cdk-error-repo/node_modules/aws-cdk-lib/aws-ec2/lib/cfn-init.js:1:7741)
at InitConfig._bind (/Users/spg/cdk-error-repo/node_modules/aws-cdk-lib/aws-ec2/lib/cfn-init.js:1:6825)
Subprocess exited with error 1
Expected Behavior
I should be able to call ec2.InitFile.fromAsset(targetFileName, path) more than once in the same stack, using the same targetFileName value.
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
When using
ec2.InitFile.fromAsset(targetFileName, path)
more than once in the same stack, using the sametargetFileName
value, an error is raised during synthesis:Expected Behavior
I should be able to call
ec2.InitFile.fromAsset(targetFileName, path)
more than once in the same stack, using the sametargetFileName
value.Current Behavior
See bug description
Reproduction Steps
App to reproduce:
You should also create a
test.txt
file (content does not matter) sitting in the same directory asapp.ts
.Possible Solution
This line seems to be causing the issue:
aws-cdk/packages/aws-cdk-lib/aws-ec2/lib/cfn-init.ts
Line 104 in a523e9f
Maybe the CloudFormation Init config should be bound to the current
scope
instead of the current stack?Additional Information/Context
No response
CDK CLI Version
2.88.0 (build 5d497f9)
Framework Version
No response
Node.js Version
v16.19.0
OS
macOS Venture 13.2
Language
Typescript
Language Version
5.0.4
Other information
No response
The text was updated successfully, but these errors were encountered: