aws / aws/aws-cdk

S3 Deployment: Deployment fails when using localstack

Open
#21,014 3 comments 2 reactions 0 assignees View on GitHub
@aws-cdk/aws-s3 effort/small feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the bug

I'm using `cdklocal` with localstack to deploy my cdk stack in my local environment. When executing the S3 Deployment, I get the error `[Errno 2] No such file or directory: '/opt/awscli/aws'`. There is no `/opt/awscli/aws` on my machine.

```
new s3deploy.BucketDeployment(this, 'WebsiteDeployment', {
sources: [s3deploy.Source.asset('./app/build')],
destinationBucket: bucket,
distribution,
distributionPaths: ['/*']
});
```

Why am I getting this error?

### Expected Behavior

The S3 Deployment should upload the contents of `./app/build` to my bucket.

### Current Behavior

The bucket is created but the contents of `./app/build` is not uploaded to my bucket.

### Reproduction Steps

1. `localstack start`
2. 'cdklocal deploy`

Stack:
```
const bucket = new s3.Bucket(this, 'Bucket', {
publicReadAccess: true,
removalPolicy: RemovalPolicy.DESTROY,
websiteIndexDocument: 'index.html'
});

new s3deploy.BucketDeployment(this, 'Deployment', {
sources: [s3deploy.Source.asset('./app/build')],
destinationBucket: bucket
});
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.22.0 (build 1db4b16)

### Framework Version

_No response_

### Node.js Version

v16.15.0

### OS

Mac OS Monterey

### Language

Typescript

### Language Version

_No response_

### Other information

CDK code referencing this value: https://github.com/aws/aws-cdk/blob/v1-main/packages/@aws-cdk/aws-s3-deployment/lib/lambda/index.py#L224

Contributor guide

Open the contributing guide

Research direction

Start with packages/@aws-cdk/aws-s3-deployment/lib/lambda/index.py around line 224 and reproduce the failure with localstack start followed by cdklocal deploy. Trace why S3 deployment looks for /opt/awscli/aws; done means the ./app/build contents upload successfully to the bucket in the reported local environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.