Skip to content

Commit

Permalink
rename log-groups-listener to listener
Browse files Browse the repository at this point in the history
  • Loading branch information
dasfmi committed Jul 18, 2024
1 parent 92572ce commit eabb51c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
yq ".Resources.AxiomCloudWatchForwarder.Properties.Code.ZipFile = \"$(sed 's/\"/\\\"/g' ./forwarder.py)\"" cloudformation-stacks/forwarder.template.yaml > build/axiom-cloudwatch-forwarder-cloudformation-stack.yaml
yq ".Resources.SubscriberLambda.Properties.Code.ZipFile = \"$(sed 's/\"/\\\"/g' ./subscriber.py)\"" cloudformation-stacks/subscriber.template.yaml > build/axiom-cloudwatch-subscriber-cloudformation-stack.yaml
yq ".Resources.SubscriberLambda.Properties.Code.ZipFile = \"$(sed 's/\"/\\\"/g' ./unsubscriber.py)\"" cloudformation-stacks/unsubscriber.template.yaml > build/axiom-cloudwatch-unsubscriber-cloudformation-stack.yaml
yq ".Resources.AxiomCloudWatchLogGroupsListener.Properties.Code.ZipFile = \"$(sed 's/\"/\\\"/g' ./logs_subscriber.py)\"" cloudformation-stacks/log-groups-listener.template.yaml > build/axiom-cloudwatch-log-groups-listener-cloudformation-stack.yaml
yq ".Resources.AxiomCloudWatchLogGroupsListener.Properties.Code.ZipFile = \"$(sed 's/\"/\\\"/g' ./listener.py)\"" cloudformation-stacks/listener.template.yaml > build/axiom-cloudwatch-listener-cloudformation-stack.yaml
- run: cat build/*
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
yq ".Resources.AxiomCloudWatchForwarder.Properties.Code.ZipFile = \"$(sed 's/\"/\\\"/g' ./forwarder.py)\"" cloudformation-stacks/forwarder.template.yaml > build/axiom-cloudwatch-forwarder-v${{ github.ref_name }}-cloudformation-stack.yaml
yq ".Resources.SubscriberLambda.Properties.Code.ZipFile = \"$(sed 's/\"/\\\"/g' ./subscriber.py)\"" cloudformation-stacks/subscriber.template.yaml > build/axiom-cloudwatch-subscriber-v${{ github.ref_name }}-cloudformation-stack.yaml
yq ".Resources.SubscriberLambda.Properties.Code.ZipFile = \"$(sed 's/\"/\\\"/g' ./unsubscriber.py)\"" cloudformation-stacks/unsubscriber.template.yaml > build/axiom-cloudwatch-unsubscriber-v${{ github.ref_name }}-cloudformation-stack.yaml
yq ".Resources.AxiomCloudWatchLogGroupsListener.Properties.Code.ZipFile = \"$(sed 's/\"/\\\"/g' ./logs_subscriber.py)\"" cloudformation-stacks/subscriber.template.yaml > build/axiom-cloudwatch-log-groups-listener-v${{ github.ref_name }}-cloudformation-stack.yaml
yq ".Resources.AxiomCloudWatchLogGroupsListener.Properties.Code.ZipFile = \"$(sed 's/\"/\\\"/g' ./listener.py)\"" cloudformation-stacks/listener.template.yaml > build/axiom-cloudwatch-listener-v${{ github.ref_name }}-cloudformation-stack.yaml
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Axiom CloudWatch Forwarder includes templates for the following CloudFormation s

- Forwarder creates a Lambda function that forwards logs from CloudWatch to Axiom.
- _Subscriber_ runs once to create subscription filters on the _Forwarder_ Lambda for CloudWatch log groups specified by a combination of names, prefix and regular expression.
- LogGroups Listener creates a Lambda function that listens for new log groups and creates subscription filters for them. This way, you don't have to create subscription filters manually for new log groups.
- _Listener_ creates a Lambda function that listens for new log groups and creates subscription filters for them. This way, you don't have to create subscription filters manually for new log groups.

## Guide

Expand All @@ -16,7 +16,7 @@ Axiom CloudWatch Forwarder includes templates for the following CloudFormation s
4. [Click this link to launch the Forwarder Stack](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=axiom-cloudwatch-forwarder&templateURL=https://axiom-cloudformation.s3.amazonaws.com/stacks/axiom-cloudwatch-forwarder-v1.0.0-cloudformation-stack.yaml).
5. Get the created Forwarder lambda ARN from the previous step, and use it to install the Subscriber stack in the next step.
6. [Click this link to open the Subscriber stack template](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=axiom-cloudwatch-subscriber&templateURL=https://axiom-cloudformation.s3.amazonaws.com/stacks/axiom-cloudwatch-subscriber-v1.0.0-cloudformation-stack.yaml).
7. [Click this link to automatically subscribe to new log groups](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=axiom-cloudwatch-log-groups-listener&templateURL=https://axiom-cloudformation.s3.amazonaws.com/stacks/axiom-cloudwatch-log-groups-listener-v1.0.0-cloudformation-stack.yaml).
7. [Click this link to automatically subscribe to new log groups](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=axiom-cloudwatch-listener&templateURL=https://axiom-cloudformation.s3.amazonaws.com/stacks/axiom-cloudwatch-listener-v1.0.0-cloudformation-stack.yaml).


## Removing subscription filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Parameters:
LambdaFunctionName:
Type: String
Description: Name of the AWS Lambda function.
Default: axiom-cloudwatch-log-groups-listener
Default: axiom-cloudwatch-listener
AllowedPattern: ".+" # required
AxiomCloudWatchForwarderLambdaARN:
Type: String
Expand All @@ -25,18 +25,18 @@ Parameters:
Conditions:
ShouldEnableCloudTrail: !Equals [true, !Ref EnableCloudTrail]
Resources:
AxiomCloudWatchLogGroupsListenerS3Bucket:
AxiomCloudWatchListenerS3Bucket:
Condition: ShouldEnableCloudTrail
Type: AWS::S3::Bucket
Properties:
AccessControl: BucketOwnerFullControl
BucketName: !Join ["-", [!Ref AWS::StackName, "cloudtrail"]]
AxiomCloudWatchLogGroupsListenerS3BucketPolicy:
AxiomCloudWatchListenerS3BucketPolicy:
Type: AWS::S3::BucketPolicy
Condition: ShouldEnableCloudTrail
DependsOn: AxiomCloudWatchLogGroupsListenerS3Bucket
DependsOn: AxiomCloudWatchListenerS3Bucket
Properties:
Bucket: !Ref AxiomCloudWatchLogGroupsListenerS3Bucket
Bucket: !Ref AxiomCloudWatchListenerS3Bucket
PolicyDocument:
{
"Version": "2012-10-17",
Expand All @@ -48,7 +48,7 @@ Resources:
"Principal": { "Service": "cloudtrail.amazonaws.com" },
"Action": "s3:GetBucketAcl",
"Resource":
!GetAtt ["AxiomCloudWatchLogGroupsListenerS3Bucket", "Arn"],
!GetAtt ["AxiomCloudWatchListenerS3Bucket", "Arn"],
},
{
"Sid": "AWSCloudTrailWrite20150319",
Expand All @@ -59,7 +59,7 @@ Resources:
!Join [
"",
[
!GetAtt ["AxiomCloudWatchLogGroupsListenerS3Bucket", "Arn"],
!GetAtt ["AxiomCloudWatchListenerS3Bucket", "Arn"],
"/AWSLogs/",
{ "Ref": "AWS::AccountId" },
"/*",
Expand All @@ -73,7 +73,7 @@ Resources:
},
],
}
AxiomLogGroupsListenerCloudTrail:
AxiomCloudWatchListenerCloudTrail:
Type: AWS::CloudTrail::Trail
Condition: ShouldEnableCloudTrail
DependsOn: AxiomCloudWatchLogGroupsListenerS3BucketPolicy
Expand All @@ -82,10 +82,10 @@ Resources:
IncludeGlobalServiceEvents: true
IsMultiRegionTrail: true
IsLogging: true
S3BucketName: !Ref AxiomCloudWatchLogGroupsListenerS3Bucket
S3BucketName: !Ref AxiomCloudWatchListenerS3Bucket
TrailName: !Join ["-", [!Ref AWS::StackName, { "Ref": "AWS::AccountId" }]]
AxiomLogGroupsListenerrEventRule:
DependsOn: AxiomCloudWatchLogGroupsListener
AxiomListenerEventRule:
DependsOn: AxiomCloudWatchListener
Type: AWS::Events::Rule
Properties:
Description: Axiom log group auto subscription event rule.,
Expand All @@ -100,8 +100,8 @@ Resources:
["-", [{ "Ref": "AWS::StackName" }, "auto-subscription-rule"]]
Targets:
- Id: !Join ["-", [!Ref "AWS::StackName", "auto-subscription-rule"]]
Arn: !GetAtt ["AxiomLogGroupsListener", "Arn"]
AxiomLogGroupsListenerrPolicy:
Arn: !GetAtt ["AxiomCloudWatchListener", "Arn"]
AxiomListenerPolicy:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Expand All @@ -120,10 +120,10 @@ Resources:
- logs:GetLogEvents
Effect: Allow
Resource: "*"
PolicyName: axiom-cloudwatch-log-groups-listener-policy
PolicyName: axiom-cloudwatch-listener-policy
Roles:
- !Ref "AxiomCloudWatchLogGroupsListener"
AxiomCloudWatchLogGroupsListenerRole:
- !Ref "AxiomCloudWatchListener"
AxiomCloudWatchListenerRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Expand All @@ -137,10 +137,10 @@ Resources:
- logs.amazonaws.com
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
AxiomCloudWatchLogGroupsListener:
AxiomCloudWatchListener:
Type: AWS::Lambda::Function
DependsOn:
- AxiomCloudWatchLogGroupsListenerRole
- AxiomCloudWatchListenerRole
Properties:
FunctionName: !Ref LambdaFunctionName
Runtime: python3.9
Expand All @@ -150,27 +150,27 @@ Resources:
# DO NOT EDIT
# CI will replace these comments with the code from ./logs_subscriber.py
Role: !GetAtt
- AxiomCloudWatchLogGroupsListenerRole
- AxiomCloudWatchListenerRole
- Arn
Description: Axiom CloudWatch Automatic log groups listener lambda
Environment:
Variables:
AXIOM_CLOUDWATCH_FORWARDER_LAMBDA_ARN: !Ref "AxiomCloudWatchForwarderLambdaARN"
LOG_GROUP_PREFIX: !Ref "CloudWatchLogGroupsPrefix"
AxiomCloudWatchLogGroupsListenerPermission:
AxiomCloudWatchListenerPermission:
Type: AWS::Lambda::Permission
Properties:
Action: "lambda:InvokeFunction"
FunctionName: { "Fn::GetAtt": ["AxiomCloudWatchLogGroupsListener", "Arn"] }
FunctionName: { "Fn::GetAtt": ["AxiomCloudWatchListener", "Arn"] }
Principal: "events.amazonaws.com"
SourceAccount:
Ref: AWS::AccountId
SourceArn: !GetAtt ["AxiomCloudWatchLogGroupsListenerEventRule", "Arn"]
AxiomCloudWatchLogsSubscriberLogGroup:
DependsOn: ["AxiomCloudWatchLogGroupsListenerRole"]
SourceArn: !GetAtt ["AxiomCloudWatchListenerEventRule", "Arn"]
AxiomCloudWatchListenerLogGroup:
DependsOn: ["AxiomCloudWatchListenerRole"]
Type: AWS::Logs::LogGroup
Properties:
LogGroupName:
!Join ["", ["/aws/lambda/", { "Ref": "AxiomCloudWatchLogGroupsListener" }]]
!Join ["", ["/aws/lambda/", { "Ref": "AxiomCloudWatchListener" }]]
RetentionInDays:
Ref: "AxiomLambdaLogRetention"
File renamed without changes.

0 comments on commit eabb51c

Please sign in to comment.