

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

# Amazon EventBridge 架构的基于资源的政策
<a name="eb-resource-based-schemas"></a>

 EventBridge [架构注册表](eb-schema-registry.md)支持[基于资源的策略](eb-use-resource-based.md)。*基于资源的策略*是附加到资源而不是 IAM 身份的策略。例如，在 Amazon Simple Storage Service (Amazon S3) 中，资源策略附加到 Amazon S3 桶。

有关 EventBridge 架构和基于资源的策略的更多信息，请参阅以下内容。
+ [亚马逊 EventBridge 架构 REST API 参考](https://docs.aws.amazon.com/eventbridge/latest/schema-reference/what-is-eventbridge-schemas.html)
+ 《IAM 用户指南》中的[基于身份的策略和基于资源的策略](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_identity-vs-resource.html)。

## APIs 支持基于资源的策略
<a name="eb-resource-supported-apis"></a>

您可以将以下内容 APIs 与 EventBridge 架构注册表的基于资源的策略一起使用。
+ `DescribeRegistry`
+ `UpdateRegistry`
+ `DeleteRegistry`
+ `ListSchemas`
+ `SearchSchemas`
+ `DescribeSchema`
+ `CreateSchema`
+ `DeleteSchema`
+ `UpdateSchema`
+ `ListSchemaVersions`
+ `DeleteSchemaVersion`
+ `DescribeCodeBinding`
+ `GetCodeBindingSource`
+ `PutCodeBinding`

## 向 AWS 账户授予所有支持的操作的策略示例
<a name="eb-resource-policy-account-all"></a>

对于 EventBridge 架构注册表，必须始终将基于资源的策略附加到注册表。要对架构授予访问权限，请在策略中指定架构 ARN 和注册表 ARN。

要向用户授予对所有可用 EventBridge 架构 APIs 的访问权限，请使用类似于以下内容的策略，将替换为您要授予访问权限的账户的账户 ID。`"Principal"`

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "Test",
            "Effect": "Allow",
            "Action": [
                "schemas:*"
            ],
            "Principal": {
                "AWS": [
                    "109876543210" 
                ]
            },
            "Resource": [
                "arn:aws:schemas:us-east-1:012345678901:registry/default",
                "arn:aws:schemas:us-east-1:012345678901:schema/default*"
            ]
        }
    ]
}
```

------

## 向 AWS 账户授予只读操作的策略示例
<a name="eb-resource-policy-account-read"></a>

以下示例仅向 EventBridge架构的只读 APIs 账户授予访问权限。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "Test",
            "Effect": "Allow",
            "Action": [
                "schemas:DescribeRegistry",
                "schemas:ListSchemas",
                "schemas:SearchSchemas",
                "schemas:DescribeSchema",
                "schemas:ListSchemaVersions",
                "schemas:DescribeCodeBinding",
                "schemas:GetCodeBindingSource"
            ],
            "Principal": {
                "AWS": [
                    "109876543210"
                ]
            },
            "Resource": [
                "arn:aws:schemas:us-east-1:012345678901:registry/default",
                "arn:aws:schemas:us-east-1:012345678901:schema/default*"
            ]
        }
    ]
}
```

------

## 向组织授予所有操作权限的策略示例
<a name="eb-resource-policy-org"></a>

您可以将基于资源的策略与 EventBridge 架构注册表一起使用，向组织授予访问权限。有关更多信息，请参阅 [AWS Organizations 《用户指南》](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html)。以下示例向 ID 为 `o-a1b2c3d4e5` 的组织授予对架构注册表的访问权限。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "Test",
            "Effect": "Allow",
            "Action": [
                "schemas:*"
            ],
            "Principal": "*",
            "Resource": [
                "arn:aws:schemas:us-east-1:012345678901:registry/default",
                "arn:aws:schemas:us-east-1:012345678901:schema/default*"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:PrincipalOrgID": [
                        "o-a1b2c3d4e5"
                    ]
                }
            }
        }
    ]
}
```

------