Skip to content

Commit ee7804f

Browse files
Merge pull request #60 from Pocket/katerina/SOCIALPLAT-257-ts-logger-cloudwatch
Chore: Adding ts-logger, logging to cloudwatch & cleanup
2 parents 79f1a6f + 3352010 commit ee7804f

File tree

12 files changed

+26396
-13591
lines changed

12 files changed

+26396
-13591
lines changed

.aws/package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.aws/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"node": "=18"
1818
},
1919
"dependencies": {
20-
"@pocket-tools/terraform-modules": "4.14.0"
20+
"@pocket-tools/terraform-modules": "^4.17.0"
2121
},
2222
"devDependencies": {
2323
"@pocket-tools/tsconfig": "2.0.1",

.aws/src/main.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
import { PagerdutyProvider } from '@cdktf/provider-pagerduty/lib/provider';
2424
import { LocalProvider } from '@cdktf/provider-local/lib/provider';
2525
import { NullProvider } from '@cdktf/provider-null/lib/provider';
26+
import { CloudwatchLogGroup } from '@cdktf/provider-aws/lib/cloudwatch-log-group';
2627
import * as fs from 'fs';
2728

2829
class Stack extends TerraformStack {
@@ -169,25 +170,15 @@ class Stack extends TerraformStack {
169170
value: process.env.NODE_ENV, // this gives us a nice lowercase production and development
170171
},
171172
],
173+
logGroup: this.createCustomLogGroup('app'),
174+
logMultilinePattern: '^\\S.+',
172175
secretEnvVars: [
173176
{
174177
name: 'SENTRY_DSN',
175178
valueFrom: `arn:aws:ssm:${region.name}:${caller.accountId}:parameter/${config.name}/${config.environment}/SENTRY_DSN`,
176179
},
177180
],
178181
},
179-
{
180-
name: 'xray-daemon',
181-
containerImage: 'public.ecr.aws/xray/aws-xray-daemon:latest',
182-
portMappings: [
183-
{
184-
hostPort: 2000,
185-
containerPort: 2000,
186-
protocol: 'udp',
187-
},
188-
],
189-
command: ['--region', 'us-east-1', '--local-mode'],
190-
},
191182
],
192183
codeDeploy: {
193184
useCodeDeploy: true,
@@ -281,7 +272,7 @@ class Stack extends TerraformStack {
281272
* @private
282273
*/
283274
private createWafAcl() {
284-
/*
275+
/*
285276
Rule 0: MozillaOpsSource
286277
287278
Requests originating from Mozilla hosted Google CDNs include the following headers:
@@ -365,6 +356,25 @@ class Stack extends TerraformStack {
365356
rule: [mozillaOpsSourceRule, globalRateLimitRule],
366357
});
367358
}
359+
/**
360+
* Create Custom log group for ECS to share across task revisions
361+
* @param containerName
362+
* @private
363+
*/
364+
private createCustomLogGroup(containerName: string) {
365+
const logGroup = new CloudwatchLogGroup(
366+
this,
367+
`${containerName}-log-group`,
368+
{
369+
name: `/Backend/${config.prefix}/ecs/${containerName}`,
370+
retentionInDays: 90,
371+
skipDestroy: true,
372+
tags: config.tags,
373+
}
374+
);
375+
376+
return logGroup.name;
377+
}
368378
}
369379

370380
const app = new App();

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ dist
3535

3636
# JSON is required for some tools and may be generated, only check in and edit openapi.yml
3737
openapi.json
38+
39+
# server logs
40+
logs

0 commit comments

Comments
 (0)