This is the new Amazon CloudFormation Template Reference Guide. Please update your bookmarks and links. For help getting started with CloudFormation, see the Amazon CloudFormation User Guide.
AWS::Events::EventBusPolicy
Running PutPermission permits the specified Amazon account or Amazon organization
to put events to the specified event bus. Amazon EventBridge rules in your account are triggered by these events arriving to an event bus in your
account.
For another account to send events to your account, that external account must have an EventBridge rule with your account's event bus as a target.
To enable multiple Amazon accounts to put events to your event bus, run
PutPermission once for each of these accounts. Or, if all the accounts are
members of the same Amazon organization, you can run PutPermission
once specifying Principal as "*" and specifying the Amazon
organization ID in Condition, to grant permissions to all accounts in that
organization.
If you grant permissions using an organization, then accounts in that organization must
specify a RoleArn with proper permissions when they use PutTarget to
add your account's event bus as a target. For more information, see Sending and
Receiving Events Between Amazon Accounts in the Amazon EventBridge User Guide.
The permission policy on the event bus cannot exceed 10 KB in size.
Syntax
To declare this entity in your Amazon CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::Events::EventBusPolicy", "Properties" : { "EventBusName" :String, "Statement" :Json, "StatementId" :String} }
YAML
Type: AWS::Events::EventBusPolicy Properties: EventBusName:StringStatement:JsonStatementId:String
Properties
EventBusName-
The name of the event bus associated with the rule. If you omit this, the default event bus is used.
Required: No
Type: String
Pattern:
[\.\-_A-Za-z0-9]+Minimum:
1Maximum:
256Update requires: Replacement
Statement-
A JSON string that describes the permission policy statement. You can include a
Policyparameter in the request instead of using theStatementId,Action,Principal, orConditionparameters.Required: No
Type: Json
Update requires: No interruption
StatementId-
An identifier string for the external account that you are granting permissions to. If you later want to revoke the permission for this external account, specify this
StatementIdwhen you run RemovePermission.Note
Each
StatementIdmust be unique.Required: Yes
Type: String
Pattern:
[a-zA-Z0-9-_]+Minimum:
1Maximum:
64Update requires: Replacement
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the event bus policy ID, such as
EventBusPolicy-1aBCdeFGh2J3.
For more information about using the Ref function, see Ref.
Examples
Grant Permission to One Account
The following example grants permission to one Amazon account with an account ID of
111122223333.
JSON
"SampleEventBusPolicy": { "Type": "AWS::Events::EventBusPolicy", "Properties": { "StatementId": "MyStatement", "Statement": { "Effect": "Allow", "Principal" : {"AWS" : "arn:aws:iam::111122223333:root"}, "Action": "events:PutEvents", "Resource": "arn:aws:events:us-east-1:111122223333:event-bus/default" } } }
YAML
SampleEventBusPolicy: Type: AWS::Events::EventBusPolicy Properties: StatementId: "MyStatement" Statement: Effect: "Allow" Principal: AWS: "arn:aws:iam::111122223333:root" Action: "events:PutEvents" Resource: "arn:aws:events:us-east-1:111122223333:event-bus/default"
Grant Permission to an Organization
The following example grants permission to all Amazon accounts in the organization with
an organization ID of o-1234567890.
JSON
"SampleEventBusPolicy": { "Type": "AWS::Events::EventBusPolicy", "Properties": { "StatementId": "MyStatement", "Statement": { "Effect": "Allow", "Principal" : "*", "Action": "events:PutEvents", "Resource": "arn:aws:events:us-east-1:111122223333:event-bus/default", "Condition": { "StringEquals": {"aws:PrincipalOrgID": "o-1234567890"} } } } }
YAML
SampleEventBusPolicy: Type: AWS::Events::EventBusPolicy Properties: StatementId: "MyStatement" Statement: Effect: "Allow" Principal: "*" Action: "events:PutEvents" Resource: "arn:aws:events:us-east-1:111122223333:event-bus/default" Condition: StringEquals: "aws:PrincipalOrgID": "o-1234567890"
Deny policy using multiple principals and actions
The following example demonstrates a deny policy statement using multiple principals and actions.
JSON
"SampleDenyEventBusPolicy": { "Type": "AWS::Events::EventBusPolicy", "Properties": { "StatementId": "MyDenyStatement", "Statement": { "Effect": "Deny", "Principal" : {"AWS" : ["arn:aws:iam::111122223333:user/alice", "arn:aws:iam::111122223333:user/bob"]}, "Action": [ "events:PutEvents", "events:PutRule" ], "Resource": "arn:aws:events:us-east-1:111122223333:event-bus/default" } } }
YAML
SampleDenyEventBusPolicy: Type: AWS::Events::EventBusPolicy Properties: StatementId: "MyDenyStatement" Statement: Effect: "Deny" Principal: AWS: - "arn:aws:iam::111122223333:user/alice" - "arn:aws:iam::111122223333:user/bob" Action: - "events:PutEvents" - "events:PutRule" Resource: "arn:aws:events:us-east-1:111122223333:event-bus/default"
Grant Permission to an Organization using a custom event bus
The following example grants permission to all Amazon accounts in the organization with an organization ID of o-1234567890 using a custom event bus.
JSON
"SampleCustomEventBus": { "Type": "AWS::Events::EventBus", "Properties": { "Name": "MyCustomEventBus" } }, "SampleCustomEventBusPolicy": { "Type": "AWS::Events::EventBusPolicy", "Properties": { "EventBusName": { "Ref": "SampleCustomEventBus" }, "StatementId": "MyCustomEventBusStatement", "Statement": { "Effect": "Allow", "Principal" : "*", "Action": "events:PutEvents", "Resource": { "Fn::GetAtt": [ "SampleCustomEventBus", "Arn" ] }, "Condition": { "StringEquals": {"aws:PrincipalOrgID": "o-1234567890"} } } } }
YAML
SampleCustomEventBus: Type: AWS::Events::EventBus Properties: Name: "MyCustomEventBus" SampleCustomEventBusPolicy: Type: AWS::Events::EventBusPolicy Properties: EventBusName: Ref: "SampleCustomEventBus" StatementId: "MyCustomEventBusStatement" Statement: Effect: "Allow" Principal: "*" Action: "events:PutEvents" Resource: !GetAtt "SampleCustomEventBus.Arn" Condition: StringEquals: "aws:PrincipalOrgID": "o-1234567890"