class Source
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.S3.Deployment.Source |
Java | software.amazon.awscdk.services.s3.deployment.Source |
Python | aws_cdk.aws_s3_deployment.Source |
TypeScript (source) | @aws-cdk/aws-s3-deployment » Source |
Specifies bucket deployment source.
Usage:
Source.bucket(bucket, key)
Source.asset('/local/path/to/directory')
Source.asset('/local/path/to/a/file.zip')
Source.data('hello/world/file.txt', 'Hello, world!')
Source.data('config.json', { baz: topic.topicArn })
Example
declare const websiteBucket: s3.Bucket;
const deployment = new s3deploy.BucketDeployment(this, 'DeployWebsite', {
sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
destinationBucket: websiteBucket,
});
new ConstructThatReadsFromTheBucket(this, 'Consumer', {
// Use 'deployment.deployedBucket' instead of 'websiteBucket' here
bucket: deployment.deployedBucket,
});
Methods
Name | Description |
---|---|
static asset(path, options?) | Uses a local asset as the deployment source. |
static bucket(bucket, zipObjectKey) | Uses a .zip file stored in an S3 bucket as the source for the destination bucket contents. |
static data(objectKey, data) | Deploys an object with the specified string contents into the bucket. |
static json | Deploys an object with the specified JSON object into the bucket. |
static asset(path, options?)
public static asset(path: string, options?: AssetOptions): ISource
Parameters
- path
string
— The path to a local .zip file or a directory. - options
Asset
Options
Returns
Uses a local asset as the deployment source.
If the local asset is a .zip archive, make sure you trust the producer of the archive.
static bucket(bucket, zipObjectKey)
public static bucket(bucket: IBucket, zipObjectKey: string): ISource
Parameters
- bucket
IBucket
— The S3 Bucket. - zipObjectKey
string
— The S3 object key of the zip file with contents.
Returns
Uses a .zip file stored in an S3 bucket as the source for the destination bucket contents.
Make sure you trust the producer of the archive.
static data(objectKey, data)
public static data(objectKey: string, data: string): ISource
Parameters
- objectKey
string
— The destination S3 object key (relative to the root of the S3 deployment). - data
string
— The data to be stored in the object.
Returns
Deploys an object with the specified string contents into the bucket.
The
content can include deploy-time values (such as snsTopic.topicArn
) that
will get resolved only during deployment.
To store a JSON object use Source.jsonData()
.
Data(objectKey, obj)
static jsonpublic static jsonData(objectKey: string, obj: any): ISource
Parameters
- objectKey
string
— The destination S3 object key (relative to the root of the S3 deployment). - obj
any
— A JSON object.
Returns
Deploys an object with the specified JSON object into the bucket.
The
object can include deploy-time values (such as snsTopic.topicArn
) that
will get resolved only during deployment.