Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 Deployment: Deployment fails when using localstack #21014

Open
garyholiday13 opened this issue Jul 6, 2022 · 3 comments
Open

S3 Deployment: Deployment fails when using localstack #21014

garyholiday13 opened this issue Jul 6, 2022 · 3 comments
Labels
@aws-cdk/aws-s3 Related to Amazon S3 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@garyholiday13
Copy link

garyholiday13 commented Jul 6, 2022

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

@garyholiday13 garyholiday13 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 6, 2022
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Jul 6, 2022
@jashgala
Copy link

jashgala commented Jul 7, 2022

Tried reproducing the same error without localstack (i.e. while deploying an S3 bucket into an actual AWS account). Even though the path /opt/awscli/aws did not exist on my local machine, the latest CDK version (2.30.0) was able to successfully deploy the bucket and assets to S3.

@peterwoodworth
Copy link
Contributor

I think this would be an issue specific to localstack - the code you've referenced will be ran during deployment normally in a lambda function as a custom resource, so it will have a different directory than if the code were executed locally

I think we could potentially support this by passing in a variable to the custom resource.

I am marking this issue as p2, which means that we are unable to work on this immediately.

We use +1s to help prioritize our work, and are happy to revaluate this issue based on community feedback. You can reach out to the cdk.dev community on Slack to solicit support for reprioritization.

@peterwoodworth peterwoodworth added feature-request A feature should be added or improved. p2 effort/small Small work item – less than a day of effort and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 9, 2022
@peterwoodworth peterwoodworth changed the title S3 Deployment: Deployment fails with [Errno 2] No such file or directory: '/opt/awscli/aws' S3 Deployment: Deployment fails when using localstack Jul 9, 2022
@JGitHub01
Copy link

I'm having the same issue with CDK BucketDeployment. It does not upload contents into the bucket. I wish it can be supported by localstack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

5 participants