Skip to content

Commit

Permalink
Use git commit hash rather than deployment identifier as the deployme…
Browse files Browse the repository at this point in the history
…nt's docker tag
  • Loading branch information
danielnaab committed Aug 8, 2024
1 parent 946b292 commit 940167a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
11 changes: 7 additions & 4 deletions infra/cdktf/src/lib/app-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down Expand Up @@ -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`);
Expand Down
6 changes: 3 additions & 3 deletions infra/cdktf/src/lib/cloud.gov/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -22,7 +22,7 @@ export class CloudGovSpace extends Construct {
scope,
`${id}-server-doj`,
space.id,
`server-doj:${deployEnv}`,
`server-doj:${gitCommitHash}`,
{
loginGovPrivateKey: getSecret(
this,
Expand All @@ -34,7 +34,7 @@ export class CloudGovSpace extends Construct {
scope,
`${id}-server-kansas`,
space.id,
`server-kansas:${deployEnv}`,
`server-kansas:${gitCommitHash}`,
{
loginGovPrivateKey: getSecret(
this,
Expand Down
5 changes: 4 additions & 1 deletion infra/cdktf/src/spaces/main.ts
Original file line number Diff line number Diff line change
@@ -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);
5 changes: 4 additions & 1 deletion infra/cdktf/src/spaces/staging.ts
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 940167a

Please sign in to comment.