# S3DownloadOptions

Options when downloading files from S3.

- Source: [`aws-ec2/lib/user-data.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-ec2/lib/user-data.ts#L40)
- Type last changed: v2.224.0 · 13 Nov 2025

## 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

- `bucket`: [IBucketRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_s3.IBucketRef.html) (required) — Name of the S3 bucket to download from.

- `bucketKey`: string (required) — The key of the file to download.

- `localFile`: string — The name of the local file.

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

- `region`: string = none — The region of the S3 Bucket (needed for access via VPC Gateway).
