javascript - How to I deploy an AWS S3 bucket to Amplify via @aws-sdkclient-amplify? - Stack Overflow

Here's how I've got deployments working right now with Amplify:In case it matters, this depl

Here's how I've got deployments working right now with Amplify:

In case it matters, this deployment is entirely frontend.

  1. Deploy application files to an S3 bucket.
  2. In the Amplify project, click Deploy Updates, select Amazon S3, verify the bucket is correct, and click Save and deploy.

Maybe deploying straight to Amplify is the right thing. I'm hoping I can replicate what I'm doing in the Amplify project UI.

I'm trying to replicate this process with @aws-sdk/client-amplify, but I'm running into issues.

Here's the documentation I'm following: / as well as the API reference from .html.

I'm attempting it this way (let me know if you want actual code examples):

  1. Create and send a CreateDeploymentCommand (.html) with the appId and branchName.
  2. Create and send a StartDeploymentCommand (.html) with the appId and branchName. Additionally, I'm setting jobId to the job ID returned in step 1. I'm also setting sourceUrl to the S3 bucket as it's set in the Amplify project deployment UI, and sourceUrlType to BUCKET_PREFIX.
  3. Poll by creating and sending a GetJobCommand (.html) periodically with the job ID until it returns a status saying the deployment has completed.

Step 1 seems to work. I can see the deployment pending in the Amplify project UI. Step 2 fails with the error BadRequestException: Deployment file has not been uploaded, please make sure you uploaded the deployment file prior to invoke this api.. This is confusing for me because I'm trying to deploy from S3, not upload anything. I feel like I must be missing something, but their documentation doesn't say anything about this. The only thing in their documentation about this error is that BadRequestException means "A request contains unexpected data." (.html). That might be the case, but there is no further information on what I might be doing wrong.

Or maybe I'm approaching this the wrong way. Let me know if you've got any insight :D

Here's how I've got deployments working right now with Amplify:

In case it matters, this deployment is entirely frontend.

  1. Deploy application files to an S3 bucket.
  2. In the Amplify project, click Deploy Updates, select Amazon S3, verify the bucket is correct, and click Save and deploy.

Maybe deploying straight to Amplify is the right thing. I'm hoping I can replicate what I'm doing in the Amplify project UI.

I'm trying to replicate this process with @aws-sdk/client-amplify, but I'm running into issues.

Here's the documentation I'm following: https://docs.aws.amazon/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-amplify/ as well as the API reference from https://docs.aws.amazon/amplify/latest/APIReference/API_StartDeployment.html.

I'm attempting it this way (let me know if you want actual code examples):

  1. Create and send a CreateDeploymentCommand (https://docs.aws.amazon/amplify/latest/APIReference/API_CreateDeployment.html) with the appId and branchName.
  2. Create and send a StartDeploymentCommand (https://docs.aws.amazon/amplify/latest/APIReference/API_StartDeployment.html) with the appId and branchName. Additionally, I'm setting jobId to the job ID returned in step 1. I'm also setting sourceUrl to the S3 bucket as it's set in the Amplify project deployment UI, and sourceUrlType to BUCKET_PREFIX.
  3. Poll by creating and sending a GetJobCommand (https://docs.aws.amazon/amplify/latest/APIReference/API_GetJob.html) periodically with the job ID until it returns a status saying the deployment has completed.

Step 1 seems to work. I can see the deployment pending in the Amplify project UI. Step 2 fails with the error BadRequestException: Deployment file has not been uploaded, please make sure you uploaded the deployment file prior to invoke this api.. This is confusing for me because I'm trying to deploy from S3, not upload anything. I feel like I must be missing something, but their documentation doesn't say anything about this. The only thing in their documentation about this error is that BadRequestException means "A request contains unexpected data." (https://docs.aws.amazon/amplify/latest/APIReference/API_StartDeployment.html). That might be the case, but there is no further information on what I might be doing wrong.

Or maybe I'm approaching this the wrong way. Let me know if you've got any insight :D

Share Improve this question asked Feb 3 at 4:08 jmarkystonjmarkyston 931 silver badge15 bronze badges 1
  • Is your source URL publicly accessible? Amplify might require that to access to your source code – fa44 Commented Feb 4 at 10:15
Add a comment  | 

1 Answer 1

Reset to default 2

I figured out how to do what I need to, but it does not involve @aws-sdk/client-amplify. I think there may be a bug in that package.

This process does work, however, via the AWS CLI. Running aws amplify start-deployment --app-id [AMPLIFY_APP_ID] --branch-name [AMPLIFY_BRANCH_NAME] --source-url [S3_BUCKET_URL] --source-url-type BUCKET_PREFIX does start the Amplify deployment from the S3 bucket. I'm not sure why this doesn't work with @aws-sdk/client-amplify.

That being the case, I just added a deploy step to my pipeline that calls that CLI function. Done.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745249894a4618614.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信