Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
akash1810 committed Oct 13, 2023
1 parent 348b22a commit 3d96471
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 0 deletions.
107 changes: 107 additions & 0 deletions lib/__snapshots__/interactive-tilemaker.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,29 @@ exports[`The InteractiveTilemaker stack matches the snapshot 1`] = `
{
"Essential": true,
"Image": "hello-world",
"LogConfiguration": {
"LogDriver": "awslogs",
"Options": {
"awslogs-group": {
"Ref": "TileMakerTaskHelloWorldContainerLogGroup15B4BEFA",
},
"awslogs-region": {
"Ref": "AWS::Region",
},
"awslogs-stream-prefix": "tile-maker/hello-world",
},
},
"Memory": 2048,
"Name": "HelloWorldContainer",
},
],
"Cpu": "1024",
"ExecutionRoleArn": {
"Fn::GetAtt": [
"TileMakerTaskExecutionRole9653D5DB",
"Arn",
],
},
"Family": "InteractiveTilemakerTileMakerTask12DC9A80",
"Memory": "2048",
"NetworkMode": "awsvpc",
Expand Down Expand Up @@ -189,6 +207,95 @@ exports[`The InteractiveTilemaker stack matches the snapshot 1`] = `
},
"Type": "AWS::ECS::TaskDefinition",
},
"TileMakerTaskExecutionRole9653D5DB": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com",
},
},
],
"Version": "2012-10-17",
},
"Tags": [
{
"Key": "gu:cdk:version",
"Value": "TEST",
},
{
"Key": "gu:repo",
"Value": "guardian/interactive-tilemaker",
},
{
"Key": "Stack",
"Value": "interactives",
},
{
"Key": "Stage",
"Value": "TEST",
},
],
},
"Type": "AWS::IAM::Role",
},
"TileMakerTaskExecutionRoleDefaultPolicy10BD4468": {
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": [
"logs:CreateLogStream",
"logs:PutLogEvents",
],
"Effect": "Allow",
"Resource": {
"Fn::GetAtt": [
"TileMakerTaskHelloWorldContainerLogGroup15B4BEFA",
"Arn",
],
},
},
],
"Version": "2012-10-17",
},
"PolicyName": "TileMakerTaskExecutionRoleDefaultPolicy10BD4468",
"Roles": [
{
"Ref": "TileMakerTaskExecutionRole9653D5DB",
},
],
},
"Type": "AWS::IAM::Policy",
},
"TileMakerTaskHelloWorldContainerLogGroup15B4BEFA": {
"DeletionPolicy": "Retain",
"Properties": {
"Tags": [
{
"Key": "gu:cdk:version",
"Value": "TEST",
},
{
"Key": "gu:repo",
"Value": "guardian/interactive-tilemaker",
},
{
"Key": "Stack",
"Value": "interactives",
},
{
"Key": "Stage",
"Value": "TEST",
},
],
},
"Type": "AWS::Logs::LogGroup",
"UpdateReplacePolicy": "Retain",
},
"TileMakerTaskTaskRole4911CC8F": {
"Properties": {
"AssumeRolePolicyDocument": {
Expand Down
2 changes: 2 additions & 0 deletions lib/interactive-tilemaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ContainerImage,
CpuArchitecture,
FargateService,
LogDriver,
OperatingSystemFamily,
TaskDefinition,
} from 'aws-cdk-lib/aws-ecs';
Expand Down Expand Up @@ -47,6 +48,7 @@ export class InteractiveTilemaker extends GuStack {
task.addContainer('HelloWorldContainer', {
image: ContainerImage.fromRegistry('hello-world'),
memoryLimitMiB: 2048,
logging: LogDriver.awsLogs({streamPrefix: "tile-maker/hello-world"})
});

new FargateService(this, 'TileMakerService', {
Expand Down

0 comments on commit 3d96471

Please sign in to comment.