このページでは、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 の要件
- リージョンに運用可能な Secure Source Manager インスタンスがデプロイされていることを確認します。 Google Cloud
- Developer Connect 接続と Secure Source Manager インスタンスは同じリージョンに存在する必要があります。
- Developer Connect サービス エージェント(P4SA)に、Secure Source Manager インスタンスのプロジェクトに対する
roles/securesourcemanager.developerConnectLinkerロールを付与します。
必要なロール
接続とリンクの作成に必要な権限を取得するには、管理者に次の IAM のロールを付与するよう依頼してください。
-
接続を作成してリポジトリにリンクする:
Developer Connect 管理者 (
roles/developerconnect.admin) Developer Connect リソースを作成するプロジェクトに対する。 -
Developer Connect サービス エージェントに権限を付与する:
プロジェクト IAM 管理者 (
roles/resourcemanager.projectIamAdmin) Secure Source Manager が実行されているプロジェクトに対する
ロールの付与については、プロジェクト、フォルダ、組織へのアクセス権の管理をご覧ください。
必要な権限は、カスタム ロールや他の事前定義 ロールから取得することもできます。
接続を作成する
このセクションでは、Developer Connect と Secure Source Manager の間に接続を作成する方法について説明します。コンソールを使用している場合は、接続の設定が完了したら、リポジトリへのリンクの追加を開始することもできます。 Google Cloud
新しい Secure Source Manager 接続を作成するには、次のいずれかのオプションを選択します。
コンソール
コンソールで [Developer Connect] を開きます。 Google Cloud
[接続を作成] をクリックします。
ソース プロバイダとして [Secure Source Manager] を選択します。
For [Region] で、接続のリージョンを選択します。これは、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 は、 Google Cloud Secure Source Manager インスタンスがある プロジェクトの 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 は、 Google Cloud Secure Source Manager インスタンスがある プロジェクトの 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 インスタンスで安全な git 読み取りオペレーション(clone など)を実行できます。
Developer Connect プロキシは git push オペレーションをサポートしていません。DevConnect
P4SA の ID を使用する書き込みオペレーションはシステムによって阻止されます。
接続の他の構成(Developer Connect プロキシの有効化または無効化など)を更新できますが、既存の接続を別の Secure Source Manager インスタンスに接続することはできません。
次のステップ
- Developer Connect の詳細を確認する。
- Secure Source Manager の詳細を確認する。