Skip to content

Instantly share code, notes, and snippets.

@xavier-thomas
Created June 9, 2022 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xavier-thomas/874ad9c7ce5bd442380a04cec80d8f7c to your computer and use it in GitHub Desktop.
Save xavier-thomas/874ad9c7ce5bd442380a04cec80d8f7c to your computer and use it in GitHub Desktop.
Pipeline Monitor Event Rule - CloudFormation
Description: The CloudWatch event rule to publish statuses to the SNS topic
Parameters:
ServiceCodeTag:
Description: The code attached to the service which costs are attributed to
Type: String
ServiceNameTag:
Description: The name of the service which costs are attributed to
Type: String
ServiceOwnerTag:
Description: The owners of the service which costs are attributed to
Type: String
Resources:
PipelineStatusEventRule:
Type: AWS::Events::Rule
Properties:
Description: EventRule
EventPattern:
detail:
state:
- FAILED
- STARTED
- SUCCEEDED
- RESUMED
- CANCELED
- SUPERSEDED
detail-type:
- CodePipeline Pipeline Execution State Change
source:
- aws.codepipeline
Name: !Sub "xt-${AWS::Region}-pipeline-status-event-rule"
State: ENABLED
Targets:
- Arn: !Sub "arn:aws:events:${AWS::Region}:0123456789:event-bus/default"
Id: XtDevEventBus
RoleArn: !GetAtt PipelineStatusEventRuleRole.Arn
PipelineStatusEventRuleRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- events.amazonaws.com
Version: 2012-10-17
Description: The IAM role required for the pipeline status CloudWatch event rule
Path: /
Policies:
- PolicyDocument:
Statement:
- Action:
- events:PutEvents
Effect: Allow
Resource:
- !Sub "arn:aws:events:${AWS::Region}:0123456789:event-bus/default"
Version: 2012-10-17
PolicyName: !Sub "xt-${AWS::Region}-pipeline-status-event-rule-policy"
RoleName: !Sub "xt-${AWS::Region}-pipeline-status-event-rule-role"
Tags:
- Key: ServiceCode
Value: !Ref ServiceCodeTag
- Key: ServiceName
Value: !Ref ServiceNameTag
- Key: ServiceOwner
Value: !Ref ServiceOwnerTag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment