Skip to content

Commit

Permalink
fix: address API GW route concurrency-related issue (#4131)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed May 14, 2024
1 parent 0b8a356 commit b893929
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/pulumi-aws/src/apps/api/ApiWebsocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export const ApiWebsocket = createAppModule({
routeKey: "$connect",
authorizationType: "NONE",
target: websocketApiIntegration.output.id.apply(value => `integrations/${value}`)
}
},
opts: { dependsOn: websocketApiDefaultRoute.output }
});

const websocketApiDisconnectRoute = app.addResource(aws.apigatewayv2.Route, {
Expand All @@ -93,7 +94,8 @@ export const ApiWebsocket = createAppModule({
routeKey: "$disconnect",
authorizationType: "NONE",
target: websocketApiIntegration.output.id.apply(value => `integrations/${value}`)
}
},
opts: { dependsOn: websocketApiConnectRoute.output }
});

const apiGatewayLoggingRole = app.addResource(aws.iam.Role, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getStackOutput } from "@webiny/cli-plugin-deploy-pulumi/utils";
import { BeforeDeployPlugin } from "@webiny/cli-plugin-deploy-pulumi/plugins";
import { BeforeBuildPlugin } from "@webiny/cli-plugin-deploy-pulumi/plugins";
import { GracefulError } from "@webiny/cli-plugin-deploy-pulumi/utils";

export const ensureApiDeployed = new BeforeDeployPlugin(({ env }, ctx) => {
export const ensureApiDeployed = new BeforeBuildPlugin(({ env }, ctx) => {
const output = getStackOutput({ folder: "apps/api", env });
const apiDeployed = output && Object.keys(output).length > 0;
if (apiDeployed) {
Expand All @@ -12,11 +12,12 @@ export const ensureApiDeployed = new BeforeDeployPlugin(({ env }, ctx) => {
const apiAppName = ctx.error.hl("API");
const adminAppName = ctx.error.hl("Admin");
const cmd = ctx.error.hl(`yarn webiny deploy api --env ${env}`);
ctx.error(`Cannot build ${adminAppName} project application before deploying ${apiAppName}.`);

throw new GracefulError(
[
`Cannot deploy ${adminAppName} project application before deploying ${apiAppName}.`,
`Please deploy ${apiAppName} project application first by running: ${cmd}.`
`Before building ${adminAppName} project application, please`,
`deploy ${apiAppName} first by running: ${cmd}.`
].join(" ")
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ export const ensureCoreDeployed = new BeforeDeployPlugin(({ env }, ctx) => {
const coreAppName = ctx.error.hl("Core");
const apiAppName = ctx.error.hl("API");
const cmd = ctx.error.hl(`yarn webiny deploy core --env ${env}`);
ctx.error(`Cannot deploy ${apiAppName} project application before deploying ${coreAppName}.`);

throw new GracefulError(
[
`Cannot deploy ${apiAppName} project application before deploying ${coreAppName}.`,
`Please deploy ${coreAppName} project application first by running: ${cmd}.`
`Before deploying ${apiAppName} project application, please`,
`deploy ${coreAppName} first by running: ${cmd}.`
].join(" ")
);
});
Expand Down

0 comments on commit b893929

Please sign in to comment.