Skip to content
v2.274.0

S3DownloadOptions Struct ​

Options when downloading files from S3.

Example ​

ts
import { Asset } from 'aws-cdk-lib/aws-s3-assets';

declare const instance: ec2.Instance;

const asset = new Asset(this, 'Asset', {
  path: './configure.sh'
});

const localPath = instance.userData.addS3DownloadCommand({
  bucket:asset.bucket,
  bucketKey:asset.s3ObjectKey,
  region: 'us-east-1', // Optional
});
instance.userData.addExecuteFileCommand({
  filePath:localPath,
  arguments: '--verbose -y'
});
asset.grantRead(instance.role);

Properties ​

bucketIBucketRefbucketIBucketRefbucketIBucketRefBucketIBucketRefBucketIBucketRefrequired#
Name of the S3 bucket to download from.
bucketKeystringbucket_keystrbucketKeyStringBucketKeystringBucketKey*stringrequired#
The key of the file to download.
localFilestringlocal_filestrlocalFileStringLocalFilestringLocalFile*string= Linux - /tmp/bucketKey Windows -…#
The name of the local file.
default

Default: Linux - /tmp/bucketKey Windows - %TEMP%/bucketKey

regionstringregionstrregionStringRegionstringRegion*string= none#
The region of the S3 Bucket (needed for access via VPC Gateway).