Created
April 29, 2024 15:45
-
-
Save SodaDev/c7fb211ce6d00d656b5e8556ed244e9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: | |
- AWS::LanguageExtensions | |
- AWS::Serverless-2016-10-31 | |
Description: SAM Template for CbEventSourceManager | |
Parameters: | |
Project: | |
Type: String | |
ProjectGroup: | |
Type: String | |
Environment: | |
Type: String | |
TracingName: | |
Type: String | |
CircuitBreakerAlarmArn: | |
Description: Alarm that is base for the circuit breaker | |
Type: String | |
ManagedFunctionArn: | |
Description: SQS Consumer Function ARN | |
Type: String | |
ManagedQueueArn: | |
Description: Consumed SQS ARN | |
Type: String | |
ConsumerClosedConcurrency: | |
Description: Closed concurrency for the consumer | |
Type: Number | |
Mappings: | |
Properties: | |
DEV: | |
loggingLevel: 'debug' | |
SIT: | |
loggingLevel: 'info' | |
UAT: | |
loggingLevel: 'info' | |
OAT: | |
loggingLevel: 'info' | |
PROD: | |
loggingLevel: 'info' | |
Resources: | |
FunctionLogGroup: | |
Type: AWS::Logs::LogGroup | |
Properties: | |
LogGroupName: !Sub | |
- '/aws/lambda/${LambdaName}' | |
- { LambdaName: !Ref CbEventSourceManagerFunction } | |
RetentionInDays: 14 | |
CbEventSourceManagerFunction: | |
# More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction | |
Type: AWS::Serverless::Function | |
Properties: | |
CodeUri: .. | |
Handler: bootstrap | |
Runtime: provided.al2 | |
AutoPublishAlias: live | |
AutoPublishAliasAllProperties: true | |
Architectures: | |
- arm64 | |
Tracing: Active | |
FunctionName: CB-ESM-MANAGER | |
Timeout: 10 | |
MemorySize: 128 | |
Environment: | |
Variables: | |
LOG_LEVEL: !FindInMap [ Properties, !Ref Environment, loggingLevel ] | |
APPLICATION: cb-esm-manager | |
PROJECT: !Ref Project | |
PROJECT_GROUP: !Ref ProjectGroup | |
ATTRIBUTES_PREFIX: cb-esm-manager | |
VERSION: 'N/A' | |
OPENTELEMETRY_COLLECTOR_CONFIG_FILE: | |
!Sub | |
- '{{resolve:ssm:${ConfigLocation}}}' | |
- ConfigLocation: | |
Fn::ImportValue: OTEL::CollectorConfig::S3Location | |
OPENTELEMETRY_EXTENSION_LOG_LEVEL: warn | |
OTEL_SERVICE_NAME: !Ref TracingName | |
FUNCTION_ARN: !Ref ManagedFunctionArn | |
QUEUE_ARN: !Ref ManagedQueueArn | |
CLOSED_CONCURRENCY: !Ref ConsumerClosedConcurrency | |
Events: | |
OpenCircuitRule: | |
Type: EventBridgeRule | |
Properties: | |
Pattern: | |
source: | |
- "aws.cloudwatch" | |
detail-type: | |
- "CloudWatch Alarm State Change" | |
resources: | |
- !Ref CircuitBreakerAlarmArn | |
Layers: | |
- !Sub arn:aws:lambda:${AWS::Region}:184161586896:layer:opentelemetry-collector-arm64-0_5_0:1 | |
Policies: | |
- Fn::ImportValue: OTEL::CollectorConfig::AccessPolicy | |
- Fn::ImportValue: OTEL::CollectorConfig::DisableXRayReportingPolicy | |
- Statement: | |
- Sid: ListEventSourceMappings | |
Effect: Allow | |
Action: | |
- lambda:listEventSourceMappings | |
Resource: "*" | |
- Sid: UpdateEventSourceMapping | |
Effect: Allow | |
Action: | |
- lambda:UpdateEventSourceMapping | |
Resource: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:event-source-mapping:* | |
Tags: | |
Name: CB-ESM-MANAGER | |
Metadata: | |
BuildMethod: makefile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment