Skip to content

Commit

Permalink
feat(stacks.api): tag all stacks with myApplication tag
Browse files Browse the repository at this point in the history
Signed-off-by: Braden Mars <[email protected]>
  • Loading branch information
BradenM committed Dec 30, 2023
1 parent 9045e6e commit b6a8f65
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/stacks/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getConfig,
type Stage as ConfigStage,
} from '@crisiscleanup/config'
import { App } from 'aws-cdk-lib'
import { App, Tags } from 'aws-cdk-lib'
import {
KubePrometheusStackAddOn,
RedisStackAddOn,
Expand Down Expand Up @@ -149,6 +149,9 @@ const pipeline = Pipeline.builder({
})

await pipeline.waitForAsyncTasks()
if (config.pipeline.appRegistryTag) {
Tags.of(pipeline).add('awsApplication', config.pipeline.appRegistryTag)
}
app.synth({ validateOnSynthesis: true })

export default pipeline
23 changes: 21 additions & 2 deletions packages/stacks/api/src/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Stack,
type StackProps,
Duration,
Tags,
} from 'aws-cdk-lib'
import * as apigateway from 'aws-cdk-lib/aws-apigateway'
import * as iam from 'aws-cdk-lib/aws-iam'
Expand Down Expand Up @@ -185,8 +186,9 @@ export class Pipeline {
)
data.bastion.createDnsRecord(subZone)

let cacheStack: Stack | undefined = undefined
if (config.apiStack!.cache.enabled) {
new CacheStack(
cacheStack = new CacheStack(
scope,
env.id + '-cache',
{
Expand All @@ -197,7 +199,7 @@ export class Pipeline {
)
}

return envStackBuilder
const clusterStack = envStackBuilder
.resourceProvider(
blueprints.GlobalResources.Vpc,
new blueprints.DirectVpcProvider(network.vpc),
Expand Down Expand Up @@ -282,6 +284,23 @@ export class Pipeline {
}),
)
.build(scope, id, stackProps)

const stacks = [
delegatorZone,
delegateZoneStack,
network,
data,
cacheStack,
clusterStack,
].filter(Boolean) as Array<Stack>

if (config.pipeline.appRegistryTag) {
stacks.forEach((stack) => {
Tags.of(stack).add('awsApplication', config.pipeline.appRegistryTag)
Tags.of(stack).add('crisiscleanup:environment', env.id)
})
}
return clusterStack
},
async buildAsync(
scope: Construct,
Expand Down

0 comments on commit b6a8f65

Please sign in to comment.