使用适用于亚马逊的基于身份的政策(IAM 策略) EventBridge - Amazon EventBridge
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用适用于亚马逊的基于身份的政策(IAM 策略) EventBridge

基于身份的策略是附加到 IAM 身份的权限策略。

Amazon 的托管策略 EventBridge

Amazon 通过提供由创建和管理的独立 IAM 策略来解决许多常见用例 Amazon。托管 策略也称为预定义策略,可针对常见使用场景授予必要的权限,让您不必调查需要哪些权限。有关更多信息,请参阅《IAM 用户指南》中的 Amazon 托管式策略

您可以将以下 Amazon 托管策略附加到账户中的用户 EventBridge:

  • AmazonEventBridgeFullAccess— 授予对 EventBridge 管道 EventBridge、 EventBridge 架构和 EventBridge 调度程序的完全访问权限。

  • AmazonEventBridgeReadOnlyAccess— 授予对 EventBridge 管道 EventBridge、 EventBridge 架构和 EventBridge 调度程序的只读访问权限。

AmazonEventBridgeFullAccess 政策

该 AmazonEventBridgeFullAccess 策略授予使用所有 EventBridge 操作的权限以及以下权限:

  • iam:CreateServiceLinkedRole— EventBridge 需要此权限才能在您的账户中为 API 目标创建服务角色。此权限仅授予 IAM 服务在您的账户中专门为 API 目标创建角色的权限。

  • iam:PassRole— EventBridge 需要此权限才能将调用角色传递给 EventBridge 以调用规则的目标。

  • S@@ ecrets Manager 权限 — 当你通过连接资源提供证书来授权 API 目标时, EventBridge需要这些权限才能管理账户中的机密。

以下 JSON 显示了该 AmazonEventBridgeFullAccess 策略。

{ "Version": "2012-10-17", "Statement": [ { "Sid": "EventBridgeActions", "Effect": "Allow", "Action": [ "events:*", "schemas:*", "scheduler:*", "pipes:*" ], "Resource": "*" }, { "Sid": "IAMCreateServiceLinkedRoleForApiDestinations", "Effect": "Allow", "Action": "iam:CreateServiceLinkedRole", "Resource": "arn:aws:iam::*:role/aws-service-role/AmazonEventBridgeApiDestinationsServiceRolePolicy", "Condition": { "StringEquals": { "iam:AWSServiceName": "apidestinations.events.amazonaws.com" } } }, { "Sid": "SecretsManagerAccessForApiDestinations", "Effect": "Allow", "Action": [ "secretsmanager:CreateSecret", "secretsmanager:UpdateSecret", "secretsmanager:DeleteSecret", "secretsmanager:GetSecretValue", "secretsmanager:PutSecretValue" ], "Resource": "arn:aws:secretsmanager:*:*:secret:events!*" }, { "Sid": "IAMPassRoleAccessForEventBridge", "Effect": "Allow", "Action": "iam:PassRole", "Resource": "arn:aws:iam::*:role/*", "Condition": { "StringLike": { "iam:PassedToService": "events.amazonaws.com" } } }, { "Sid": "IAMPassRoleAccessForScheduler", "Effect": "Allow", "Action": "iam:PassRole", "Resource": "arn:aws:iam::*:role/*", "Condition": { "StringLike": { "iam:PassedToService": "scheduler.amazonaws.com" } } }, { "Sid": "IAMPassRoleAccessForPipes", "Effect": "Allow", "Action": "iam:PassRole", "Resource": "arn:aws:iam::*:role/*", "Condition": { "StringLike": { "iam:PassedToService": "pipes.amazonaws.com" } } } ] }
注意

本节中的信息也适用于 CloudWatchEventsFullAccess 策略。但是,强烈建议您使用亚马逊 EventBridge 而不是亚马逊 CloudWatch 活动。

AmazonEventBridgeReadOnlyAccess 政策

该 AmazonEventBridgeReadOnlyAccess 策略授予使用所有读取 EventBridge 操作的权限。

