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

Align CDK Template #1577

Merged
merged 29 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
68b6750
Align
samchungy Jun 8, 2024
888b127
add dep
samchungy Jun 8, 2024
28d2e78
Merge branch 'main' into upgrade-cdk-template
samchungy Jun 8, 2024
60659f4
update hooks
samchungy Jun 8, 2024
2ec8e20
Merge branch 'upgrade-cdk-template' of github.com:seek-oss/skuba into…
samchungy Jun 8, 2024
c3e222d
update
samchungy Jun 8, 2024
46311fc
Merge branch 'main' into upgrade-cdk-template
samchungy Jun 8, 2024
b61f9d2
fix
samchungy Jun 8, 2024
3537f89
Update hot-worms-decide.md
samchungy Jun 8, 2024
fd204b0
update bundler settings
samchungy Jun 8, 2024
92c9a4b
Merge branch 'upgrade-cdk-template' of github.com:seek-oss/skuba into…
samchungy Jun 8, 2024
cbf83d8
Update hot-worms-decide.md
samchungy Jun 8, 2024
a4172e2
add extension layer
samchungy Jun 8, 2024
1f2a1ae
Merge branch 'upgrade-cdk-template' of github.com:seek-oss/skuba into…
samchungy Jun 8, 2024
2a2adfe
update bundling
samchungy Jun 8, 2024
fe58114
Merge branch 'main' of github.com:seek-oss/skuba into upgrade-cdk-tem…
samchungy Jun 19, 2024
4721553
Merge branch 'main' of github.com:seek-oss/skuba into upgrade-cdk-tem…
samchungy Sep 28, 2024
402afab
fix lock
samchungy Sep 28, 2024
ca287df
export schema to fix lint error
samchungy Sep 28, 2024
6446df4
Merge branch 'main' of github.com:seek-oss/skuba into upgrade-cdk-tem…
samchungy Oct 2, 2024
b721a9a
further alignment
samchungy Oct 2, 2024
1a4f706
Bump datadog extension
samchungy Oct 18, 2024
ff41462
update version name
samchungy Oct 18, 2024
d6a6135
Merge branch 'main' of github.com:seek-oss/skuba into upgrade-cdk-tem…
samchungy Oct 18, 2024
9d4d67a
remove redundant default sections
samchungy Oct 18, 2024
00664b4
tweak
samchungy Oct 18, 2024
ed68214
replace lambda version
samchungy Oct 19, 2024
77d75a8
bump datadog-lambda-js
samchungy Oct 19, 2024
f479b47
lock
samchungy Oct 19, 2024
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
7 changes: 7 additions & 0 deletions .changeset/hot-worms-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'skuba': patch
---

template/lambda-sqs-worker-cdk: Align template with Serverless template

