Skip to content

Commit

Permalink
fix(cloudquery): Add required ASG tags for devx-logs
Browse files Browse the repository at this point in the history
The `LogKinesisStreamName` and `SystemdUnit` tags are required by `devx-logs`.

GuCDK only adds these tags automatically at the pattern level, so we have manually add them.

See guardian/cdk#1800.

Co-authored-by: TJ Silver <[email protected]>
Co-authored-by: NovemberTang <[email protected]>
Co-authored-by: nicl <[email protected]>
Co-authored-by: JuliaBrigitte <[email protected]>
  • Loading branch information
5 people committed Mar 31, 2023
1 parent 47344b8 commit 7a3f29e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/cdk/lib/__snapshots__/cloudquery.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,13 @@ exports[`The CloudQuery stack matches the snapshot 1`] = `
"PropagateAtLaunch": true,
"Value": "guardian/service-catalogue",
},
{
"Key": "LogKinesisStreamName",
"PropagateAtLaunch": true,
"Value": {
"Ref": "LoggingStreamName",
},
},
{
"Key": "Name",
"PropagateAtLaunch": true,
Expand All @@ -751,6 +758,11 @@ exports[`The CloudQuery stack matches the snapshot 1`] = `
"PropagateAtLaunch": true,
"Value": "TEST",
},
{
"Key": "SystemdUnit",
"PropagateAtLaunch": true,
"Value": "cloudquery.service",
},
],
"VPCZoneIdentifier": {
"Ref": "cloudqueryPrivateSubnets",
Expand Down
16 changes: 15 additions & 1 deletion packages/cdk/lib/cloudquery.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { MetadataKeys } from '@guardian/cdk/lib/constants';
import type { GuAutoScalingGroupProps } from '@guardian/cdk/lib/constructs/autoscaling';
import { GuAutoScalingGroup } from '@guardian/cdk/lib/constructs/autoscaling';
import type { GuStackProps } from '@guardian/cdk/lib/constructs/core';
import {
GuDistributionBucketParameter,
GuLoggingStreamNameParameter,
GuStack,
} from '@guardian/cdk/lib/constructs/core';
import {
Expand All @@ -11,7 +13,7 @@ import {
SubnetType,
} from '@guardian/cdk/lib/constructs/ec2';
import type { App } from 'aws-cdk-lib';
import { CfnParameter } from 'aws-cdk-lib';
import { CfnParameter, Tags } from 'aws-cdk-lib';
import {
InstanceClass,
InstanceSize,
Expand Down Expand Up @@ -163,6 +165,18 @@ export class CloudQuery extends GuStack {

const asg = new GuAutoScalingGroup(this, 'asg', asgProps);

/*
Manually add tags required by devx-logs to build fluentbit configuration,
as GuCDK does not currently support this.
See https://github.com/guardian/cdk/issues/1800.
*/
Tags.of(asg).add(
MetadataKeys.LOG_KINESIS_STREAM_NAME,
GuLoggingStreamNameParameter.getInstance(this).valueAsString,
);
Tags.of(asg).add(MetadataKeys.SYSTEMD_UNIT, `${app}.service`);

asg.role.addManagedPolicy(
ManagedPolicy.fromManagedPolicyArn(
this,
Expand Down

0 comments on commit 7a3f29e

Please sign in to comment.