-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: don't upload the same asset multiple times (#1011)
This change implements two asset bandwidth conservation measures: - If a lambda.AssetCode object is reused for multiple Lambdas, the same underyling Asset object will be reused (which leads to the asset data only being uploaded once). - If nonetheless multiple Asset objects are created for the same source data, the data will only be uploaded once and subsequently copied on the server-side to avoid the additional data transfer. Fixes #989.
- Loading branch information
Showing
5 changed files
with
108 additions
and
14 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
packages/@aws-cdk/assets/test/integ.multi-assets.expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"Parameters": { | ||
"SampleAsset1S3Bucket469E18FF": { | ||
"Type": "String", | ||
"Description": "S3 bucket for asset \"aws-cdk-multi-assets/SampleAsset1\"" | ||
}, | ||
"SampleAsset1S3VersionKey63A628F0": { | ||
"Type": "String", | ||
"Description": "S3 key for asset version \"aws-cdk-multi-assets/SampleAsset1\"" | ||
}, | ||
"SampleAsset2S3BucketC94C651A": { | ||
"Type": "String", | ||
"Description": "S3 bucket for asset \"aws-cdk-multi-assets/SampleAsset2\"" | ||
}, | ||
"SampleAsset2S3VersionKey3A7E2CC4": { | ||
"Type": "String", | ||
"Description": "S3 key for asset version \"aws-cdk-multi-assets/SampleAsset2\"" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import cdk = require('@aws-cdk/cdk'); | ||
import path = require('path'); | ||
import assets = require('../lib'); | ||
|
||
class TestStack extends cdk.Stack { | ||
constructor(parent: cdk.App, name: string, props?: cdk.StackProps) { | ||
super(parent, name, props); | ||
|
||
// Check that the same asset added multiple times is | ||
// uploaded and copied. | ||
new assets.FileAsset(this, 'SampleAsset1', { | ||
path: path.join(__dirname, 'file-asset.txt') | ||
}); | ||
|
||
new assets.FileAsset(this, 'SampleAsset2', { | ||
path: path.join(__dirname, 'file-asset.txt') | ||
}); | ||
} | ||
} | ||
|
||
const app = new cdk.App(); | ||
new TestStack(app, 'aws-cdk-multi-assets'); | ||
app.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters