このページでは、Secure Source Manager への接続を作成し、Secure Source Manager リポジトリにリンクする方法について説明します。この統合により、Secure Source Manager リポジトリのダッシュボード ビューなどの Developer Connect 機能を使用したり、Developer Connect プロキシを使用して安全な読み取りオペレーションなどの git オペレーションを実行したりできます。
始める前に
-
Google アカウントにログインします。
Google アカウントをまだお持ちでない場合は、新しいアカウントを登録します。
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Developer Connect API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Developer Connect API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.- 省略可: Developer Connect が作成する認証シークレットを暗号化するための顧客管理の暗号鍵(CMEK)を作成します。
- 省略可: このガイドのコマンドラインの手順を使用するには、次の操作を行います。
- Google Cloud CLI をインストールする。 すでに gcloud CLI をインストールしている場合は、
gcloud components updateを実行して、最新のバージョンがインストールされていることを確認してください。 - 次のコマンドを実行して、Developer Connect サービス アカウントを作成します。ここで、PROJECT_ID は Google Cloud プロジェクト ID です。
gcloud beta services identity create \ --service=developerconnect.googleapis.com \ --project=PROJECT_ID
- Google Cloud CLI をインストールする。 すでに gcloud CLI をインストールしている場合は、
Secure Source Manager の要件
- Google Cloud リージョンに運用可能な Secure Source Manager インスタンスがデプロイされていることを確認します。
- Developer Connect 接続と Secure Source Manager インスタンスは同じリージョンに存在する必要があります。
- Developer Connect サービス エージェント(P4SA)に、Secure Source Manager インスタンスのプロジェクトで
roles/securesourcemanager.developerConnectLinkerロールを付与します。
必要なロール
接続とリンクの作成に必要な権限を取得するには、管理者に次の IAM ロールを付与するよう依頼してください。
-
接続を作成してリポジトリにリンクする: Developer Connect リソースを作成するプロジェクトに対する Developer Connect 管理者(
roles/developerconnect.admin) -
Developer Connect サービス エージェントに権限を付与するには: Secure Source Manager が実行されているプロジェクトに対するプロジェクト IAM 管理者(
roles/resourcemanager.projectIamAdmin)。
ロールの付与については、プロジェクト、フォルダ、組織へのアクセス権の管理をご覧ください。
必要な権限は、カスタムロールや他の事前定義ロールから取得することもできます。
接続を作成する
このセクションでは、Developer Connect と Secure Source Manager 間の接続を作成する方法について説明します。 Google Cloud コンソールを使用している場合は、接続の設定が完了したら、リポジトリへのリンクの追加を開始することもできます。
新しい Secure Source Manager 接続を作成するには、次のいずれかのオプションを選択します。
コンソール
Google Cloud コンソールで Developer Connect を開きます。
[接続を作成] をクリックします。
ソース プロバイダとして Secure Source Manager を選択します。
[リージョン] で、接続のリージョンを選択します。これは、Secure Source Manager インスタンスと同じリージョンにする必要があります。
[名前] に、接続の名前を入力します。
[インスタンス] リストで、インスタンスを選択します。
[詳細を表示] をクリックすると、オプションの構成設定が表示されます。
省略可: Developer Connect プロキシを無効にするには、[Developer Connect プロキシを有効にする] チェックボックスをオフにします。
[続行] をクリックします。
リポジトリへのリンクは今すぐ行うことも、後で接続を編集して行うこともできます。リポジトリにリンクするには、リストからリポジトリを選択します。
[リンク] をクリックします。
Developer Connect は、リポジトリ リンクを作成して Google Cloud コンソールに表示します。
gcloud
Google Cloud CLI で Developer Connect 接続を作成するには、次のコマンドを実行します。
gcloud developer-connect connections create CONNECTION_ID \
--location=REGION \
--project=CONNECTION_PROJECT_ID \
--secure-source-manager-instance-config=projects/INSTANCE_PROJECT_ID/locations/REGION/instances/INSTANCE_ID
ここで
- CONNECTION_ID は、作成する Developer Connect 接続の ID です。
- REGION は、接続のリージョンです。これは、Secure Source Manager インスタンスと同じリージョンにする必要があります。
- CONNECTION_PROJECT_ID は、接続を作成する Google Cloud プロジェクトの ID です。
- INSTANCE_PROJECT_ID は、Secure Source Manager インスタンスが配置されている Google Cloud プロジェクトの ID です。
- INSTANCE_ID は、Secure Source Manager インスタンスの ID です。
curl
curl を使用して Developer Connect 接続を作成するには、次の API 呼び出しを行います。
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://developerconnect.googleapis.com/v1/projects/CONNECTION_PROJECT_ID/locations/REGION/connections?connection_id=CONNECTION_ID \
-X POST -H "Content-Type: application/json" \
-d '{"secure_source_manager_instance_config":{"instance":"projects/INSTANCE_PROJECT_ID/locations/REGION/instances/INSTANCE_ID"}}'
ここで
- CONNECTION_ID は、作成する Developer Connect 接続の ID です。
- REGION は、接続のリージョンです。これは、Secure Source Manager インスタンスと同じリージョンにする必要があります。
- CONNECTION_PROJECT_ID は、接続を作成する Google Cloud プロジェクトの ID です。
- INSTANCE_PROJECT_ID は、Secure Source Manager インスタンスが配置されている Google Cloud プロジェクトの ID です。
- INSTANCE_ID は、Secure Source Manager インスタンスの ID です。
既存の接続にリポジトリ リンクを追加する
Secure Source Manager への接続を確立したら、リポジトリにリンクできます。必要に応じて、後でこの手順を繰り返してリポジトリを追加できます。
既存の Secure Source Manager 接続にリポジトリ リンクを作成するには、次のいずれかのオプションを選択します。
コンソール
Google Cloud コンソールで [リポジトリ] ページを開きます。
[リポジトリをリンクする] をクリックします。
[Git リポジトリをリンク] ペインが開きます。
接続リストで、Secure Source Manager 接続を選択します。
[続行] をクリックします。
リポジトリのリストで、リンクするリポジトリを選択します。
[作成] をクリックします。
Developer Connect は、リポジトリ リンクを作成して Google Cloud コンソールに表示します。
gcloud
gcloud を使用して git リポジトリ リンクを管理する方法については、gcloud developer-connect connections git-repository-links をご覧ください。
Cloud Build で Developer Connect プロキシを使用する
Cloud Build で Developer Connect プロキシを使用するには、次の操作を行います。
- Secure Source Manager サービス エージェントに、Developer Connect プロジェクトに対する
roles/developerconnect.viewerロール、またはdeveloperconnect.gitRepositoryLinks.get権限を持つロールを付与します。 - Secure Source Manager リポジトリを Developer Connect
gitRepositoryLinkにリンクします。手順については、Secure Source Manager リポジトリにリンクするをご覧ください。 リポジトリのルート ディレクトリにある
.cloudbuild/trigger.yamlファイルに、ターゲットのgitRepositoryLinkリソースを指す新しいエントリを追加します。次に例を示します。
triggers: - name: test-trigger project: my-project configFilePath: cloudbuild.yaml eventType: push serviceAccount: projects/my-project/serviceAccounts/my-sa@my-project.iam.gserviceaccount.com devConnectGitRepositoryLink: projects/my-project/locations/us-central1/connections/my-ssm-connection/gitRepositoryLinks/my-repo-link
運用範囲と制限事項
接続を構成したら、Developer Connect プロキシ URI を使用して、Secure Source Manager インスタンスで clone などの安全な git 読み取りオペレーションを実行できます。
Developer Connect プロキシは git push オペレーションをサポートしていません。システムは、DevConnect P4SA の ID を使用する書き込みオペレーションを防止します。
接続の他の構成(Developer Connect プロキシの有効化や無効化など)は更新できますが、既存の接続を別の Secure Source Manager インスタンスに指定することはできません。
次のステップ
- Developer Connect の詳細を確認する。
- Secure Source Manager の詳細を確認する。