This adds the same boilerplate code available in `lambda-sqs-worker` along with Datadog integration.
1 change: 1 addition & 0 deletions template/lambda-sqs-worker-cdk/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENVIRONMENT=local
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,40 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
},
"Type": "AWS::IAM::Policy",
},
"datadogapikeysecret046FEF06": {
"DeletionPolicy": "Delete",
"Properties": {
"GenerateSecretString": {},
},
"Type": "AWS::SecretsManager::Secret",
"UpdateReplacePolicy": "Delete",
},
"destinationtopicDCE2E0B8": {
"Properties": {
"KmsMasterKeyId": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition",
},
":kms:",
{
"Ref": "AWS::Region",
},
":",
{
"Ref": "AWS::AccountId",
},
":alias/aws/sns",
],
],
},
"TopicName": "serviceName",
},
"Type": "AWS::SNS::Topic",
},
"kmskey49FBC3B3": {
"DeletionPolicy": "Retain",
"Properties": {
Expand Down Expand Up @@ -448,6 +482,22 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
"Description": "Updated at 1212-12-12T12:12:12.121Z",
"Environment": {
"Variables": {
"DD_API_KEY_SECRET_ARN": {
"Ref": "datadogapikeysecret046FEF06",
},
"DD_CAPTURE_LAMBDA_PAYLOAD": "false",
"DD_FLUSH_TO_LOG": "false",
"DD_LAMBDA_HANDLER": "index.handler",
"DD_LOGS_INJECTION": "false",
"DD_MERGE_XRAY_TRACES": "false",
"DD_SERVERLESS_APPSEC_ENABLED": "false",
"DD_SERVERLESS_LOGS_ENABLED": "false",
"DD_SITE": "datadoghq.com",
"DD_TAGS": "git.commit.sha:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,git.repository_url:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"DD_TRACE_ENABLED": "true",
"DESTINATION_SNS_TOPIC_ARN": {
"Ref": "destinationtopicDCE2E0B8",
},
"ENVIRONMENT": "dev",
"NODE_ENV": "production",
"NODE_OPTIONS": "--enable-source-maps",
Expand All @@ -456,13 +506,27 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
},
},
"FunctionName": "serviceName",
"Handler": "index.handler",
"Handler": "node_modules/datadog-lambda-js/dist/handler.handler",
"KmsKeyArn": {
"Fn::GetAtt": [
"kmskey49FBC3B3",
"Arn",
],
},
"Layers": [
{
"Fn::Join": [
"",
[
"arn:aws:lambda:",
{
"Ref": "AWS::Region",
},
":464622532012:layer:Datadog-Extension-ARM:58",
],
],
},
],
"ReservedConcurrentExecutions": 2,
"Role": {
"Fn::GetAtt": [
Expand All @@ -471,6 +535,12 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
],
},
"Runtime": "nodejs20.x",
"Tags": [
{
"Key": "dd_cdk_construct",
"Value": "v1.13.0",
},
],
"Timeout": 30,
},
"Type": "AWS::Lambda::Function",
Expand Down Expand Up @@ -585,6 +655,16 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": [
"secretsmanager:GetSecretValue",
"secretsmanager:DescribeSecret",
],
"Effect": "Allow",
"Resource": {
"Ref": "datadogapikeysecret046FEF06",
},
},
{
"Action": [
"sqs:ReceiveMessage",
Expand Down Expand Up @@ -651,7 +731,7 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
},
},
"FunctionName": "serviceName-post-hook",
"Handler": "index.handler",
"Handler": "index.post",
"KmsKeyArn": {
"Fn::GetAtt": [
"kmskey49FBC3B3",
Expand Down Expand Up @@ -805,7 +885,7 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
},
},
"FunctionName": "serviceName-pre-hook",
"Handler": "index.handler",
"Handler": "index.pre",
"KmsKeyArn": {
"Fn::GetAtt": [
"kmskey49FBC3B3",
Expand Down Expand Up @@ -1350,6 +1430,40 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
},
"Type": "AWS::IAM::Policy",
},
"datadogapikeysecret046FEF06": {
"DeletionPolicy": "Delete",
"Properties": {
"GenerateSecretString": {},
},
"Type": "AWS::SecretsManager::Secret",
"UpdateReplacePolicy": "Delete",
},
"destinationtopicDCE2E0B8": {
"Properties": {
"KmsMasterKeyId": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition",
},
":kms:",
{
"Ref": "AWS::Region",
},
":",
{
"Ref": "AWS::AccountId",
},
":alias/aws/sns",
],
],
},
"TopicName": "serviceName",
},
"Type": "AWS::SNS::Topic",
},
"kmskey49FBC3B3": {
"DeletionPolicy": "Retain",
"Properties": {
Expand Down Expand Up @@ -1496,6 +1610,22 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
"Description": "Updated at 1212-12-12T12:12:12.121Z",
"Environment": {
"Variables": {
"DD_API_KEY_SECRET_ARN": {
"Ref": "datadogapikeysecret046FEF06",
},
"DD_CAPTURE_LAMBDA_PAYLOAD": "false",
"DD_FLUSH_TO_LOG": "false",
"DD_LAMBDA_HANDLER": "index.handler",
"DD_LOGS_INJECTION": "false",
"DD_MERGE_XRAY_TRACES": "false",
"DD_SERVERLESS_APPSEC_ENABLED": "false",
"DD_SERVERLESS_LOGS_ENABLED": "false",
"DD_SITE": "datadoghq.com",
"DD_TAGS": "git.commit.sha:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,git.repository_url:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"DD_TRACE_ENABLED": "true",
"DESTINATION_SNS_TOPIC_ARN": {
"Ref": "destinationtopicDCE2E0B8",
},
"ENVIRONMENT": "prod",
"NODE_ENV": "production",
"NODE_OPTIONS": "--enable-source-maps",
Expand All @@ -1504,13 +1634,27 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
},
},
"FunctionName": "serviceName",
"Handler": "index.handler",
"Handler": "node_modules/datadog-lambda-js/dist/handler.handler",
"KmsKeyArn": {
"Fn::GetAtt": [
"kmskey49FBC3B3",
"Arn",
],
},
"Layers": [
{
"Fn::Join": [
"",
[
"arn:aws:lambda:",
{
"Ref": "AWS::Region",
},
":464622532012:layer:Datadog-Extension-ARM:58",
],
],
},
],
"ReservedConcurrentExecutions": 20,
"Role": {
"Fn::GetAtt": [
Expand All @@ -1519,6 +1663,12 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
],
},
"Runtime": "nodejs20.x",
"Tags": [
{
"Key": "dd_cdk_construct",
"Value": "v1.13.0",
},
],
"Timeout": 30,
},
"Type": "AWS::Lambda::Function",
Expand Down Expand Up @@ -1633,6 +1783,16 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": [
"secretsmanager:GetSecretValue",
"secretsmanager:DescribeSecret",
],
"Effect": "Allow",
"Resource": {
"Ref": "datadogapikeysecret046FEF06",
},
},
{
"Action": [
"sqs:ReceiveMessage",
Expand Down Expand Up @@ -1699,7 +1859,7 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
},
},
"FunctionName": "serviceName-post-hook",
"Handler": "index.handler",
"Handler": "index.post",
"KmsKeyArn": {
"Fn::GetAtt": [
"kmskey49FBC3B3",
Expand Down Expand Up @@ -1853,7 +2013,7 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
},
},
"FunctionName": "serviceName-pre-hook",
"Handler": "index.handler",
"Handler": "index.pre",
"KmsKeyArn": {
"Fn::GetAtt": [
"kmskey49FBC3B3",
Expand Down
15 changes: 13 additions & 2 deletions template/lambda-sqs-worker-cdk/infra/appStack.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, aws_sns } from 'aws-cdk-lib';
import { App, aws_secretsmanager, aws_sns } from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';

const currentDate = '1212-12-12T12:12:12.121Z';
Expand Down Expand Up @@ -36,6 +36,12 @@ it.each(['dev', 'prod'])(
.spyOn(aws_sns.Topic, 'fromTopicArn')
.mockImplementation((scope, id) => new aws_sns.Topic(scope, id));

jest
.spyOn(aws_secretsmanager.Secret, 'fromSecretPartialArn')
.mockImplementation(
(scope, id) => new aws_secretsmanager.Secret(scope, id),
);

const app = new App();

const stack = new AppStack(app, 'appStack');
Expand All @@ -47,9 +53,14 @@ it.each(['dev', 'prod'])(
/"S3Key":"([0-9a-f]+)\.zip"/g,
(_, hash) => `"S3Key":"${'x'.repeat(hash.length)}.zip"`,
)
.replaceAll(
.replace(
/workerCurrentVersion([0-9a-zA-Z]+)"/g,
(_, hash) => `workerCurrentVersion${'x'.repeat(hash.length)}"`,
)
.replace(
/"DD_TAGS":"git.commit.sha:([0-9a-f]+),git.repository_url:([^\"]+)"/g,
(_, sha, url) =>
`"DD_TAGS":"git.commit.sha:${'x'.repeat(sha.length)},git.repository_url:${'x'.repeat(url.length)}"`,
);

expect(JSON.parse(json)).toMatchSnapshot();
Expand Down
Loading
Loading