Skip to content

Instantly share code, notes, and snippets.

@spg
Created October 5, 2017 00:34
Show Gist options
  • Save spg/241141c95be4d4d8973120c63d6c0b55 to your computer and use it in GitHub Desktop.
Save spg/241141c95be4d4d8973120c63d6c0b55 to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: '2010-09-09'
Description: Provisions OpsGenie Heartbeats using CloudFormation
Parameters:
OpsGenieHeartbeatApiKey:
Type: String
NoEcho: true
Resources:
HeartbeatLambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
HeartbeatFunction:
Type: AWS::Lambda::Function
Properties:
Role: !GetAtt HeartbeatLambdaExecutionRole.Arn
Description: Lambda function that manages OpsGenie heartbeats
Code: code
Handler: opsgenie_heartbeat.lambda_handler
Runtime: python3.6
Timeout: 15
Environment:
Variables:
OPSGENIE_HEARTBEAT_API_KEY: !Ref OpsGenieHeartbeatApiKey
Heartbeat1:
Type: Custom::OpsGenieHeartbeat
Properties:
ServiceToken: !GetAtt HeartbeatFunction.Arn
Name: Heartbeat1
Interval: 30
IntervalUnit: 'minutes'
Description: 'Our first heartbeat'
Enabled: 'true'
Heartbeat2:
Type: Custom::OpsGenieHeartbeat
Properties:
ServiceToken: !GetAtt HeartbeatFunction.Arn
Name: Heartbeat2
Interval: 4
IntervalUnit: 'hours'
Description: 'Our second heartbeat'
Enabled: 'false'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment