Skip to content

Commit

Permalink
fix: run packageWeb after stack deploy if it's a new stack
Browse files Browse the repository at this point in the history
Fixes the scenario where the UI relies on stack outputs
  • Loading branch information
brettstack committed May 5, 2020
1 parent 506ed1b commit 2f619ae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ class ServerlessAmplifyPlugin {
region: this.serverless.getProvider('aws').getRegion()
})
this.amplifyClient = amplifyClient
await this.packageWeb()
await this.describeStack({ isPackageStep: true })

const stackExists = Boolean(this.amplifyAppId)

// If the stack exists, package and create the deployment
// During the package step, then execute the deployment
// During the CloudFormation deployment
if (stackExists) {
await this.packageWeb()
const { jobId } = await createAmplifyDeployment({
amplifyClient,
appId: this.amplifyAppId,
Expand All @@ -39,6 +43,9 @@ class ServerlessAmplifyPlugin {
this.amplifyDeploymentJobId = jobId
}
},
// TODO:
// If this is a stack update, deploy to Amplify *during* deployment
// instead of after so that it doesn't wait for rollback window
'after:deploy:deploy': () => this.amplifyOptions.isManual && this.deployWeb(),
'after:rollback:initialize': () => this.amplifyOptions.isManual && this.rollbackAmplify()
}
Expand Down Expand Up @@ -193,6 +200,7 @@ frontend:
if (!this.amplifyDeploymentJobId) {
await this.describeStack({ isPackageStep: false })

await this.packageWeb()
const { jobId } = await createAmplifyDeployment({
amplifyClient: this.amplifyClient,
appId: this.amplifyAppId,
Expand Down

0 comments on commit 2f619ae

Please sign in to comment.