以下 JSON 显示了该 AmazonEventBridgeReadOnlyAccess 策略。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "events:DescribeRule", "events:DescribeEventBus", "events:DescribeEventSource", "events:ListEventBuses", "events:ListEventSources", "events:ListRuleNamesByTarget", "events:ListRules", "events:ListTargetsByRule", "events:TestEventPattern", "events:DescribeArchive", "events:ListArchives", "events:DescribeReplay", "events:ListReplays", "events:DescribeConnection", "events:ListConnections", "events:DescribeApiDestination", "events:ListApiDestinations", "events:DescribeEndpoint", "events:ListEndpoints", "schemas:DescribeCodeBinding", "schemas:DescribeDiscoverer", "schemas:DescribeRegistry", "schemas:DescribeSchema", "schemas:ExportSchema", "schemas:GetCodeBindingSource", "schemas:GetDiscoveredSchema", "schemas:GetResourcePolicy", "schemas:ListDiscoverers", "schemas:ListRegistries", "schemas:ListSchemas", "schemas:ListSchemaVersions", "schemas:ListTagsForResource", "schemas:SearchSchemas", "scheduler:GetSchedule", "scheduler:GetScheduleGroup", "scheduler:ListSchedules", "scheduler:ListScheduleGroups", "scheduler:ListTagsForResource", "pipes:DescribePipe", "pipes:ListPipes", "pipes:ListTagsForResource" ], "Resource": "*" } ] }
注意

本节中的信息也适用于 CloudWatchEventsReadOnlyAccess 策略。但是,强烈建议您使用亚马逊 EventBridge 而不是亚马逊 CloudWatch 活动。

EventBridge 特定于架构的托管策略

架构定义了发送到的事件的结构 EventBridge。 EventBridge 为 Amazon 服务生成的所有事件提供架构。以下特定于 EventBridge 架构的 Amazon 托管策略可用:

EventBridge 日程安排器特定的托管策略

Amazon Sched EventBridge uler 是一种无服务器计划程序,允许您通过一个中央托管服务创建、运行和管理任务。有关特定于日程安排器的 Amazon 托管策略,请参阅《 EventBridge 日程安排器 EventBridge 用户指南》中的日程安排EventBridge 程序Amazon 托管策略

EventBridge 特定于 Pipes 的托管策略

Amazon Pip EventBridge es 将事件源与目标连接起来。在开发事件驱动型架构时,Pipes 可减少对专业知识和集成代码的需求。这有助于确保贵公司应用程序的一致性。以下特定于 Pipes 的 Amazon 托 EventBridge 管策略可用:

用于发送事件的 IAM 角色

要将事件传递给目标, EventBridge 需要一个 IAM 角色。

创建用于向发送事件的 IAM 角色 EventBridge
  1. 通过 https://console.aws.amazon.com/iam/ 打开 IAM 控制台。

  2. 要创建 IAM 角色,请按照 I A M 用户指南中创建向 Amazon 服务委派权限的角色中的步骤操作。在执行这些步骤时,请注意以下操作:

    • 角色名称中,使用账户中的唯一名称。

    • “选择角色类型” 中,选择 “Amazon 服务角色”,然后选择 Amazon EventBridge。这会授予担任该角色的 EventBridge 权限。

    • 附加策略中,选择AmazonEventBridgeFullAccess

您也可以创建自己的自定义 IAM 策略以授予 EventBridge 操作和资源的权限。您可以将这些自定义策略附加到需要这些权限的 IAM 用户或组。有关 IAM 策略的更多信息,请参阅《IAM 用户指南》中的 IAM 策略概述。有关管理和创建自定义 IAM 策略的更多信息,请参阅《IAM 用户指南》中的管理 IAM 策略

使用 IAM 角色 EventBridge 访问目标所需的权限

EventBridge 目标通常需要授予调用目标权限 EventBridge 的 IAM 角色。以下是各种 Amazon 服务和目标的一些示例。对于其他人,请使用 EventBridge 控制台创建规则并创建一个新角色,该角色将使用预先配置了范围明确的权限的策略来创建。

亚马逊 SQS、Amazon SNS、 CloudWatch Lambda EventBridge 、日志和总线目标不使用角色,必须通过资源 EventBridge 策略授予权限。API Gateway 目标可以使用资源策略或 IAM 角色。

如果目标是 API 目标,您指定的角色必须包含以下策略。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "events:InvokeApiDestination" ], "Resource": [ "arn:aws:events:::api-destination/*" ] } ] }

如果目标是 Kinesis 流,则用于将事件数据发送到该目标的角色必须包含以下策略。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "kinesis:PutRecord" ], "Resource": "*" } ] }

