Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
AWSTemplateFormatVersion: 2010-09-09
Description: Use this template to define EventBridge rules, which capture events from
various services, such as CloudWatch and CloudTrail, for use by other services,
such as Lambda.
Resources:
NewAccountCreationRule:
Type: AWS::Events::Rule
Properties:
Description: "Captures CreateAccountResult event generated by Organizations"
EventPattern:
source:
- "aws.organizations"
detail-type:
- "AWS Service Event via CloudTrail"
detail:
eventSource:
- "organizations.amazonaws.com"
eventName:
- "CreateAccountResult"
Name: AccountCreationEvent
State: "ENABLED"
Targets:
- Id: "AccountCreationEventSNSTopic"
Arn: !Ref NewAccountSNSTopic
NewAccountSNSTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: "AccountCreationEvent"
TopicName: "AccountCreationEvent"
NewAccountSNSTopicPolicy:
Type: AWS::SNS::TopicPolicy
Properties:
PolicyDocument:
Id: MyTopicPolicy
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: events.amazonaws.com
Action: sns:Publish
Resource: "*"
Topics:
- !Ref NewAccountSNSTopic
MoveAccountRule:
Type: AWS::Events::Rule
Properties:
Description: "Captures MoveAccount event generated by Organizations"
EventPattern:
source:
- "aws.organizations"
detail-type:
- "AWS API Call via CloudTrail"
detail:
eventSource:
- "organizations.amazonaws.com"
eventName:
- "MoveAccount"
Name: MoveAccountEvent
State: "ENABLED"
Targets:
- Id: "MoveAccountEventSNSTopic"
Arn: !Ref MoveAccountSNSTopic
InputPath: "$.detail"
MoveAccountSNSTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: "MoveAccountEvent"
TopicName: "MoveAccountEvent"
MoveAccountSNSTopicPolicy:
Type: AWS::SNS::TopicPolicy
Properties:
PolicyDocument:
Id: MyTopicPolicy
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: events.amazonaws.com
Action: sns:Publish
Resource: "*"
Topics:
- !Ref MoveAccountSNSTopic
Outputs:
oAccountCreationEventSNSTopicArn:
Description: "AccountCreationEvent SNS Topic Arn"
Value: !Ref NewAccountSNSTopic
Export:
Name: oAccountCreationEventSNSTopicArn
oMoveAccountEventSNSTopicArn:
Description: "MoveAccountEvent SNS Topic Arn"
Value: !Ref MoveAccountSNSTopic
Export:
Name: oMoveAccountEventSNSTopicArn