Skip to content

Commit

Permalink
Add tags to Forwarder,Sub,Unsub stacks
Browse files Browse the repository at this point in the history
  • Loading branch information
dasfmi committed Jul 22, 2024
1 parent 34d74a5 commit 1bb4fce
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
20 changes: 18 additions & 2 deletions cloudformation-stacks/forwarder.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ Resources:
LogGroupName: !Sub "/aws/axiom/${AWS::StackName}"
RetentionInDays: 1
Tags:
- Key: "Role"
Value: "AxiomCloudWatchForwarder"
- key: "PartOf"
Value: !Ref AWS::StackName
- key: "Platform"
Value: "Axiom"
ForwarderRole:
Type: AWS::IAM::Role
Properties:
Expand All @@ -41,6 +43,13 @@ Resources:
- lambda.amazonaws.com
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
Tags:
- key: "PartOf"
Value: !Ref AWS::StackName
- key: "Role"
Value: "AxiomCloudWatchForwarder"
- key: "Platform"
Value: "Axiom"
ForwarderLambda:
Type: AWS::Lambda::Function
Properties:
Expand All @@ -56,6 +65,13 @@ Resources:
- Arn
LoggingConfig:
LogGroup: !Ref ForwarderLogGroup
Tags:
- key: "PartOf"
Value: !Ref AWS::StackName
- key: "Role"
Value: "AxiomCloudWatchForwarder"
- key: "Platform"
Value: "Axiom"
Environment:
Variables:
AXIOM_TOKEN: !Ref "AxiomToken"
Expand Down
15 changes: 14 additions & 1 deletion cloudformation-stacks/subscriber.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ Resources:
LogGroupName: !Sub "/aws/axiom/${AWS::StackName}"
RetentionInDays: 1
Tags:
- Key: "Role"
- key: "PartOf"
Value: !Ref AWS::StackName
- key: "Platform"
Value: "Axiom"
- key: "Role"
Value: "AxiomCloudWatchSubscriber"
SubscriberRole:
Type: AWS::IAM::Role
Expand Down Expand Up @@ -84,6 +88,15 @@ Resources:
- Arn
LoggingConfig:
LogGroup: !Ref SubscriberLogGroup
Tags:
- key: "PartOf"
Value: !Ref AWS::StackName
- key: "Role"
Value: "AxiomCloudWatchSubscriber"
- key: "Platform"
Value: "Axiom"
- key: "ForwarderARN"
Value: !Ref "AxiomCloudWatchForwarderLambdaARN"
Environment:
Variables:
AXIOM_CLOUDWATCH_FORWARDER_LAMBDA_ARN: !Ref "AxiomCloudWatchForwarderLambdaARN"
Expand Down
13 changes: 12 additions & 1 deletion cloudformation-stacks/unsubscriber.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ Resources:
LogGroupName: !Sub "/aws/axiom/${AWS::StackName}"
RetentionInDays: 1
Tags:
- Key: "Role"
- key: "PartOf"
Value: !Ref AWS::StackName
- key: "Role"
Value: "AxiomCloudWatchUnsubscriber"
- key: "Platform"
Value: "Axiom"
UnsubscriberRole:
Type: AWS::IAM::Role
Properties:
Expand Down Expand Up @@ -84,6 +88,13 @@ Resources:
- Arn
LoggingConfig:
LogGroup: !Ref UnsubscriberLogGroup
Tags:
- key: "PartOf"
Value: !Ref AWS::StackName
- key: "Role"
Value: "AxiomCloudWatchUnsubscriber"
- key: "Platform"
Value: "Axiom"
Environment:
Variables:
AXIOM_CLOUDWATCH_FORWARDER_LAMBDA_ARN: !Ref "AxiomCloudWatchForwarderLambdaARN"
Expand Down
2 changes: 1 addition & 1 deletion subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def lambda_handler(event: dict, context=None):
if group["name"].startswith("/aws/axiom/"):
continue
# create invoke permission for lambda
cleaned_name = '-'.join(group["name"].split("/")[3:])
cleaned_name = "-".join(group["name"].split("/")[3:])
statement_id = f"invoke-permission-for_{cleaned_name}"
# remove permission if exists
try:
Expand Down

0 comments on commit 1bb4fce

Please sign in to comment.