如果目标是 Systems Manager Run Command 且您为命令指定了一个或多个 InstanceIds 值,则您指定的角色必须包含以下策略。

{ "Version": "2012-10-17", "Statement": [ { "Action": "ssm:SendCommand", "Effect": "Allow", "Resource": [ "arn:aws:ec2:region:accountId:instance/instanceIds", "arn:aws:ssm:region:*:document/documentName" ] } ] }

如果目标是 Systems Manager Run Command 且您为命令指定了一个或多个标签,则您指定的角色必须包含以下策略。

{ "Version": "2012-10-17", "Statement": [ { "Action": "ssm:SendCommand", "Effect": "Allow", "Resource": [ "arn:aws:ec2:region:accountId:instance/*" ], "Condition": { "StringEquals": { "ec2:ResourceTag/*": [ "[[tagValues]]" ] } } }, { "Action": "ssm:SendCommand", "Effect": "Allow", "Resource": [ "arn:aws:ssm:region:*:document/documentName" ] } ] }

如果目标是 Amazon Step Functions 状态机,则您指定的角色必须包含以下策略。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "states:StartExecution" ], "Resource": [ "arn:aws:states:*:*:stateMachine:*" ] } ] }

如果目标是 Amazon ECS 任务,则您指定的角色必须包含以下策略。

