AWS ProtonIAM 服務角色政策範例 - AWS Proton

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

AWS ProtonIAM 服務角色政策範例

系統管理員擁有並管理由環境和服務範本所定義AWS Proton建立的資源。他們會將 IAM 服務角色附加AWS Proton到允許代表其建立資源的帳戶。管理員提供 IAM 角色和AWS Key Management Service金鑰,這些資源在AWS Proton環境中AWS Proton部署應用程式作為AWS Proton服務時,由開發人員擁有和管理的資源。若要取得有關AWS KMS和資料加密的更多資訊,請參閱AWS Proton 中的資料保護

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

您使用 IAM 服務建立服務角色及其許可政策。如需有關建立服務角色的詳細資訊,請參閱《IAM 使用者指南》中的建立角色以將許可委派給 AWS 服務

AWS Proton佈建使用的服務角色 AWS CloudFormation

身為平台小組的成員,您可以作為系統管理員建立AWS Proton服務角色,並在建立環境作為環境的 CloudFormation 服務角色 (CreateEnvironmentAPI 動作的protonServiceRoleArn參數) AWS Proton 時提供服務角色。當環境或其中執行的任何服務執行個體使用 AWS-managed 佈建並AWS CloudFormation佈建基礎結構時,此角色可AWS Proton讓您代表您對其他服務進行 API 呼叫。

建議您針對AWS Proton服務角色使用下列 IAM 角色和信任政策。當您使用主AWS Proton控台建立環境並選擇建立新角色時,這是新AWS Proton增至其為您建立的服務角色的原則。設定此原則的權限範圍時,請記住,錯誤時會AWS Proton失敗。Access Denied

重要

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

用您的 AWS 帳戶 ID 取代 123456789012

{ "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" ] } } } ] }
{ "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 Proton服務角色政策的範例,如果您只需要佈建 S3 資源的AWS Proton服務,則可以使用該政策。

{ "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 佈建的服務角色

身為平台小組的成員,您可以作為系統管理員建立AWS Proton服務角色,並在建立環境作為環境的 CodeBuild 服務角色 (CreateEnvironmentAPI 動作的codebuildRoleArn參數) AWS Proton 時提供服務角色。當環境或其中執行的任何服務執行個體使用佈建來 CodeBuild 佈建基礎結構時,此角色可AWS Proton讓您代表您對其他服務進行 API 呼叫。

當您使用AWS Proton主控台建立環境並選擇建立新角色時,請將具有系統管理員權限的原則新AWS Proton增至其為您建立的服務角色。當您建立自己的角色並縮減權限範圍時,請記住,Access Denied錯誤時會AWS Proton失敗。

重要

請注意,AWS Proton附加到它為您建立之角色的原則,會將管理員權限授與任何可以向您帳戶註冊範本的任何人。由於我們不知道您將在AWS Proton範本中定義哪些資源,因此這些政策具有廣泛的權限。我們建議您將權限範圍縮小到將在您的環境中部署的特定資源。

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

用您的 AWS 帳戶 ID 取代 123456789012

{ "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" } ] }
{ "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管線服務角色

若要佈建服務管線,AWS Proton需要對其他服務進行 API 呼叫的權限。必要的服務角色與您在建立環境時提供的服務角色類似。不過,建立管道的角色會在您AWS帳戶中的所有服務之間共用,您可以在主控台中將這些角色提供為 「帳戶」設定,或透過 UpdateAccountSettingsAPI 動作。

當您使用AWS Proton主控台更新帳號設定,並選擇為AWS CloudFormation或 CodeBuild 服務角色建立新角色時,新AWS Proton增至其為您建立的服務角色的政策與上一節所述的策略相同,以AWS-受管佈建角色CodeBuild 佈建角色。設定此原則的權限範圍時,請記住,錯誤時會AWS Proton失敗。Access Denied

重要

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

AWS Proton元件角色

身為平台小組的成員,您可以作為管理員建立AWS Proton服務角色,並在建立環境作為環境的 CloudFormation 元件角色 (CreateEnvironmentAPI 動作的componentRoleArn參數) AWS Proton 時提供服務角色。此角色會縮減直接定義元件可佈建的基礎結構的範圍。如需元件的詳細資訊,請參閱AWS Proton 元件

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

用您的 AWS 帳戶 ID 取代 123456789012

{ "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" } } } ] }
{ "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/*" } } } }