diff --git a/packages/@aws-cdk/assets/lib/asset.ts b/packages/@aws-cdk/assets/lib/asset.ts index 35fc91fbfe643..eb6e4b7cbcb80 100644 --- a/packages/@aws-cdk/assets/lib/asset.ts +++ b/packages/@aws-cdk/assets/lib/asset.ts @@ -99,7 +99,7 @@ export class Asset extends cdk.Construct { const s3Filename = new cdk.FnSelect(1, new cdk.FnSplit(cxapi.ASSET_PREFIX_SEPARATOR, keyParam.value)); this.s3ObjectKey = new s3.ObjectKey(new cdk.FnConcat(this.s3Prefix, s3Filename)); - this.bucket = s3.BucketRef.import(parent, 'AssetBucket', { + this.bucket = s3.BucketRef.import(this, 'AssetBucket', { bucketName: this.s3BucketName }); diff --git a/packages/@aws-cdk/assets/test/test.asset.ts b/packages/@aws-cdk/assets/test/test.asset.ts index e78d02c18fa34..b417ce33f2cbd 100644 --- a/packages/@aws-cdk/assets/test/test.asset.ts +++ b/packages/@aws-cdk/assets/test/test.asset.ts @@ -98,5 +98,18 @@ export = { path: '/path/not/found/' + Math.random() * 999999 })); test.done(); - } + }, + + 'multiple assets under the same parent'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + new ZipDirectoryAsset(stack, 'MyDirectory1', { path: '.' }); + new ZipDirectoryAsset(stack, 'MyDirectory2', { path: '.' }); + + // THEN: no error + + test.done(); + }, }; \ No newline at end of file