Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: set lambda to log as JSON #3362

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 92 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/_infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"@basemaps/lambda-tiler": "^7.11.0",
"@basemaps/shared": "^7.11.0",
"@linzjs/cdk-tags": "^1.7.0",
"aws-cdk": "2.114.x",
"aws-cdk-lib": "2.114.x",
"constructs": "^10.3.0"
"aws-cdk": "2.162.x",
"aws-cdk-lib": "2.162.x",
"constructs": "^10.4.2"
}
}
11 changes: 6 additions & 5 deletions packages/_infra/src/analytics/edge.analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Env } from '@basemaps/shared';
import { Duration, Stack, StackProps } from 'aws-cdk-lib';
import { Rule, Schedule } from 'aws-cdk-lib/aws-events';
import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
import lf from 'aws-cdk-lib/aws-lambda';
import lambda from 'aws-cdk-lib/aws-lambda';
import { RetentionDays } from 'aws-cdk-lib/aws-logs';
import { BlockPublicAccess, Bucket } from 'aws-cdk-lib/aws-s3';
import { Construct } from 'constructs';
Expand All @@ -18,7 +18,7 @@ export interface EdgeAnalyticsProps extends StackProps {
* Every hour create analytics based off the logs given to us from cloudwatch
*/
export class EdgeAnalytics extends Stack {
public lambda: lf.Function;
public lambda: lambda.Function;

public constructor(scope: Construct, id: string, props: EdgeAnalyticsProps) {
super(scope, id, props);
Expand All @@ -31,19 +31,20 @@ export class EdgeAnalytics extends Stack {
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
});

this.lambda = new lf.Function(this, 'AnalyticLambda', {
runtime: lf.Runtime.NODEJS_18_X,
this.lambda = new lambda.Function(this, 'AnalyticLambda', {
runtime: lambda.Runtime.NODEJS_18_X,
memorySize: 2048,
timeout: Duration.minutes(10),
handler: 'index.handler',
code: lf.Code.fromAsset(CODE_PATH),
code: lambda.Code.fromAsset(CODE_PATH),
environment: {
[Env.Analytics.CloudFrontId]: distributionId,
[Env.Analytics.CacheBucket]: `s3://${cacheBucket.bucketName}`,
[Env.Analytics.CloudFrontSourceBucket]: `s3://${logBucket.bucketName}`,
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
},
logRetention: RetentionDays.ONE_MONTH,
loggingFormat: lambda.LoggingFormat.JSON,
});

cacheBucket.grantReadWrite(this.lambda);
Expand Down
1 change: 1 addition & 0 deletions packages/_infra/src/serve/lambda.tiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class LambdaTiler extends Construct {
architecture: lambda.Architecture.ARM_64,
environment,
logRetention: RetentionDays.ONE_MONTH,
loggingFormat: lambda.LoggingFormat.JSON,
});

this.functionUrl = new lambda.FunctionUrl(this, 'LambdaCogUrl', {
Expand Down
Loading