From b8b1fdb76b773e4995d2134c91fab72761b3e0bb Mon Sep 17 00:00:00 2001 From: Chris Wilton-Magras Date: Wed, 3 Jul 2024 15:10:04 +0100 Subject: [PATCH] Prepare for prod-stage deployments --- cloud/bin/cloud.ts | 2 +- cloud/lib/api-stack.ts | 5 +++-- cloud/lib/hostedzone-stack.ts | 2 +- cloud/lib/ui-stack.ts | 3 ++- cloud/package.json | 1 + 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cloud/bin/cloud.ts b/cloud/bin/cloud.ts index 56827702..b6114a38 100644 --- a/cloud/bin/cloud.ts +++ b/cloud/bin/cloud.ts @@ -32,7 +32,7 @@ const tags = { /* Stack constructs */ -const hostedZoneStack = new HostedZoneStack(app, generateStackName('hosted-zone'), { +const hostedZoneStack = new HostedZoneStack(app, generateStackName('hostedzone'), { description: generateDescription('Hosted Zone stack'), env, tags, diff --git a/cloud/lib/api-stack.ts b/cloud/lib/api-stack.ts index c5a7d39b..168101d4 100644 --- a/cloud/lib/api-stack.ts +++ b/cloud/lib/api-stack.ts @@ -31,7 +31,7 @@ import { RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib/core'; import { Construct } from 'constructs'; import { join } from 'node:path'; -import { appName, resourceId } from './resourceNamingUtils'; +import { appName, resourceId, stageName } from './resourceNamingUtils'; type ApiStackProps = StackProps & { apiDomainName: string; @@ -46,6 +46,7 @@ export class ApiStack extends Stack { super(scope, id, props); const generateResourceId = resourceId(scope); + const stage = stageName(scope); const { apiDomainName, @@ -76,7 +77,7 @@ export class ApiStack extends Stack { const apiKeySecret = Secret.fromSecretNameV2( this, generateResourceId('apikey'), - 'dev/SpyLogic/ApiKey' + `${stage}/SpyLogic/ApiKey` ); /* diff --git a/cloud/lib/hostedzone-stack.ts b/cloud/lib/hostedzone-stack.ts index 990b020a..51af1f45 100644 --- a/cloud/lib/hostedzone-stack.ts +++ b/cloud/lib/hostedzone-stack.ts @@ -19,7 +19,7 @@ export class HostedZoneStack extends Stack { throw new Error('HOSTED_ZONE_ID not found in env vars'); } - this.hostedZone = HostedZone.fromHostedZoneAttributes(this, resourceId(scope)('hosted-zone'), { + this.hostedZone = HostedZone.fromHostedZoneAttributes(this, resourceId(scope)('hostedzone'), { hostedZoneId: HOSTED_ZONE_ID, zoneName: DOMAIN_NAME, }); diff --git a/cloud/lib/ui-stack.ts b/cloud/lib/ui-stack.ts index a7962832..df902c73 100644 --- a/cloud/lib/ui-stack.ts +++ b/cloud/lib/ui-stack.ts @@ -23,7 +23,7 @@ import { Duration, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib/core'; import { Construct } from 'constructs'; import { join } from 'node:path'; -import { appName, resourceId } from './resourceNamingUtils'; +import { appName, resourceId, stackName } from './resourceNamingUtils'; type UiStackProps = StackProps & { apiDomainName: string; @@ -94,6 +94,7 @@ export class UiStack extends Stack { generateResourceId('api-gatekeeper'), { functionName: 'edge-api-gatekeeper', + stackId: stackName(scope)('edge-lambda'), handler: 'index.handler', runtime: Runtime.NODEJS_18_X, code: new TypeScriptCode(join(__dirname, 'lambdas/verifyAuth/index.ts'), { diff --git a/cloud/package.json b/cloud/package.json index 644469f8..076e8ede 100644 --- a/cloud/package.json +++ b/cloud/package.json @@ -6,6 +6,7 @@ }, "scripts": { "cdk:synth": "cdk synth -q \"*\"", + "cdk:synth:prod": "cdk synth --context STAGE=prod -q \"*\"", "cdk:diff": "cdk diff --app cdk.out", "cdk:deploy": "cdk deploy --app cdk.out", "cdk:deploy:all": "cdk deploy --app cdk.out --all",