Sub topic 9
Permissions: resource policies and execution roles
This chapter assumes you know IAM roles and policies, the AWS CLI, JSON, and at least one target service such as Lambda, SQS, or SNS. It covers who is allowed to do what at each hop of an EventBridge flow: publishing events to a bus, delivering events to a target, and sharing a bus with other accounts.
Two directions, two kinds of permission
Every EventBridge flow has an inbound side and an outbound side. Each side is controlled by a different mechanism.
- Inbound: a producer calls
PutEventson a bus. The producer's IAM identity needsevents:PutEventson the bus. If the producer is in another account, the bus also needs a resource-based policy that allows it. - Outbound: a rule matches an event and EventBridge calls a target. EventBridge needs permission to invoke that target. Depending on the target type, this comes either from a resource-based policy on the target or from an IAM execution role that the rule assumes.
Most "my rule matches but nothing happens" problems come from the outbound side. The rule fires, but EventBridge is not allowed to deliver.
Permissions for publishing
A producer in the same account needs an identity-based policy that allows events:PutEvents. Scope the resource to the bus ARN so the producer cannot write to other buses.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "events:PutEvents",
"Resource": "arn:aws:events:us-east-1:123456789012:event-bus/orders-bus"
}
]
}Without this statement, PutEvents fails with an access denied error for the whole call. This differs from a per-entry failure, which appears in FailedEntryCount as covered in the PutEvents chapter.
You can narrow the statement further with condition keys. For example, events:source restricts which Source values a caller may use, so a billing service cannot publish events that claim to come from com.example.orders.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "events:PutEvents",
"Resource": "arn:aws:events:us-east-1:123456789012:event-bus/orders-bus",
"Condition": {
"StringEquals": { "events:source": "com.example.orders" }
}
}
]
}Permissions for delivery: two models
EventBridge delivers to a target in one of two ways. Which one applies depends on the target type.
| Target type | How EventBridge is authorized | What you configure |
|---|---|---|
| Lambda | Resource-based policy on the function | `lambda:InvokeFunction` for principal `events.amazonaws.com` |
| SNS topic | Resource-based policy on the topic | `sns:Publish` for `events.amazonaws.com` |
| SQS queue | Resource-based policy on the queue | `sqs:SendMessage` for `events.amazonaws.com` |
| Step Functions, Kinesis, ECS, API destinations, another bus in a different Region or account | IAM execution role | A role EventBridge assumes, passed as `RoleArn` on the target |
| CloudWatch Logs | Resource-based policy on the log group | Logs resource policy for `events.amazonaws.com` and `delivery.logs.amazonaws.com` |
Check the current EventBridge documentation for your specific target. The pattern is stable, but the list of services grows.
Resource-based policies on the target
For Lambda, SNS, and SQS you grant access on the target itself. The principal is the EventBridge service, events.amazonaws.com. You should always add a condition on the rule ARN. Without it, any EventBridge rule in any account that names your target could invoke it. This is the confused deputy problem.
An SQS queue policy for the order-alerts queue from earlier chapters looks like this:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowHighValueOrdersRule",
"Effect": "Allow",
"Principal": { "Service": "events.amazonaws.com" },
"Action": "sqs:SendMessage",
"Resource": "arn:aws:sqs:us-east-1:123456789012:order-alerts",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "arn:aws:events:us-east-1:123456789012:rule/orders-bus/high-value-orders"
}
}
}
]
}Note the rule ARN format for a custom bus: rule/<bus-name>/<rule-name>. For the default bus, the ARN is rule/<rule-name>. Using the wrong format is a common reason the condition never matches.
For Lambda, the CLI adds the equivalent statement for you:
aws lambda add-permission \
--function-name process-order \
--statement-id AllowHighValueOrdersRule \
--action lambda:InvokeFunction \
--principal events.amazonaws.com \
--source-arn arn:aws:events:us-east-1:123456789012:rule/orders-bus/high-value-ordersWhen you create the rule and target in the console, EventBridge adds this statement automatically. When you use the CLI, CloudFormation without the matching permission resource, or an SDK, you must add it yourself.
If the target queue is encrypted with a customer managed KMS key, the key policy must also allow events.amazonaws.com to use kms:GenerateDataKey and kms:Decrypt. A missing key permission looks like a queue permission failure.
Execution roles
For targets that do not support resource-based policies, EventBridge assumes an IAM role you supply. The role needs two things:
- A trust policy that lets
events.amazonaws.comassume it. - A permissions policy that allows the action on the target.
Trust policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "events.amazonaws.com" },
"Action": "sts:AssumeRole",
"Condition": {
"ArnLike": {
"aws:SourceArn": "arn:aws:events:us-east-1:123456789012:rule/orders-bus/*"
},
"StringEquals": { "aws:SourceAccount": "123456789012" }
}
}
]
}Permissions policy for a Step Functions target:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "states:StartExecution",
"Resource": "arn:aws:states:us-east-1:123456789012:stateMachine:fulfil-order"
}
]
}You then reference the role in the target definition with RoleArn:
[
{
"Id": "fulfil-order-workflow",
"Arn": "arn:aws:states:us-east-1:123456789012:stateMachine:fulfil-order",
"RoleArn": "arn:aws:iam::123456789012:role/eventbridge-start-fulfil-order"
}
]The identity that calls put-targets also needs iam:PassRole on that role. If it lacks the permission, put-targets fails even though the role itself is correct.
Permissions for sharing a bus
By default only principals in the bus's own account can put events on it. To accept events from another account, attach a resource-based policy to the bus with put-permission, or write the policy yourself.
The quick form allows one account:
aws events put-permission \
--event-bus-name orders-bus \
--action events:PutEvents \
--principal 111122223333 \
--statement-id AllowPartnerAccountFor tighter control, write a full policy and apply it with --policy. This version allows one account to publish only events whose source is com.example.orders:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowOrdersFromAccount111122223333",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::111122223333:root" },
"Action": "events:PutEvents",
"Resource": "arn:aws:events:us-east-1:123456789012:event-bus/orders-bus",
"Condition": {
"StringEquals": { "events:source": "com.example.orders" }
}
}
]
}aws events put-permission --event-bus-name orders-bus --policy file://bus-policy.jsonA bus policy opens the door at the bus level. The sending account's principal still needs its own IAM permission for events:PutEvents on your bus ARN. Both sides must allow the call. Cross-account routing is covered in detail in a later chapter.
You can also grant access to an AWS Organization instead of listing accounts. Use the aws:PrincipalOrgID condition with "Principal": "*". Keep that condition in place, because a wildcard principal without it makes the bus public.
Troubleshooting permission failures
Work from the symptom to the layer.
| Symptom | Likely cause | Check |
|---|---|---|
| `PutEvents` returns AccessDenied | Producer lacks `events:PutEvents`, or a `events:source` condition does not match | Producer IAM policy and the `Source` value |
| Cross-account `PutEvents` is denied | Bus policy missing, or sender has no IAM permission | Both the bus policy and the sender's policy |
| Rule matches, target never runs | Missing target resource policy or execution role | `FailedInvocations` metric and the dead-letter queue |
| Lambda target works in console, not CLI | Console added the permission, CLI did not | `aws lambda get-policy` |
| `put-targets` fails with an `iam:PassRole` error | Caller cannot pass the execution role | Caller's IAM policy |
| SQS target silently drops events | Queue policy `aws:SourceArn` does not match the rule ARN | Rule ARN format for custom buses |
A dead-letter queue is useful here. When delivery fails because of permissions, the event goes to the DLQ along with error attributes. The DLQ itself also needs a queue policy that lets events.amazonaws.com send messages, scoped to the rule ARN. A DLQ without that policy fails in the same way as the target it is meant to protect.
Summary of the least-privilege checklist
- Scope producer policies to a specific bus ARN, and add
events:sourcewhere the producer's identity is fixed. - Add
aws:SourceArnconditions to every resource policy that trustsevents.amazonaws.com. - Use one narrowly scoped execution role per target type and purpose, with
aws:SourceArnandaws:SourceAccounton its trust policy. - Give the DLQ its own queue policy.
- Never use a wildcard principal on a bus policy without an organization condition.
Exercise
A rule named high-value-orders on the custom bus orders-bus targets an SQS queue in the same account. Events match the rule, but the queue stays empty and the FailedInvocations metric rises. The queue policy allows sqs:SendMessage for events.amazonaws.com with the condition aws:SourceArn equal to arn:aws:events:us-east-1:123456789012:rule/high-value-orders. What is wrong, and how do you fix it?
Show answer
The rule is on a custom bus, so its ARN includes the bus name: arn:aws:events:us-east-1:123456789012:rule/orders-bus/high-value-orders. The condition names the default-bus format, so it never matches and SQS rejects the delivery. Change the aws:SourceArn value to the custom-bus format. If the queue uses a customer managed KMS key, also confirm the key policy allows events.amazonaws.com.
Exercise
Account 111122223333 needs to publish events to orders-bus in account 123456789012. You added a bus policy that allows events:PutEvents from account 111122223333, but PutEvents is still denied. What else must be true?
Show answer
The principal in account 111122223333 that calls PutEvents also needs an identity-based IAM policy that allows events:PutEvents on the orders-bus ARN. For cross-account access, both the resource policy on the bus and the caller's IAM policy must allow the action.