Skip to content

Instantly share code, notes, and snippets.

@rjulian
Last active December 16, 2019 01:37
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 rjulian/173c954b07a20292a4ccad12ccce993f to your computer and use it in GitHub Desktop.
Save rjulian/173c954b07a20292a4ccad12ccce993f to your computer and use it in GitHub Desktop.
Way One: Notify Via Email
AWSTemplateFormatVersion: '2010-09-09'
Description: Creates an event rule that detects CreateVpc and emails an administrator.
Resources:
CreateVPCRule:
Type: AWS::Events::Rule
Properties:
Description: 'Cloudwatch event required to implement this rule.'
Name: 'DetectCreateVpc'
EventPattern:
source:
- aws.ec2
detail-type:
- "AWS API Call via CloudTrail"
detail:
eventSource:
- ec2.amazonaws.com
eventName:
- CreateVpc
State: 'ENABLED'
Targets:
-
Arn: !Ref VpcCreatedTopic
Id: 'VpcCreatedTarget'
VpcCreatedTopic:
Type: AWS::SNS::Topic
Properties:
Subscription:
-
Endpoint: 'administrator@example.com'
Protocol: 'email'
DisplayName: 'VpcCreatedTopic'
TopicName: 'VpcCreatedTopic'
TopicPolicy:
Type: AWS::SNS::TopicPolicy
Properties:
PolicyDocument:
Id: TopicPolicy
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: events.amazonaws.com
Action: sns:Publish
Resource: !Ref VpcCreatedTopic
Topics:
- !Ref VpcCreatedTopic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment