

終止支援通知：將於 2026 年 10 月 7 日 AWS 結束對 的支援 AWS Proton。2026 年 10 月 7 日之後，您將無法再存取 AWS Proton 主控台或 AWS Proton 資源。您部署的基礎設施將保持不變。如需詳細資訊，請參閱[AWS Proton 服務棄用和遷移指南](https://docs.aws.amazon.com/proton/latest/userguide/proton-end-of-support.html)。

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

# AWS Proton IAM 服務角色政策範例
<a name="security_iam_service-role-policy-examples"></a>

管理員擁有和管理由環境和服務範本定義的 AWS Proton 建立的資源。他們會將 IAM 服務角色連接到其帳戶， AWS Proton 以允許 代表他們建立資源。當 將他們的應用程式部署為 AWS Proton 環境中 AWS Proton 的服務時，管理員會為開發人員稍後擁有和管理的資源提供 IAM AWS Proton 角色和 AWS Key Management Service 金鑰。如需 AWS KMS 和 資料加密的詳細資訊，請參閱 [中的資料保護 AWS Proton](data-protection.md)。

服務角色是 Amazon Web Services (IAM) 角色， AWS Proton 允許 代表您呼叫 資源。如果您指定服務角色， AWS Proton 就會使用角色的憑證。使用服務角色明確指定 AWS Proton 可執行的動作。

您使用 IAM 服務建立服務角色及其許可政策。如需建立服務角色的詳細資訊，請參閱《*IAM 使用者指南*》中的[建立角色以委派許可給 AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html)。

## AWS Proton 使用 佈建的 服務角色 CloudFormation
<a name="proton-svc-role"></a>

身為平台團隊的成員，您可以在建立環境做為環境的 CloudFormation 服務角色 ([CreateEnvironment](https://docs.aws.amazon.com/proton/latest/APIReference/API_CreateEnvironment.html) API 動作的 `protonServiceRoleArn` 參數） AWS Proton 時，以管理員身分建立 AWS Proton 服務角色並將其提供給 。當環境或其中執行的任何服務執行個體使用受管佈建和 AWS CloudFormation 佈建基礎設施時，此角色允許 代表您對其他服務 AWS Proton 進行 API AWS呼叫。

建議您針對 AWS Proton 服務角色使用下列 IAM 角色和信任政策。當您使用 AWS Proton 主控台建立環境並選擇建立新角色時，這是 AWS Proton 新增至其為您建立之服務角色的政策。縮小此政策的許可範圍時，請記住 會在`Access Denied`發生錯誤時 AWS Proton 失敗。

**重要**  
請注意，下列範例中顯示的政策會將管理員權限授予任何可以向您的帳戶註冊範本的人。由於我們不知道您會在 AWS Proton 範本中定義哪些資源，因此這些政策具有廣泛的許可。我們建議您將許可範圍縮小為將部署在您的環境中的特定資源。

### AWS Proton 的服務角色政策範例 CloudFormation
<a name="proton-svc-role.details"></a>

`{{123456789012}}` 以您的 AWS 帳戶 ID 取代 。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "cloudformation:CancelUpdateStack",
        "cloudformation:ContinueUpdateRollback",
        "cloudformation:CreateChangeSet",
        "cloudformation:CreateStack",
        "cloudformation:DeleteChangeSet",
        "cloudformation:DeleteStack",
        "cloudformation:DescribeChangeSet",
        "cloudformation:DescribeStackDriftDetectionStatus",
        "cloudformation:DescribeStackEvents",
        "cloudformation:DescribeStackResourceDrifts",
        "cloudformation:DescribeStacks",
        "cloudformation:DetectStackResourceDrift",
        "cloudformation:ExecuteChangeSet",
        "cloudformation:ListChangeSets",
        "cloudformation:ListStackResources",
        "cloudformation:UpdateStack"
      ],
      "Resource": "arn:aws:cloudformation:*:{{123456789012}}:stack/AWSProton-*"
    },
    {
      "Effect": "Allow",
      "NotAction": [
        "organizations:*",
        "account:*"
      ],
      "Resource": "*",
      "Condition": {
        "ForAnyValue:StringEquals": {
          "aws:CalledVia": [
            "cloudformation.amazonaws.com"
          ]
        }
      }
    },
    {
      "Effect": "Allow",
      "Action": [
        "organizations:DescribeOrganization",
        "account:ListRegions"
      ],
      "Resource": "*",
      "Condition": {
        "ForAnyValue:StringEquals": {
          "aws:CalledVia": [
            "cloudformation.amazonaws.com"
          ]
        }
      }
    }
  ]
}
```

------

### AWS Proton 服務信任政策
<a name="proton-svc-role.trust.details"></a>

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Sid": "ServiceTrustRelationshipWithConfusedDeputyPrevention",
    "Effect": "Allow",
    "Principal": {
      "Service": "proton.amazonaws.com"
    },
    "Action": "sts:AssumeRole",
    "Condition": {
      "StringEquals": {
        "aws:SourceAccount": "{{123456789012}}"
      },
      "ArnLike": {
        "aws:SourceArn": "arn:aws:proton:*:{{123456789012}}:environment/*"
      }
    }
  }
}
```

