Skip to content

Commit

Permalink
DO-1666: update gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
gowrizrh committed May 31, 2024
1 parent 5854ba2 commit 9d3b3c2
Show file tree
Hide file tree
Showing 5 changed files with 1,263 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Thumbs.db
cdk.out

*.d.ts
*.js
# *.js

# Lock files
package-lock.json
2 changes: 1 addition & 1 deletion packages/prerender-fargate/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
!lib/prerender/*
!lib/prerender/**
39 changes: 38 additions & 1 deletion packages/prerender-fargate/lib/prerender-fargate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Duration, RemovalPolicy, Stack } from "aws-cdk-lib";
import * as path from "path";
import { PrerenderRecacheApi } from "./recaching/prerender-recache-api-construct";
import { PrerenderFargateOptions } from "./prerender-fargate-options";
import { RetentionDays } from "aws-cdk-lib/aws-logs";

/**
* `PrerenderFargate` construct sets up an AWS Fargate service to run a
Expand Down Expand Up @@ -148,6 +149,17 @@ export class PrerenderFargate extends Construct {
),
};

const firelensLogDriver = ecs.LogDrivers.firelens({
options: {
Name: 'grafana-loki',
Url: 'http://loki:3100/loki/api/v1/push',
Labels: '{job="prerender"}',
RemoveKeys: 'container_id,ecs_task_arn,container_name,ecs_task_definition,source,ecs_cluster',
LabelKeys: "level",
LineFormat: 'json',
},
});

// Create a load-balanced Fargate service
const fargateService =
new ecsPatterns.ApplicationLoadBalancedFargateService(
Expand All @@ -162,7 +174,7 @@ export class PrerenderFargate extends Construct {
taskImageOptions: {
containerName: `${prerenderName}-container`,
image: ecs.ContainerImage.fromDockerImageAsset(asset),
enableLogging: true,
logDriver: firelensLogDriver,
containerPort: 3000,
environment,
secrets,
Expand Down Expand Up @@ -204,6 +216,31 @@ export class PrerenderFargate extends Construct {
}
);

fargateService.taskDefinition.addFirelensLogRouter("firelens", {
essential: false,
image: ecs.EcrImage.fromRegistry(
"grafana/fluent-bit-plugin-loki:main-e2ed1c0"
),
containerName: "log_router",
firelensConfig: {
type: ecs.FirelensLogRouterType.FLUENTBIT,
options: {
enableECSLogMetadata: false,
},
},
logging: ecs.LogDrivers.awsLogs({
streamPrefix: "firelens",
logRetention: RetentionDays.ONE_WEEK,
}),
memoryReservationMiB: 50,
});

fargateService.targetGroup.setAttribute('deregistration_delay.timeout_seconds', '5');

fargateService.service.enableServiceConnect({
namespace: 'svc.internal'
});

// Grant S3 Bucket access to the task role
this.bucket.grantReadWrite(fargateService.taskDefinition.taskRole);

Expand Down
Loading

0 comments on commit 9d3b3c2

Please sign in to comment.