{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": [ "ecs:RunTask" ], "Resource": [ "arn:aws:ecs:*:account-id:task-definition/task-definition-name" ], "Condition": { "ArnLike": { "ecs:cluster": "arn:aws:ecs:*:account-id:cluster/cluster-name" } } }, { "Effect": "Allow", "Action":"iam:PassRole", "Resource": [ "*" ], "Condition": { "StringLike": { "iam:PassedToService": "ecs-tasks.amazonaws.com" } } }] }

以下策略允许中的 EventBridge 内置目标代表您执行 Amazon EC2 操作。您需要使用 Amazon Web Services Management Console 来创建带有内置目标的规则。

{ "Version": "2012-10-17", "Statement": [ { "Sid": "TargetInvocationAccess", "Effect": "Allow", "Action": [ "ec2:Describe*", "ec2:RebootInstances", "ec2:StopInstances", "ec2:TerminateInstances", "ec2:CreateSnapshot" ], "Resource": "*" } ] }

以下政策允许 EventBridge 将事件中继到您账户中的 Kinesis 直播。

{ "Version": "2012-10-17", "Statement": [ { "Sid": "KinesisAccess", "Effect": "Allow", "Action": [ "kinesis:PutRecord" ], "Resource": "*" } ] }

客户管理型策略示例:使用标记来控制对规则的访问权限

以下示例显示了授予 EventBridge 操作权限的用户策略。当您使用 EventBridge API、 Amazon 软件开发工具包或时,此政策将起 Amazon CLI作用。

您可以授予用户访问特定 EventBridge 规则的权限,同时阻止他们访问其他规则。要实现此目标,请标记这两组规则,并使用 IAM 策略引用这些标签。有关为 EventBridge 资源添加标签的更多信息,请参阅亚马逊 EventBridge 标签

您可以向用户授予 IAM 策略,仅允许其访问带有特定标签的规则。您可以用这个特定标签来标记所选规则,为它们授予访问权限。例如,以下策略仅向某用户授予对标签键 Stack 值为 Prod 的规则的访问权限。

{ "Statement": [ { "Effect": "Allow", "Action": "events:*", "Resource": "*", "Condition": { "StringEquals": { "aws:ResourceTag/Stack": "Prod" } } } ] }

有关使用 IAM policy 语句的更多信息,请参阅 IAM 用户指南中的使用策略控制访问

亚马逊 EventBridge 更新了托 Amazon 管政策

查看 EventBridge 自该服务开始跟踪这些更改以来 Amazon 托管策略更新的详细信息。要获得有关此页面更改的自动提醒,请订阅 “ EventBridge 文档历史记录” 页面上的 RSS feed。

更改 描述 日期

AmazonEventBridgeFullAccess - 更新的策略

Amazon GovCloud (US) Regions 只有

不包括以下权限,因为未使用该权限:

  • iam:CreateServiceLinkedRole EventBridge 架构注册表的权限

2024 年 5 月 9 日

AmazonEventBridgeSchemasFullAccess - 更新的策略

Amazon GovCloud (US) Regions 只有

不包括以下权限,因为未使用该权限:

  • iam:CreateServiceLinkedRole EventBridge 架构注册表的权限

2024 年 5 月 9 日

AmazonEventBridgePipesFullAccess— 添加了新政策

EventBridge 为使用 Pipes 的全部权限添加了托 EventBridge 管策略。

2022 年 12 月 1 日

AmazonEventBridgePipesReadOnlyAccess— 添加了新政策

EventBridge 为查看 Pipes 信息资源的权限添加了托 EventBridge 管策略。

2022 年 12 月 1 日

AmazonEventBridgePipesOperatorAccess— 添加了新政策

EventBridge 为查看 EventBridge 管道信息以及启动和停止运行管道的权限添加了托管策略。

2022 年 12 月 1 日

AmazonEventBridgeFullAccess – 更新了现有策略

EventBridge 更新了政策,增加了使用 Pip EventBridge es 功能所需的权限。

2022 年 12 月 1 日

AmazonEventBridgeReadOnlyAccess – 更新了现有策略

EventBridge 添加了查看 Pip EventBridge es 信息资源所需的权限。

添加了以下操作:

  • pipes:DescribePipe

  • pipes:ListPipes

  • pipes:ListTagsForResource

2022 年 12 月 1 日

CloudWatchEventsReadOnlyAccess – 更新了现有策略

已更新以匹配 AmazonEventBridgeReadOnlyAccess。

2022 年 12 月 1 日

CloudWatchEventsFullAccess – 更新了现有策略

已更新以匹配 AmazonEventBridgeFullAccess。

2022 年 12 月 1 日

AmazonEventBridgeFullAccess – 更新了现有策略

EventBridge 更新了策略,增加了使用架构和计划程序功能所需的权限。

添加了以下权限:

  • EventBridge 架构注册表操作

  • EventBridge 调度器操作

  • iam:CreateServiceLinkedRole EventBridge 架构注册表的权限

  • iam:PassRole EventBridge 日程安排器的权限

2022 年 11 月 10 日

AmazonEventBridgeReadOnlyAccess – 更新了现有策略

EventBridge 添加了查看架构和调度程序信息资源所需的权限。

添加了以下操作:

  • schemas:DescribeCodeBinding

  • schemas:DescribeDiscoverer

  • schemas:DescribeRegistry

  • schemas:DescribeSchema

  • schemas:ExportSchema

  • schemas:GetCodeBindingSource

  • schemas:GetDiscoveredSchema

  • schemas:GetResourcePolicy

  • schemas:ListDiscoverers

  • schemas:ListRegistries

  • schemas:ListSchemas

  • schemas:ListSchemaVersions

  • schemas:ListTagsForResource

  • schemas:SearchSchemas

  • scheduler:GetSchedule

  • scheduler:GetScheduleGroup

  • scheduler:ListSchedules

  • scheduler:ListScheduleGroups

  • scheduler:ListTagsForResource

2022 年 11 月 10 日

AmazonEventBridgeReadOnlyAccess – 更新了现有策略

EventBridge 添加了查看端点信息所需的权限。

添加了以下操作:

  • events:ListEndpoints

  • events:DescribeEndpoint

2022 年 4 月 7 日

AmazonEventBridgeReadOnlyAccess – 更新了现有策略

EventBridge 添加了查看连接和 API 目标信息所需的权限。

添加了以下操作:

  • events:DescribeConnection

  • events:ListConnections

  • events:DescribeApiDestination

  • events:ListApiDestinations

2021 年 3 月 4 日

AmazonEventBridgeFullAccess – 更新了现有策略

EventBridge 更新了政策,以包含使用 API 目标所需的 Amazon Secrets Manager 权限iam:CreateServiceLinkedRole和权限。

添加了以下操作:

  • secretsmanager:CreateSecret

  • secretsmanager:UpdateSecret

  • secretsmanager:DeleteSecret

  • secretsmanager:GetSecretValue

  • secretsmanager:PutSecretValue

2021 年 3 月 4 日

EventBridge 开始跟踪更改

EventBridge 开始跟踪其 Amazon 托管策略的更改。

2021 年 3 月 4 日