Class Source
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
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.jsonData('config.json', { baz: topic.topicArn }) Source.yamlData('config.yaml', { baz: topic.topicArn })
Example:
Bucket destinationBucket; BucketDeployment deployment = BucketDeployment.Builder.create(this, "DeployFiles") .sources(List.of(Source.asset(join(__dirname, "source-files")))) .destinationBucket(destinationBucket) .build(); deployment.handlerRole.addToPolicy( PolicyStatement.Builder.create() .actions(List.of("kms:Decrypt", "kms:DescribeKey")) .effect(Effect.ALLOW) .resources(List.of("<encryption key ARN>")) .build());
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ISource
Uses a local asset as the deployment source.static ISource
asset
(String path, AssetOptions options) Uses a local asset as the deployment source.static ISource
Uses a .zip file stored in an S3 bucket as the source for the destination bucket contents.static ISource
Deploys an object with the specified string contents into the bucket.static ISource
Deploys an object with the specified JSON object into the bucket.static ISource
Deploys an object with the specified JSON object formatted as YAML into the bucket.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Source
protected Source(software.amazon.jsii.JsiiObjectRef objRef) -
Source
protected Source(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
-
-
Method Details
-
asset
@Stability(Stable) @NotNull public static ISource asset(@NotNull String path, @Nullable AssetOptions options) 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.
- Parameters:
path
- The path to a local .zip file or a directory. This parameter is required.options
-
-
asset
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.
- Parameters:
path
- The path to a local .zip file or a directory. This parameter is required.
-
bucket
@Stability(Stable) @NotNull public static ISource bucket(@NotNull IBucket bucket, @NotNull String zipObjectKey) 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.
If the
bucket
parameter is an "out-of-app" reference "imported" via static methods such ass3.Bucket.fromBucketName
, be cautious about the bucket's encryption key. In general, CDK does not query for additional properties of imported constructs at synthesis time. For example, for a bucket created froms3.Bucket.fromBucketName
, CDK does not know itsIBucket.encryptionKey
property, and therefore will NOT give KMS permissions to the Lambda execution role of theBucketDeployment
construct. If you want thekms:Decrypt
andkms:DescribeKey
permissions on the bucket's encryption key to be added automatically, reference the imported bucket vias3.Bucket.fromBucketAttributes
and pass in theencryptionKey
attribute explicitly.Example:
Bucket destinationBucket; IBucket sourceBucket = Bucket.fromBucketAttributes(this, "SourceBucket", BucketAttributes.builder() .bucketArn("arn:aws:s3:::my-source-bucket-name") .encryptionKey(Key.fromKeyArn(this, "SourceBucketEncryptionKey", "arn:aws:kms:us-east-1:123456789012:key/<key-id>")) .build()); BucketDeployment deployment = BucketDeployment.Builder.create(this, "DeployFiles") .sources(List.of(Source.bucket(sourceBucket, "source.zip"))) .destinationBucket(destinationBucket) .build();
- Parameters:
bucket
- The S3 Bucket. This parameter is required.zipObjectKey
- The S3 object key of the zip file with contents. This parameter is required.
-
data
@Stability(Stable) @NotNull public static ISource data(@NotNull String objectKey, @NotNull String data) 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()
. To store YAML content useSource.yamlData()
.- Parameters:
objectKey
- The destination S3 object key (relative to the root of the S3 deployment). This parameter is required.data
- The data to be stored in the object. This parameter is required.
-
jsonData
@Stability(Stable) @NotNull public static ISource jsonData(@NotNull String objectKey, @NotNull Object obj) 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.- Parameters:
objectKey
- The destination S3 object key (relative to the root of the S3 deployment). This parameter is required.obj
- A JSON object. This parameter is required.
-
yamlData
@Stability(Stable) @NotNull public static ISource yamlData(@NotNull String objectKey, @NotNull Object obj) Deploys an object with the specified JSON object formatted as YAML into the bucket.The object can include deploy-time values (such as
snsTopic.topicArn
) that will get resolved only during deployment.- Parameters:
objectKey
- The destination S3 object key (relative to the root of the S3 deployment). This parameter is required.obj
- A JSON object. This parameter is required.
-