Skip to content

Commit

Permalink
fix(assets): can now use multiple assets in the same stack (#725)
Browse files Browse the repository at this point in the history
Fixed by attaching the imported bucket to the Asset object instead
of the Asset object's parent.

Fixes #706.
  • Loading branch information
rix0rrr authored Sep 17, 2018
1 parent a7bc5ee commit bba2e5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assets/lib/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand Down
15 changes: 14 additions & 1 deletion packages/@aws-cdk/assets/test/test.asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
};

0 comments on commit bba2e5b

Please sign in to comment.