Skip to content

Commit 7ddb305

Browse files
authored
feat(logs): configure custom subscription filter name (#26498)
Currently, we can't set the subscription filter name as a prop for L2 SubscriptionFilter construct. This PR introduces the new prop `filterName`. This will let us set a specific name without requiring escape hatches. Closes #26485 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent c45c174 commit 7ddb305

14 files changed

+738
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": "32.0.0",
3+
"files": {
4+
"7db545e495a738edfcd36389d734d374090aa78c8532312439ddb90cfffdc1ef": {
5+
"source": {
6+
"path": "aws-cdk-subscriptionfilter-integ.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"355939527584-us-east-1": {
11+
"bucketName": "cdk-hnb659fds-assets-355939527584-us-east-1",
12+
"objectKey": "7db545e495a738edfcd36389d734d374090aa78c8532312439ddb90cfffdc1ef.json",
13+
"region": "us-east-1",
14+
"assumeRoleArn": "arn:${AWS::Partition}:iam::355939527584:role/cdk-hnb659fds-file-publishing-role-355939527584-us-east-1"
15+
}
16+
}
17+
}
18+
},
19+
"dockerImages": {}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
"Resources": {
3+
"LogGroupF5B46931": {
4+
"Type": "AWS::Logs::LogGroup",
5+
"Properties": {
6+
"RetentionInDays": 731
7+
},
8+
"UpdateReplacePolicy": "Retain",
9+
"DeletionPolicy": "Retain"
10+
},
11+
"LogGroupSubscriptionCanInvokeLambdaE05AC235": {
12+
"Type": "AWS::Lambda::Permission",
13+
"Properties": {
14+
"Action": "lambda:InvokeFunction",
15+
"FunctionName": {
16+
"Fn::GetAtt": [
17+
"Function76856677",
18+
"Arn"
19+
]
20+
},
21+
"Principal": "logs.amazonaws.com",
22+
"SourceArn": {
23+
"Fn::GetAtt": [
24+
"LogGroupF5B46931",
25+
"Arn"
26+
]
27+
}
28+
}
29+
},
30+
"LogGroupSubscriptionE3573E29": {
31+
"Type": "AWS::Logs::SubscriptionFilter",
32+
"Properties": {
33+
"DestinationArn": {
34+
"Fn::GetAtt": [
35+
"Function76856677",
36+
"Arn"
37+
]
38+
},
39+
"FilterName": "CustomSubscriptionFilterName",
40+
"FilterPattern": "\"ERROR\" \"MainThread\"",
41+
"LogGroupName": {
42+
"Ref": "LogGroupF5B46931"
43+
}
44+
},
45+
"DependsOn": [
46+
"LogGroupSubscriptionCanInvokeLambdaE05AC235"
47+
]
48+
},
49+
"FunctionServiceRole675BB04A": {
50+
"Type": "AWS::IAM::Role",
51+
"Properties": {
52+
"AssumeRolePolicyDocument": {
53+
"Statement": [
54+
{
55+
"Action": "sts:AssumeRole",
56+
"Effect": "Allow",
57+
"Principal": {
58+
"Service": "lambda.amazonaws.com"
59+
}
60+
}
61+
],
62+
"Version": "2012-10-17"
63+
},
64+
"ManagedPolicyArns": [
65+
{
66+
"Fn::Join": [
67+
"",
68+
[
69+
"arn:",
70+
{
71+
"Ref": "AWS::Partition"
72+
},
73+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
74+
]
75+
]
76+
}
77+
]
78+
}
79+
},
80+
"Function76856677": {
81+
"Type": "AWS::Lambda::Function",
82+
"Properties": {
83+
"Code": {
84+
"ZipFile": "foo"
85+
},
86+
"Handler": "index.handler",
87+
"Role": {
88+
"Fn::GetAtt": [
89+
"FunctionServiceRole675BB04A",
90+
"Arn"
91+
]
92+
},
93+
"Runtime": "nodejs18.x"
94+
},
95+
"DependsOn": [
96+
"FunctionServiceRole675BB04A"
97+
]
98+
}
99+
},
100+
"Parameters": {
101+
"BootstrapVersion": {
102+
"Type": "AWS::SSM::Parameter::Value<String>",
103+
"Default": "/cdk-bootstrap/hnb659fds/version",
104+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
105+
}
106+
},
107+
"Rules": {
108+
"CheckBootstrapVersion": {
109+
"Assertions": [
110+
{
111+
"Assert": {
112+
"Fn::Not": [
113+
{
114+
"Fn::Contains": [
115+
[
116+
"1",
117+
"2",
118+
"3",
119+
"4",
120+
"5"
121+
],
122+
{
123+
"Ref": "BootstrapVersion"
124+
}
125+
]
126+
}
127+
]
128+
},
129+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
130+
}
131+
]
132+
}
133+
}
134+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"32.0.0"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "32.0.0",
3+
"testCases": {
4+
"integ-test/DefaultTest": {
5+
"stacks": [
6+
"aws-cdk-subscriptionfilter-integ"
7+
],
8+
"assertionStack": "integ-test/DefaultTest/DeployAssert",
9+
"assertionStackName": "integtestDefaultTestDeployAssert24D5C536"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "32.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "integtestDefaultTestDeployAssert24D5C536.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Parameters": {
3+
"BootstrapVersion": {
4+
"Type": "AWS::SSM::Parameter::Value<String>",
5+
"Default": "/cdk-bootstrap/hnb659fds/version",
6+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
7+
}
8+
},
9+
"Rules": {
10+
"CheckBootstrapVersion": {
11+
"Assertions": [
12+
{
13+
"Assert": {
14+
"Fn::Not": [
15+
{
16+
"Fn::Contains": [
17+
[
18+
"1",
19+
"2",
20+
"3",
21+
"4",
22+
"5"
23+
],
24+
{
25+
"Ref": "BootstrapVersion"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
32+
}
33+
]
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{
2+
"version": "32.0.0",
3+
"artifacts": {
4+
"aws-cdk-subscriptionfilter-integ.assets": {
5+
"type": "cdk:asset-manifest",
6+
"properties": {
7+
"file": "aws-cdk-subscriptionfilter-integ.assets.json",
8+
"requiresBootstrapStackVersion": 6,
9+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
10+
}
11+
},
12+
"aws-cdk-subscriptionfilter-integ": {
13+
"type": "aws:cloudformation:stack",
14+
"environment": "aws://355939527584/us-east-1",
15+
"properties": {
16+
"templateFile": "aws-cdk-subscriptionfilter-integ.template.json",
17+
"validateOnSynth": false,
18+
"assumeRoleArn": "arn:${AWS::Partition}:iam::355939527584:role/cdk-hnb659fds-deploy-role-355939527584-us-east-1",
19+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::355939527584:role/cdk-hnb659fds-cfn-exec-role-355939527584-us-east-1",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-355939527584-us-east-1/7db545e495a738edfcd36389d734d374090aa78c8532312439ddb90cfffdc1ef.json",
21+
"requiresBootstrapStackVersion": 6,
22+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
23+
"additionalDependencies": [
24+
"aws-cdk-subscriptionfilter-integ.assets"
25+
],
26+
"lookupRole": {
27+
"arn": "arn:${AWS::Partition}:iam::355939527584:role/cdk-hnb659fds-lookup-role-355939527584-us-east-1",
28+
"requiresBootstrapStackVersion": 8,
29+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
30+
}
31+
},
32+
"dependencies": [
33+
"aws-cdk-subscriptionfilter-integ.assets"
34+
],
35+
"metadata": {
36+
"/aws-cdk-subscriptionfilter-integ/LogGroup/Resource": [
37+
{
38+
"type": "aws:cdk:logicalId",
39+
"data": "LogGroupF5B46931"
40+
}
41+
],
42+
"/aws-cdk-subscriptionfilter-integ/LogGroup/Subscription/CanInvokeLambda": [
43+
{
44+
"type": "aws:cdk:logicalId",
45+
"data": "LogGroupSubscriptionCanInvokeLambdaE05AC235"
46+
}
47+
],
48+
"/aws-cdk-subscriptionfilter-integ/LogGroup/Subscription/Resource": [
49+
{
50+
"type": "aws:cdk:logicalId",
51+
"data": "LogGroupSubscriptionE3573E29"
52+
}
53+
],
54+
"/aws-cdk-subscriptionfilter-integ/Function/ServiceRole/Resource": [
55+
{
56+
"type": "aws:cdk:logicalId",
57+
"data": "FunctionServiceRole675BB04A"
58+
}
59+
],
60+
"/aws-cdk-subscriptionfilter-integ/Function/Resource": [
61+
{
62+
"type": "aws:cdk:logicalId",
63+
"data": "Function76856677"
64+
}
65+
],
66+
"/aws-cdk-subscriptionfilter-integ/BootstrapVersion": [
67+
{
68+
"type": "aws:cdk:logicalId",
69+
"data": "BootstrapVersion"
70+
}
71+
],
72+
"/aws-cdk-subscriptionfilter-integ/CheckBootstrapVersion": [
73+
{
74+
"type": "aws:cdk:logicalId",
75+
"data": "CheckBootstrapVersion"
76+
}
77+
]
78+
},
79+
"displayName": "aws-cdk-subscriptionfilter-integ"
80+
},
81+
"integtestDefaultTestDeployAssert24D5C536.assets": {
82+
"type": "cdk:asset-manifest",
83+
"properties": {
84+
"file": "integtestDefaultTestDeployAssert24D5C536.assets.json",
85+
"requiresBootstrapStackVersion": 6,
86+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
87+
}
88+
},
89+
"integtestDefaultTestDeployAssert24D5C536": {
90+
"type": "aws:cloudformation:stack",
91+
"environment": "aws://unknown-account/unknown-region",
92+
"properties": {
93+
"templateFile": "integtestDefaultTestDeployAssert24D5C536.template.json",
94+
"validateOnSynth": false,
95+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
96+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
97+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
98+
"requiresBootstrapStackVersion": 6,
99+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
100+
"additionalDependencies": [
101+
"integtestDefaultTestDeployAssert24D5C536.assets"
102+
],
103+
"lookupRole": {
104+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
105+
"requiresBootstrapStackVersion": 8,
106+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
107+
}
108+
},
109+
"dependencies": [
110+
"integtestDefaultTestDeployAssert24D5C536.assets"
111+
],
112+
"metadata": {
113+
"/integ-test/DefaultTest/DeployAssert/BootstrapVersion": [
114+
{
115+
"type": "aws:cdk:logicalId",
116+
"data": "BootstrapVersion"
117+
}
118+
],
119+
"/integ-test/DefaultTest/DeployAssert/CheckBootstrapVersion": [
120+
{
121+
"type": "aws:cdk:logicalId",
122+
"data": "CheckBootstrapVersion"
123+
}
124+
]
125+
},
126+
"displayName": "integ-test/DefaultTest/DeployAssert"
127+
},
128+
"Tree": {
129+
"type": "cdk:tree",
130+
"properties": {
131+
"file": "tree.json"
132+
}
133+
}
134+
}
135+
}

0 commit comments

Comments
 (0)