Reputation: 93
Here's how I've got deployments working right now with Amplify:
In case it matters, this deployment is entirely frontend.
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.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-amplify/ as well as the API reference from https://docs.aws.amazon.com/amplify/latest/APIReference/API_StartDeployment.html.
I'm attempting it this way (let me know if you want actual code examples):
CreateDeploymentCommand
(https://docs.aws.amazon.com/amplify/latest/APIReference/API_CreateDeployment.html) with the appId
and branchName
.StartDeploymentCommand
(https://docs.aws.amazon.com/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
.GetJobCommand
(https://docs.aws.amazon.com/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.com/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
Upvotes: 2
Views: 117
Reputation: 93
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.
Upvotes: 2