------

### 範圍下 AWS管佈建服務角色政策
<a name="proton-svc-role.scoped-down.details"></a>

以下是範圍縮小 AWS Proton 服務角色政策的範例，如果您只需要 AWS Proton 服務來佈建 S3 資源，您可以使用該政策。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "cloudformation:CancelUpdateStack",
        "cloudformation:ContinueUpdateRollback",
        "cloudformation:CreateChangeSet",
        "cloudformation:CreateStack",
        "cloudformation:DeleteChangeSet",
        "cloudformation:DeleteStack",
        "cloudformation:DescribeChangeSet",
        "cloudformation:DescribeStackDriftDetectionStatus",
        "cloudformation:DescribeStackEvents",
        "cloudformation:DescribeStackResourceDrifts",
        "cloudformation:DescribeStacks",
        "cloudformation:DetectStackResourceDrift",
        "cloudformation:ExecuteChangeSet",
        "cloudformation:ListChangeSets",
        "cloudformation:ListStackResources",
        "cloudformation:UpdateStack"
      ],
      "Resource": "arn:aws:cloudformation:*:{{123456789012}}:stack/AWSProton-*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3:*"
      ],
      "Resource": "*",
      "Condition": {
        "ForAnyValue:StringEquals": {
          "aws:CalledVia": [
            "cloudformation.amazonaws.com"
          ]
        }
      }
    }
  ]
}
```

------

## AWS Proton CodeBuild 佈建的服務角色
<a name="codebuild-proton-svc-role"></a>

身為平台團隊的成員，您可以在建立環境做為環境的 CodeBuild AWS Proton 服務角色 ([CreateEnvironment](https://docs.aws.amazon.com/proton/latest/APIReference/API_CreateEnvironment.html) API 動作的 `codebuildRoleArn` 參數） AWS Proton 時，以管理員身分建立服務角色並將其提供給 。當環境或其中執行的任何服務執行個體使用 CodeBuild 佈建來佈建基礎設施時，此角色允許 代表您對其他服務 AWS Proton 進行 API 呼叫。

當您使用 AWS Proton 主控台建立環境並選擇建立新角色時， 會將具有管理員權限的政策 AWS Proton 新增至其為您建立的服務角色。當您建立自己的角色和縮小範圍許可時，請記住 會在`Access Denied`發生錯誤時 AWS Proton 失敗。

**重要**  
請注意， AWS Proton 連接到其為您建立的角色的政策會將管理員權限授予任何可以向您的帳戶註冊範本的人。由於我們不知道您會在 AWS Proton 範本中定義哪些資源，因此這些政策具有廣泛的許可。我們建議您將許可範圍縮小為將部署在您的環境中的特定資源。

### AWS Proton CodeBuild 的服務角色政策範例
<a name="codebuild-proton-svc-role.details"></a>

下列範例提供 CodeBuild 使用 佈建資源的許可 AWS Cloud Development Kit (AWS CDK)。

`{{123456789012}}` 以您的 AWS 帳戶 ID 取代 。

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

****  

```
 {
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Action": [
        "logs:CreateLogStream",
        "logs:CreateLogGroup",
        "logs:PutLogEvents"
      ],
      "Resource": [
        "arn:aws:logs:{{us-east-1}}:{{123456789012}}:log-group:/aws/codebuild/AWSProton-   Shell-*",
        "arn:aws:logs:{{us-east-1}}:{{123456789012}}:log-group:/aws/codebuild/AWSProton-   Shell-*:*"
      ],
      "Effect": "Allow"
    },
    {
      "Action": "proton:NotifyResourceDeploymentStatusChange",
      "Resource": "arn:aws:proton:{{us-east-1}}:{{123456789012}}:*",
      "Effect": "Allow"
    },
    {
      "Action": "sts:AssumeRole",
      "Resource": [
        "arn:aws:iam::{{123456789012}}:role/cdk-*-deploy-role-*",
        "arn:aws:iam::{{123456789012}}:role/cdk-*-file-publishing-role-*"
      ],
      "Effect": "Allow"
    }
  ]
}
```

------

### AWS Proton CodeBuild 信任政策
<a name="codebuild-proton-svc-role.trust.details"></a>

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Sid": "CodeBuildTrustRelationshipWithConfusedDeputyPrevention",
    "Effect": "Allow",
    "Principal": {
      "Service": "codebuild.amazonaws.com"
    },
    "Action": "sts:AssumeRole",
    "Condition": {
      "StringEquals": {
        "aws:SourceAccount": "{{123456789012}}"
      },
      "ArnLike": {
        "aws:SourceArn": "arn:aws:proton:*:{{123456789012}}:environment/*"
      }
    }
  }
}
```

