Skip to content

Commit

Permalink
simplify lambda and log group names
Browse files Browse the repository at this point in the history
  • Loading branch information
dasfmi committed Jul 22, 2024
1 parent a706a09 commit 9a308d4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
8 changes: 2 additions & 6 deletions cloudformation-stacks/forwarder.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ Parameters:
DataTags:
Type: String
Description: Tags to be included with the data ingested into Axiom, e.g., <key1>=<value1>,<key2>=<value2>.
ForwarderLambdaName:
Type: String
Description: The name of the Forwarder Lambda function.
Default: "forwarder"
Resources:
ForwarderLogGroup:
Type: "AWS::Logs::LogGroup"
Properties:
LogGroupName: !Sub "/aws/axiom/${AWS::StackName}-${ForwarderLambdaName}"
LogGroupName: !Sub "/aws/axiom/${AWS::StackName}"
RetentionInDays: 1
Tags:
- Key: "Role"
Expand All @@ -48,7 +44,7 @@ Resources:
ForwarderLambda:
Type: AWS::Lambda::Function
Properties:
FunctionName: !Join ["-", [!Ref ForwarderLambdaName, !Ref AWS::StackName]]
FunctionName: !Ref AWS::StackName
Runtime: python3.9
Handler: index.lambda_handler
Code:
Expand Down
8 changes: 2 additions & 6 deletions cloudformation-stacks/subscriber.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ Metadata:
- CloudWatchLogGroupsPattern

Parameters:
LambdaFunctionName:
Type: String
Description: The name of the Subscriber Lambda function.
Default: "subscriber"
AxiomCloudWatchForwarderLambdaARN:
Type: String
Description: The ARN of the Axiom CloudWatch Forwarder Lambda function used to ship logs to Axiom.
Expand Down Expand Up @@ -54,7 +50,7 @@ Resources:
SubscriberLogGroup:
Type: "AWS::Logs::LogGroup"
Properties:
LogGroupName: !Sub "/aws/axiom/${AWS::StackName}-${LambdaFunctionName}"
LogGroupName: !Sub "/aws/axiom/${AWS::StackName}"
RetentionInDays: 1
Tags:
- Key: "Role"
Expand All @@ -75,7 +71,7 @@ Resources:
SubscriberLambda:
Type: AWS::Lambda::Function
Properties:
FunctionName: !Sub "${AWS::StackName}-${LambdaFunctionName}"
FunctionName: !Sub "${AWS::StackName}"
Runtime: python3.9
Handler: index.lambda_handler
Timeout: 300
Expand Down
9 changes: 2 additions & 7 deletions cloudformation-stacks/unsubscriber.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ Metadata:
- CloudWatchLogGroupsPattern

Parameters:
LambdaFunctionName:
Type: String
Description: The name of the Unsubscriber Lambda function.
Default: "unsubscriber"
AxiomCloudWatchForwarderLambdaARN:
Type: String
Description: The ARN of the Axiom CloudWatch Forwarder Lambda function used to forward logs to Axiom.
Expand Down Expand Up @@ -54,8 +50,7 @@ Resources:
UnsubscriberLogGroup:
Type: "AWS::Logs::LogGroup"
Properties:
LogGroupName: !Sub
- "/aws/axiom/${AWS::StackName}-${LambdaFunctionName}"
LogGroupName: !Sub "/aws/axiom/${AWS::StackName}"
RetentionInDays: 1
Tags:
- Key: "Role"
Expand All @@ -76,7 +71,7 @@ Resources:
UnsubscriberLambda:
Type: AWS::Lambda::Function
Properties:
FunctionName: !Sub "${AWS::StackName}-unsubscriber"
FunctionName: !Sub "${AWS::StackName}"
Runtime: python3.9
Handler: index.lambda_handler
Timeout: 300
Expand Down
4 changes: 1 addition & 3 deletions subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ def lambda_handler(event: dict, context=None):
try:
remove_permission(statement_id, axiom_cloudwatch_forwarder_lambda_arn)
except Exception as e:
logger.warning(
f"failed to remove permission for {cleaned_name}: {str(e)}"
)
logger.warning(f"failed to remove permission for {cleaned_name}: {str(e)}")

try:
add_permission(
Expand Down

0 comments on commit 9a308d4

Please sign in to comment.