權限和範例 AWS CodeConnections - 開發人員工具主控台

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

權限和範例 AWS CodeConnections

下列政策陳述式和範例可協助您管理 AWS CodeConnections。

如需有關如何使用這些範例原則文件建立以IAM身分識別為基礎的JSON原則的詳細資訊,請參閱使用指南中的JSON索引標籤上的IAM建立策略。

範例:使用主控 AWS CodeConnections 台建立CLI和檢視的政策

被指定用來檢視、建立、標記 AWS CLI 或SDK刪除連線的角色或使用者,應具有下列各項限制的權限。

注意

只具有下列許可,並無法在主控台中完成連線。您需要新增下一節中的許可。

若要使用主控台來檢視可用連線的清單、檢視標籤和使用連線,請使用下列政策。

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ConnectionsFullAccess", "Effect": "Allow", "Action": [ "codeconnections:CreateConnection", "codeconnections:DeleteConnection", "codeconnections:UseConnection", "codeconnections:GetConnection", "codeconnections:ListConnections", "codeconnections:TagResource", "codeconnections:ListTagsForResource", "codeconnections:UntagResource" ], "Resource": "*" } ] }

範例:使用主控台建立 AWS CodeConnections 的政策

指定要管理在主控台中連線的角色或使用者,應具備完成主控台中的連線及建立安裝所需的許可,包括授權供應商進行交握,以及建立供連線使用的安裝。也應該新增 UseConnection 以使用主控台中的連線。請使用下列政策來在主控台中檢視、使用、建立、標記或刪除連線。

注意

目前,如果您使用主控台建立連線,這只會在資源codestar-connections中建立具有的資源ARN。若要建立在中包含codeconnections服務前置詞的資源ARN,請使用CLISDK、或CFN。具有兩個服務前綴的資源仍將顯示在控制台中。自 2024 年 7 月 1 日起,可以建立主控台資源。

注意

對於使用主控台建立的資源,政策陳述式動作必須包含codestar-connections做為服務前置詞,如下列範例所示。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "codestar-connections:CreateConnection", "codestar-connections:DeleteConnection", "codestar-connections:GetConnection", "codestar-connections:ListConnections", "codestar-connections:GetInstallationUrl", "codestar-connections:GetIndividualAccessToken", "codestar-connections:ListInstallationTargets", "codestar-connections:StartOAuthHandshake", "codestar-connections:UpdateConnectionInstallation", "codestar-connections:UseConnection", "codestar-connections:TagResource", "codestar-connections:ListTagsForResource", "codestar-connections:UntagResource" ], "Resource": [ "*" ] } ] }

範例:用於管理的系統管理員層級原則 AWS CodeConnections

在此範例中,您想要授與 AWS 帳IAM戶中的使用者完整存取權限,以 CodeConnections 便使用者可以新增、更新和刪除連線。這是完整存取原則,相當於 AWSCodePipeline_ 受FullAccess管理的原則。就像該受管理策略一樣,您應該只將這種策略聲明附加到需要對整個 AWS 帳戶連接進行完整管理權限的IAM使用者、群組或角色。

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ConnectionsFullAccess", "Effect": "Allow", "Action": [ "codeconnections:CreateConnection", "codeconnections:DeleteConnection", "codeconnections:UseConnection", "codeconnections:GetConnection", "codeconnections:ListConnections", "codeconnections:ListInstallationTargets", "codeconnections:GetInstallationUrl", "codeconnections:StartOAuthHandshake", "codeconnections:UpdateConnectionInstallation", "codeconnections:GetIndividualAccessToken", "codeconnections:TagResource", "codeconnections:ListTagsForResource", "codeconnections:UntagResource" ], "Resource": "*" } ] }

範例:使用的參與者層級原則 AWS CodeConnections

在此範例中,您想要授與存取使用情 day-to-day 況 (例如建立和檢視連線的詳細資料),但不要授與更具破壞性的動作 (例如刪除連線)。 CodeConnections

{ "Version": "2012-10-17", "Statement": [ { "Sid": "AWSCodeConnectionsPowerUserAccess", "Effect": "Allow", "Action": [ "codeconnections:CreateConnection", "codeconnections:UseConnection", "codeconnections:GetConnection", "codeconnections:ListConnections", "codeconnections:ListInstallationTargets", "codeconnections:GetInstallationUrl", "codeconnections:GetIndividualAccessToken", "codeconnections:StartOAuthHandshake", "codeconnections:UpdateConnectionInstallation", "codeconnections:ListTagsForResource" ], "Resource": "*" } ] }

範例:使用的 read-only-level 政策 AWS CodeConnections

在此範例中,您想要授與帳IAM戶中的使用者對您帳戶中連線的唯讀存取權。 AWS 此範例會示範如何建立允許檢視這些項目的政策。

{ "Version": "2012-10-17", "Id": "Connections__ReadOnly", "Statement": [ { "Sid": "Reads_API_Access", "Effect": "Allow", "Action": [ "codeconnections:GetConnection", "codeconnections:ListConnections", "codeconnections:ListInstallationTargets", "codeconnections:GetInstallationUrl", "codeconnections:ListTagsForResource" ], "Resource": "*" } ] }

範例:與指定存放庫 AWS CodeConnections 搭配使用的範圍縮短原則

在下列範例中,客戶希望 CodeBuild 服務角色存取指定的 Bitbucket 存放庫。 CodeBuild 服務角色的原則:

{ "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Action": [ "codeconnections:UseConnection" ], "Resource": "arn:aws:codeconnections:us-west-2:connection:3dee99b9-172f-4ebe-a257-722365a39557", "Condition": {"ForAllValues:StringEquals": {"codeconnections:FullRepositoryId": "myrepoowner/myreponame"}} } }

範例:使用連線的原則 CodePipeline

在下列範例中,系統管理員想要使用者使用與的連線 CodePipeline。連接至使用者的政策:

{ "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Action": [ "codeconnections:PassConnection" ], "Resource": "arn:aws:codeconnections:us-west-2:connection/aEXAMPLE-8aad-4d5d-8878-dfcab0bc441f", "Condition": {"ForAllValues:StringEquals": {"codeconnections:PassedToService": "codepipeline.amazonaws.com"}} } }

範例:使用 CodeBuild 服務角色進行 Bitbucket 讀取作業 AWS CodeConnections

在下列範例中,無論存放庫為何,客戶都希望 CodeBuild 服務角色在 Bitbucket 上執行讀取作業。 CodeBuild 服務角色的原則:

{ "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Action": [ "codeconnections:UseConnection" ], "Resource": "arn:aws:codeconnections:us-west-2:connection/aEXAMPLE-8aad-4d5d-8878-dfcab0bc441f", "Condition": {"ForAllValues:StringEquals": {"codeconnections:ProviderPermissionsRequired": "read_only"}} } }

範例:限制 CodeBuild 服務角色執行作業 AWS CodeConnections

在下列範例中,客戶想要防止 CodeBuild 服務角色執行類似的作業CreateRepository。 CodeBuild 服務角色的原則:

{ "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Action": [ "codeconnections:UseConnection" ], "Resource": "arn:aws:codeconnections:us-west-2:connection/aEXAMPLE-8aad-4d5d-8878-dfcab0bc441f", "Condition": {"ForAllValues:StringNotEquals": {"codeconnections:ProviderAction": "CreateRepository"}} } }