------

## AWS Proton 管道服務角色
<a name="codepipeline-proton-svc-role"></a>

若要佈建服務管道， AWS Proton 需要對其他 服務進行 API 呼叫的許可。所需的服務角色類似於您在建立環境時提供的服務角色。不過，建立管道的角色會在您 AWS 帳戶中的所有服務之間共用，而且您可以在 主控台中或透過 [UpdateAccountSettings](https://docs.aws.amazon.com/proton/latest/APIReference/API_UpdateAccountSettings.html) API 動作提供這些角色做為**帳戶設定**。

當您使用 AWS Proton 主控台更新帳戶設定，並選擇為 CloudFormation 或 CodeBuild 服務角色建立新角色時， AWS Proton 新增至其為您建立之服務角色的政策會與先前章節中所述的政策相同，[AWS受管佈建角色](#proton-svc-role)以及 [CodeBuild 佈建角色](#codebuild-proton-svc-role)。縮小此政策的許可範圍時，請記住 會在`Access Denied`發生錯誤時 AWS Proton 失敗。

**重要**  
請注意，前幾節中的範例政策會將管理員權限授予任何可以向您的帳戶註冊範本的人。由於我們不知道您會在 AWS Proton 範本中定義哪些資源，因此這些政策具有廣泛的許可。建議您將許可範圍縮小為將在管道中部署的特定資源。

## AWS Proton 元件角色
<a name="proton-custom-comp-role"></a>

身為平台團隊的成員，您可以在建立環境做為環境的 CloudFormation 元件角色 ([CreateEnvironment](https://docs.aws.amazon.com/proton/latest/APIReference/API_CreateEnvironment.html) API 動作的 `componentRoleArn` 參數） AWS Proton 時，以管理員身分建立 AWS Proton 服務角色並將其提供給 。此角色會縮小直接定義元件可以佈建的基礎設施範圍。如需元件的詳細資訊，請參閱 [AWS Proton 元件](ag-components.md)。

下列範例政策支援建立直接定義的元件，以佈建 Amazon Simple Storage Service (Amazon S3) 儲存貯體和相關的存取政策。

### AWS Proton 元件角色政策範例
<a name="proton-custom-comp-role.details"></a>

`{{123456789012}}` 以您的 AWS 帳戶 ID 取代 。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "cloudformation:CancelUpdateStack",
        "cloudformation:CreateChangeSet",
        "cloudformation:DeleteChangeSet",
        "cloudformation:DescribeStacks",
        "cloudformation:ContinueUpdateRollback",
        "cloudformation:DetectStackResourceDrift",
        "cloudformation:DescribeStackResourceDrifts",
        "cloudformation:DescribeStackEvents",
        "cloudformation:CreateStack",
        "cloudformation:DeleteStack",
        "cloudformation:UpdateStack",
        "cloudformation:DescribeChangeSet",
        "cloudformation:ExecuteChangeSet",
        "cloudformation:ListChangeSets",
        "cloudformation:ListStackResources"
      ],
      "Resource": "arn:aws:cloudformation:*:{{123456789012}}:stack/AWSProton-*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3:CreateBucket",
        "s3:DeleteBucket",
        "s3:GetBucket*",
        "iam:CreatePolicy",
        "iam:DeletePolicy",
        "iam:GetPolicy",
        "iam:ListPolicyVersions",
        "iam:DeletePolicyVersion"
      ],
      "Resource": "*",
      "Condition": {
        "ForAnyValue:StringEquals": {
          "aws:CalledVia": "cloudformation.amazonaws.com"
        }
      }
    }
  ]
}
```

------

### AWS Proton 元件信任政策
<a name="proton-custom-comp-role.trust.details"></a>

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Sid": "ServiceTrustRelationshipWithConfusedDeputyPrevention",
    "Effect": "Allow",
    "Principal": {
      "Service": "proton.amazonaws.com"
    },
    "Action": "sts:AssumeRole",
    "Condition": {
      "StringEquals": {
        "aws:SourceAccount": "{{123456789012}}"
      },
      "ArnLike": {
        "aws:SourceArn": "arn:aws:proton:*:{{123456789012}}:environment/*"
      }
    }
  }
}
```

------