diff --git a/infra/cdktf/src/lib/app-stack.ts b/infra/cdktf/src/lib/app-stack.ts index d171b876..0b1e2e3a 100644 --- a/infra/cdktf/src/lib/app-stack.ts +++ b/infra/cdktf/src/lib/app-stack.ts @@ -8,15 +8,18 @@ import { withBackend } from './backend'; import { CloudGovSpace } from './cloud.gov/space'; import { DataAwsSsmParameter } from '../../.gen/providers/aws/data-aws-ssm-parameter'; -export const registerAppStack = (stackPrefix: string, deployEnv: string) => { +export const registerAppStack = ( + stackPrefix: string, + gitCommitHash: string +) => { const app = new App(); - const stack = new AppStack(app, stackPrefix, deployEnv); + const stack = new AppStack(app, stackPrefix, gitCommitHash); withBackend(stack, stackPrefix); app.synth(); }; class AppStack extends TerraformStack { - constructor(scope: Construct, id: string, deployEnv: string) { + constructor(scope: Construct, id: string, gitCommitHash: string) { super(scope, id); new AwsProvider(this, 'AWS', { @@ -45,7 +48,7 @@ class AppStack extends TerraformStack { password: cfPassword.value, }); - new CloudGovSpace(this, id, deployEnv); + new CloudGovSpace(this, id, gitCommitHash); //new Docassemble(this, `${id}-docassemble`); //new FormService(this, `${id}-rest-api`); diff --git a/infra/cdktf/src/lib/cloud.gov/space.ts b/infra/cdktf/src/lib/cloud.gov/space.ts index 85fbf4ba..77c36925 100644 --- a/infra/cdktf/src/lib/cloud.gov/space.ts +++ b/infra/cdktf/src/lib/cloud.gov/space.ts @@ -6,7 +6,7 @@ import { AstroService } from './node-astro'; import { getSecret } from '../secrets'; export class CloudGovSpace extends Construct { - constructor(scope: Construct, id: string, deployEnv: string) { + constructor(scope: Construct, id: string, gitCommitHash: string) { super(scope, id); const space = new cloudfoundry.dataCloudfoundrySpace.DataCloudfoundrySpace( @@ -22,7 +22,7 @@ export class CloudGovSpace extends Construct { scope, `${id}-server-doj`, space.id, - `server-doj:${deployEnv}`, + `server-doj:${gitCommitHash}`, { loginGovPrivateKey: getSecret( this, @@ -34,7 +34,7 @@ export class CloudGovSpace extends Construct { scope, `${id}-server-kansas`, space.id, - `server-kansas:${deployEnv}`, + `server-kansas:${gitCommitHash}`, { loginGovPrivateKey: getSecret( this, diff --git a/infra/cdktf/src/spaces/main.ts b/infra/cdktf/src/spaces/main.ts index 34ed8c1c..839824f9 100644 --- a/infra/cdktf/src/spaces/main.ts +++ b/infra/cdktf/src/spaces/main.ts @@ -1,3 +1,6 @@ +import { execSync } from 'child_process'; + import { registerAppStack } from '../lib/app-stack'; -registerAppStack('tts-10x-atj-dev', 'main'); +const gitCommitHash = execSync('git rev-parse HEAD').toString().trim(); +registerAppStack('tts-10x-atj-dev', gitCommitHash); diff --git a/infra/cdktf/src/spaces/staging.ts b/infra/cdktf/src/spaces/staging.ts index d6425f1e..ac44cf85 100644 --- a/infra/cdktf/src/spaces/staging.ts +++ b/infra/cdktf/src/spaces/staging.ts @@ -1,3 +1,6 @@ +import { execSync } from 'child_process'; + import { registerAppStack } from '../lib/app-stack'; -registerAppStack('tts-10x-atj-staging', 'staging'); +const gitCommitHash = execSync('git rev-parse HEAD').toString().trim(); +registerAppStack('tts-10x-atj-staging', gitCommitHash);