Skip to content

Multiple Assets In the same stack #706

@sentient-jbreindel

Description

@sentient-jbreindel

Whenever I try to create a stack with multiple assets I receive the following error when I run cdk synth:

Error: There is already a Construct with name 'AssetBucket' in ApiStack [ApiStack]
    at ApiStack.addChild (/git/project/node_modules/@aws-cdk/cdk/lib/core/construct.js:287:19)
    at new Construct (/git/project/node_modules/@aws-cdk/cdk/lib/core/construct.js:38:20)
    at new BucketRef (/git/project/node_modules/@aws-cdk/aws-s3/lib/bucket.js:30:9)
    at new ImportedBucketRef (/git/project/node_modules/@aws-cdk/aws-s3/lib/bucket.js:519:9)
    at Function.import (/git/project/node_modules/@aws-cdk/aws-s3/lib/bucket.js:46:16)
    at new Asset (/git/project/node_modules/@aws-cdk/assets/lib/asset.js:48:42)
    at new ZipDirectoryAsset (/git/project/node_modules/@aws-cdk/assets/lib/asset.js:95:9)
    at new ApiStack (/git/project/index.js:100:24)
    at new App (/git/project/index.js:187:5)
    at Object.<anonymous> (/git/project/index.js:191:22)

I noticed that when defining a new asset the bucket is always imported with the same name. I think this may be the offending line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions