

 **帮助改进此页面** 

要帮助改进本用户指南，请选择位于每个页面右侧窗格中的**在 GitHub 上编辑此页面**链接。

# 更新 EKS 自动模式的组织控制
<a name="auto-controls"></a>

某些组织控制可能会阻止 EKS 自动模式正常运行。如果出现这种情况，则必须更新这些控制，以允许 EKS 自动模式拥有代表您管理 EC2 实例所需的权限。

EKS 自动模式使用服务角色启动支持 EKS 自动模式节点的 EC2 实例。服务角色是在您的账户中创建的 [IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)，服务假定该角色代表您执行操作。[服务控制策略](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html)（SCP）始终适用于使用服务角色执行的操作。这将允许 SCP 禁止自动模式的操作。最常见的情况是使用 SCP 来限制可以启动的亚马逊机器映像（AMI）。要使 EKS 自动模式可以正常工作，请修改 SCP 以允许从 EKS 自动模式账户启动 AMI。

您还可以使用 [EC2 允许的 AMI](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-allowed-amis.html) 功能来限制其他账户中 AMI 的可见性。如果您使用此功能，则必须扩展映像标准，以包含感兴趣区域中的 EKS 自动模式 AMI 账户。

## 示例 SCP：阻止除 EKS 自动模式 AMI 外的所有 AMI
<a name="_example_scp_to_block_all_amis_except_for_eks_auto_mode_amis"></a>

除非 AMI 属于 us-west-2 或 us-east-1 的 EKS 自动模式 AMI 账户，否则以下 SCP 会阻止调用 `ec2:RunInstances`。

**注意**  
切**勿**使用 `ec2:Owner` 上下文键。Amazon 拥有 EKS 自动模式 AMI 账户，该键的值将始终为 `amazon`。如果构建一个 SCP，允许当 `ec2:Owner` 为 `amazon` 时启动 AMI，则将允许启动所有 Amazon 拥有的 AMI，而不仅限于 EKS 自动模式的 AMI。\*

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "DenyAMI",
      "Effect": "Deny",
      "Action": "ec2:RunInstances",
      "Resource": "arn:*:ec2:*::image/ami-*",
      "Condition": {
        "StringNotEquals": {
          "aws:ResourceAccount": [
            "767397842682",
            "992382739861"
          ]
        }
      }
    }
  ]
}
```

## EKS 自动模式 AMI 账户
<a name="_eks_auto_mode_ami_accounts"></a>

 因区域而异的 AWS 账户托管 EKS 自动模式公有 AMI。


|  |  | 
| --- |--- |
|  AWS 区域 | Account | 
| af-south-1 | 471112993317 | 
| ap-east-1 | 590183728416 | 
| ap-east-2 | 381492200852 | 
| ap-northeast-1 | 851725346105 | 
| ap-northeast-2 | 992382805010 | 
| ap-northeast-3 | 891377407544 | 
| ap-south-1 | 975049899075 | 
| ap-south-2 | 590183737426 | 
| ap-southeast-1 | 339712723301 | 
| ap-southeast-2 | 058264376476 | 
| ap-southeast-3 | 471112941769 | 
| ap-southeast-4 | 590183863144 | 
| ap-southeast-5 | 654654202513 | 
| ap-southeast-6 | 905418310314 | 
| ap-southeast-7 | 533267217478 | 
| ca-central-1 | 992382439851 | 
| ca-west-1 | 767397959864 | 
| eu-central-1 | 891376953411 | 
| eu-central-2 | 381492036002 | 
| eu-north-1 | 339712696471 | 
| eu-south-1 | 975049955519 | 
| eu-south-2 | 471112620929 | 
| eu-west-1 | 381492008532 | 
| eu-west-2 | 590184142468 | 
| eu-west-3 | 891376969258 | 
| il-central-1 | 590183797093 | 
| me-central-1 | 637423494195 | 
| me-south-1 | 905418070398 | 
| mx-central-1 | 211125506622 | 
| sa-east-1 | 339712709251 | 
| us-east-1 | 992382739861 | 
| us-east-2 | 975050179949 | 
| us-west-1 | 975050035094 | 
| us-west-2 | 767397842682 | 
| us-gov-east-1 | 446077414359 | 
| us-gov-west-1 | 446098668741 | 

## 关联公有 IP 地址
<a name="_associate_public_ip_address"></a>

调用 `ec2:RunInstances` 时，实例启动的 `AssociatePublicIpAddress` 字段将根据实例启动到的子网类型自动确定。可以使用 SCP 强制将该值显式设置为 false，无论实例启动到哪种类型的子网。在这种情况下，也可以将 NodeClass 字段 `spec.advancedNetworking.associatePublicIPAddress` 设置为 false 以满足 SCP 的要求。

```
  {
        "Sid": "DenyPublicEC2IPAddesses",
        "Effect": "Deny",
        "Action": "ec2:RunInstances",
        "Resource": "arn:aws:ec2:*:*:network-interface/*",
        "Condition": {
            "BoolIfExists": {
                "ec2:AssociatePublicIpAddress": "true"
            }
        }
    }
```