Skip to content

Commit

Permalink
feat(logs): configure custom subscription filter name (#26498)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
tam0ri committed Jul 27, 2023
1 parent c45c174 commit 7ddb305
Show file tree
Hide file tree
Showing 14 changed files with 738 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "32.0.0",
"files": {
"7db545e495a738edfcd36389d734d374090aa78c8532312439ddb90cfffdc1ef": {
"source": {
"path": "aws-cdk-subscriptionfilter-integ.template.json",
"packaging": "file"
},
"destinations": {
"355939527584-us-east-1": {
"bucketName": "cdk-hnb659fds-assets-355939527584-us-east-1",
"objectKey": "7db545e495a738edfcd36389d734d374090aa78c8532312439ddb90cfffdc1ef.json",
"region": "us-east-1",
"assumeRoleArn": "arn:${AWS::Partition}:iam::355939527584:role/cdk-hnb659fds-file-publishing-role-355939527584-us-east-1"
}
}
}
},
"dockerImages": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"Resources": {
"LogGroupF5B46931": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"RetentionInDays": 731
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
"LogGroupSubscriptionCanInvokeLambdaE05AC235": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"Function76856677",
"Arn"
]
},
"Principal": "logs.amazonaws.com",
"SourceArn": {
"Fn::GetAtt": [
"LogGroupF5B46931",
"Arn"
]
}
}
},
"LogGroupSubscriptionE3573E29": {
"Type": "AWS::Logs::SubscriptionFilter",
"Properties": {
"DestinationArn": {
"Fn::GetAtt": [
"Function76856677",
"Arn"
]
},
"FilterName": "CustomSubscriptionFilterName",
"FilterPattern": "\"ERROR\" \"MainThread\"",
"LogGroupName": {
"Ref": "LogGroupF5B46931"
}
},
"DependsOn": [
"LogGroupSubscriptionCanInvokeLambdaE05AC235"
]
},
"FunctionServiceRole675BB04A": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
]
]
}
]
}
},
"Function76856677": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "foo"
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"FunctionServiceRole675BB04A",
"Arn"
]
},
"Runtime": "nodejs18.x"
},
"DependsOn": [
"FunctionServiceRole675BB04A"
]
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"32.0.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "32.0.0",
"testCases": {
"integ-test/DefaultTest": {
"stacks": [
"aws-cdk-subscriptionfilter-integ"
],
"assertionStack": "integ-test/DefaultTest/DeployAssert",
"assertionStackName": "integtestDefaultTestDeployAssert24D5C536"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "32.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
"path": "integtestDefaultTestDeployAssert24D5C536.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"version": "32.0.0",
"artifacts": {
"aws-cdk-subscriptionfilter-integ.assets": {
"type": "cdk:asset-manifest",
"properties": {
"file": "aws-cdk-subscriptionfilter-integ.assets.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"aws-cdk-subscriptionfilter-integ": {
"type": "aws:cloudformation:stack",
"environment": "aws://355939527584/us-east-1",
"properties": {
"templateFile": "aws-cdk-subscriptionfilter-integ.template.json",
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::355939527584:role/cdk-hnb659fds-deploy-role-355939527584-us-east-1",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::355939527584:role/cdk-hnb659fds-cfn-exec-role-355939527584-us-east-1",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-355939527584-us-east-1/7db545e495a738edfcd36389d734d374090aa78c8532312439ddb90cfffdc1ef.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
"aws-cdk-subscriptionfilter-integ.assets"
],
"lookupRole": {
"arn": "arn:${AWS::Partition}:iam::355939527584:role/cdk-hnb659fds-lookup-role-355939527584-us-east-1",
"requiresBootstrapStackVersion": 8,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"dependencies": [
"aws-cdk-subscriptionfilter-integ.assets"
],
"metadata": {
"/aws-cdk-subscriptionfilter-integ/LogGroup/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "LogGroupF5B46931"
}
],
"/aws-cdk-subscriptionfilter-integ/LogGroup/Subscription/CanInvokeLambda": [
{
"type": "aws:cdk:logicalId",
"data": "LogGroupSubscriptionCanInvokeLambdaE05AC235"
}
],
"/aws-cdk-subscriptionfilter-integ/LogGroup/Subscription/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "LogGroupSubscriptionE3573E29"
}
],
"/aws-cdk-subscriptionfilter-integ/Function/ServiceRole/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "FunctionServiceRole675BB04A"
}
],
"/aws-cdk-subscriptionfilter-integ/Function/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "Function76856677"
}
],
"/aws-cdk-subscriptionfilter-integ/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "BootstrapVersion"
}
],
"/aws-cdk-subscriptionfilter-integ/CheckBootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
]
},
"displayName": "aws-cdk-subscriptionfilter-integ"
},
"integtestDefaultTestDeployAssert24D5C536.assets": {
"type": "cdk:asset-manifest",
"properties": {
"file": "integtestDefaultTestDeployAssert24D5C536.assets.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"integtestDefaultTestDeployAssert24D5C536": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "integtestDefaultTestDeployAssert24D5C536.template.json",
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
"integtestDefaultTestDeployAssert24D5C536.assets"
],
"lookupRole": {
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
"requiresBootstrapStackVersion": 8,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"dependencies": [
"integtestDefaultTestDeployAssert24D5C536.assets"
],
"metadata": {
"/integ-test/DefaultTest/DeployAssert/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "BootstrapVersion"
}
],
"/integ-test/DefaultTest/DeployAssert/CheckBootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
]
},
"displayName": "integ-test/DefaultTest/DeployAssert"
},
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
}
}
}
Loading

0 comments on commit 7ddb305

Please sign in to comment.