

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

# 設定自我託管執行器的私有登錄登入資料
新內容：設定自我託管執行器的私有登錄登入資料

新增使用來自非私有登錄檔的自訂映像時，設定登錄檔登入資料的支援。

使用下列指示來設定自我託管執行器的登錄登入資料。

**注意**  
請注意，只有在映像被私有登錄檔的映像覆寫時，才會使用這些登入資料。

------
#### [ AWS Management Console ]

1. 在 https：//[https://console.aws.amazon.com/codesuite/codebuild/home](https://console.aws.amazon.com/codesuite/codebuild/home) 開啟 AWS CodeBuild 主控台。

1. 建立建置專案或選取現有的專案。如需詳細資訊，請參閱 [建立組建專案 (主控台)](create-project.md#create-project-console) 及 [變更建置專案的設定 (主控台)](change-project.md#change-project-console)。

1.  在**環境中**，選擇**其他組態**。

1.  **在其他組態**中，輸入來自 的秘密名稱或 ARN AWS Secrets Manager for **Registry 登入資料 - 選用**。  
![\[登錄檔登入資料組態。\]](http://docs.aws.amazon.com/zh_tw/codebuild/latest/userguide/images/registry-credential.png)

------
#### [ AWS CLI ]

1. 如果您想要建立新的專案，請執行 **create-project** 命令。

   ```
   aws codebuild create-project \
       --name project-name \
       --source type=source-type,location=source-location \
       --environment "type=environment-type,image=image,computeType=compute-type,registryCredential={credentialProvider=SECRETS_MANAGER,credential=secret-name-or-arn},imagePullCredentialsType=CODEBUILD|SERVICE_ROLE" \
       --artifacts type=artifacts-type \
       --service-role arn:aws:iam::account-ID:role/service-role/service-role-name
   ```

1. 如果您想要更新現有的專案，請執行 **update-project** 命令。

   ```
   aws codebuild update-project \
       --name project-name \
       --environment "type=environment-type,image=image,computeType=compute-type,registryCredential={credentialProvider=SECRETS_MANAGER,credential=secret-name-or-arn}"
   ```

------