admin管理员组文章数量:1416331
Here's how I've got deployments working right now with Amplify:
In case it matters, this deployment is entirely frontend.
- Deploy application files to an S3 bucket.
- 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):
- Create and send a
CreateDeploymentCommand
(.html) with theappId
andbranchName
. - Create and send a
StartDeploymentCommand
(.html) with theappId
andbranchName
. Additionally, I'm settingjobId
to the job ID returned in step 1. I'm also settingsourceUrl
to the S3 bucket as it's set in the Amplify project deployment UI, andsourceUrlType
toBUCKET_PREFIX
. - 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.
- Deploy application files to an S3 bucket.
- 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):
- Create and send a
CreateDeploymentCommand
(https://docs.aws.amazon/amplify/latest/APIReference/API_CreateDeployment.html) with theappId
andbranchName
. - Create and send a
StartDeploymentCommand
(https://docs.aws.amazon/amplify/latest/APIReference/API_StartDeployment.html) with theappId
andbranchName
. Additionally, I'm settingjobId
to the job ID returned in step 1. I'm also settingsourceUrl
to the S3 bucket as it's set in the Amplify project deployment UI, andsourceUrlType
toBUCKET_PREFIX
. - 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
1 Answer
Reset to default 2I 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.
本文标签: javascriptHow to I deploy an AWS S3 bucket to Amplify via awssdkclientamplifyStack Overflow
版权声明:本文标题:javascript - How to I deploy an AWS S3 bucket to Amplify via @aws-sdkclient-amplify? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745249894a2649759.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论