

 **協助改進此頁面** 

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

若要為本使用者指南貢獻內容，請點選每個頁面右側面板中的**在 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 來限制可以啟動的 Amazon Machine Image (AMI)。為了讓 EKS 自動模式能夠運作，請修改 SCP 以允許從 EKS 自動模式帳戶啟動 AMI。

您也可使用 [EC2 允許的 AMI](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-allowed-amis.html) 功能來限制其他帳戶中 AMI 的可見性。若您使用此功能，必須擴展映像標準，以同時包含感興趣區域中的 EKS 自動模式 AMI 帳戶。

## 僅允許 EKS 自動模式 AMI 而封鎖所有其他 AMI 的範例 SCP
<a name="_example_scp_to_block_all_amis_except_for_eks_auto_mode_amis"></a>

下面的 SCP 會阻止呼叫 `ec2:RunInstances`，除非 AMI 屬於 us-west-2 或 us-east-1 區域的 EKS 自動模式 AMI 帳戶。

**注意**  
請**勿**使用 `ec2:Owner` 內容索引鍵。Amazon 擁有 EKS 自動模式 AMI 帳戶，此索引鍵的值一律為 `amazon`。建構允許啟動 AMIs SCP，如果 `ec2:Owner` `amazon`將允許啟動任何 Amazon 擁有的 AMI，而不只是 EKS Auto Mode 的 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 Auto Mode 公有 AMIs 而異。


|  |  | 
| --- |--- |
|  AWS 區域 | 帳戶 | 
| 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"
            }
        }
    }
```