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

Amplify CLI Custom CDK - 'Error occurred while GetObject. S3 Error Code: NoSuchKey' with BucketDeployment #13144

Closed
2 tasks done
ggotti opened this issue Aug 22, 2023 · 2 comments
Labels
custom-cdk Issues related to custom CDK resource functionality duplicate If marked with duplicate, issue will be closed & original will be added for traceability pending-triage Issue is pending triage

Comments

@ggotti
Copy link

ggotti commented Aug 22, 2023

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v18.16.0

Amplify CLI Version

12.3.0

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Describe the bug

Using a CDK Custom Resource, I've attempted to upload a local folder using a aws_s3_deployment.BucketDeployment CDK. Instead of deploying the local folder into the s3 bucket, an error occurs trying to deploy a AWS::Lambda::LayerVersion.

Expected behavior

That the folder is uploaded correctly.

Reproduction steps

  1. Initiate a new Amplify Project
  2. Add a new CDK custom resource
  3. Enter the following into the CDK generated stack.
  constructor(scope: Construct, id: string, props?: cdk.StackProps, amplifyResourceProps?: AmplifyHelpers.AmplifyResourceProps) {
    super(scope, id, props);
    /* Do not remove - Amplify CLI automatically injects the current deployment environment in this input parameter */
    new cdk.CfnParameter(this, 'env', {
      type: 'String',
      description: 'Current Amplify CLI env name',
    });
    /* AWS CDK code goes here - learn more: https://docs.aws.amazon.com/cdk/latest/guide/home.html */


	  const targetBucket = new aws_s3.Bucket(this, 'exampleBucket', {
		  bucketName: `ihavereplacedthisvalue`
	  });

	  new aws_s3_deployment.BucketDeployment(this, 'PublicImageDeployment', {
		  sources: [aws_s3_deployment.Source.asset(path.join(__dirname, '../../../../../public/images'), {})],
		  destinationBucket: targetBucket,
		  retainOnDelete: true,
		  memoryLimit: 1792,
		  prune: false
	  });
  }
}
  1. Ensure there are resources to upload within the public/images folder in the root amplify directory.
  2. Run amplify push

Project Identifier

e4de6252d95e8a5241e8ff5d8345c9f1

Log output

❯ amplify push
✔ Successfully pulled backend environment dev from the cloud.

    Current Environment: dev

┌──────────┬───────────────┬───────────┬───────────────────┐
│ Category │ Resource name │ Operation │ Provider plugin   │
├──────────┼───────────────┼───────────┼───────────────────┤
│ Custom   │ testResource  │ Create    │ awscloudformation │
└──────────┴───────────────┴───────────┴───────────────────┘
✔ Are you sure you want to continue? (Y/n) · yes

Deployment failed.
Deploying root stack testVersion [ ---------------------------------------- ] 0/2
	amplify-testversion-dev-165210 AWS::CloudFormation::Stack     UPDATE_ROLLBACK_COMPLETE_CLEA… Tue Aug 22 2023 17:06:45…
	customtestResource             AWS::CloudFormation::Stack     CREATE_FAILED                  Tue Aug 22 2023 17:06:42…
Deploying custom testResource [ ====================-------------------- ] 3/6
	CustomCDKBucketDeployment8693… AWS::IAM::Role                 DELETE_COMPLETE                Tue Aug 22 2023 17:06:52…
	exampleBucketB33BA2C4          AWS::S3::Bucket                DELETE_SKIPPED                 Tue Aug 22 2023 17:06:50…
	PublicImageDeploymentAwsCliLa… AWS::Lambda::LayerVersion      CREATE_FAILED                  Tue Aug 22 2023 17:05:45…
	CustomCDKBucketDeployment8693… AWS::IAM::Policy               DELETE_COMPLETE                Tue Aug 22 2023 17:06:50…

🛑 The following resources failed to deploy:
Resource Name: PublicImageDeploymentAwsCliLayer01584DF6 (AWS::Lambda::LayerVersion)
Event Type: create
Reason: Resource handler returned message: "Error occurred while GetObject. S3 Error Code: NoSuchKey. S3 Error Message: The specified key does not exist. (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: fd71b8ef-8fb6-4c8f-85d7-ac3fc2a95eb3; Proxy: null)" (RequestToken: cd158b34-62fe-710a-d2f8-a53382b7bda2, HandlerErrorCode: NotFound)


🛑 CFN Deployment failed for custom resources.
Name: PublicImageDeploymentAwsCliLayer01584DF6 (AWS::Lambda::LayerVersion), Event Type: create, Reason: Resource handler returned message: "Error occurred while GetObject. S3 Error Code: NoSuchKey. S3 Error Message: The specified key does not exist. (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: fd71b8ef-8fb6-4c8f-85d7-ac3fc2a95eb3; Proxy: null)" (RequestToken: cd158b34-62fe-710a-d2f8-a53382b7bda2, HandlerErrorCode: NotFound), IsCustomResource: true


Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@ggotti ggotti added the pending-triage Issue is pending triage label Aug 22, 2023
@ykethan ykethan added the custom-cdk Issues related to custom CDK resource functionality label Aug 22, 2023
@ykethan
Copy link
Contributor

ykethan commented Aug 22, 2023

Hey @ggotti, thank you for reaching out. Amplify custom resources does not support packaging assets, this is currently being tracked as a feature request here: #9055.
Closing the issue.

@ykethan ykethan added the duplicate If marked with duplicate, issue will be closed & original will be added for traceability label Aug 22, 2023
@ykethan ykethan closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom-cdk Issues related to custom CDK resource functionality duplicate If marked with duplicate, issue will be closed & original will be added for traceability pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

2 participants