Secure Source Manager に接続する

このページでは、Secure Source Manager への接続を作成し、Secure Source Manager リポジトリにリンクする方法について説明します。この統合により、Secure Source Manager リポジトリのダッシュボード ビューなどの Developer Connect 機能を使用できます。また、Developer Connect プロキシを使用して、安全な読み取りオペレーションなどの git オペレーションを実行できます。

始める前に

  1. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  2. Verify that billing is enabled for your Google Cloud project.

  3. Enable the Developer Connect, Secret Manager APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  4. 省略可: Developer Connect が作成する認証シークレットを暗号化するための顧客管理の暗号鍵(CMEK)を作成します。
  5. 省略可: このガイドのコマンドラインの手順を使用するには、次の操作を行います。
    1. Google Cloud CLI をインストールする。 すでに gcloud CLI をインストールしている場合は、gcloud components update を実行して、最新のバージョンがインストールされていることを確認してください。
    2. 次のコマンドを実行して、Developer Connect サービス アカウントを作成します。ここで、PROJECT_ID は Google Cloud プロジェクト ID です。
              gcloud beta services identity create \
                  --service=developerconnect.googleapis.com \
                  --project=PROJECT_ID
              

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 と Secure Source Manager の間に接続を作成する方法について説明します。 Google Cloud コンソールを使用している場合は、接続の設定が完了すると、リポジトリへのリンクの追加を開始することもできます。

新しい Secure Source Manager 接続を作成するには、次のいずれかのオプションを選択します。

コンソール

  1. Google Cloud コンソールで Developer Connect を開きます。

    Developer Connect に移動

  2. [接続を作成] をクリックします。

  3. ソース プロバイダとして [Secure Source Manager] を選択します。

  4. [リージョン] で、接続のリージョンを選択します。これは、Secure Source Manager インスタンスと同じリージョンにする必要があります。

  5. [名前] に、接続の名前を入力します。

  6. [インスタンス] リストで、インスタンスを選択します。

  7. [Show more] をクリックして、オプションの構成設定を表示します。

  8. 省略可: Developer Connect プロキシを無効にするには、[Developer Connect プロキシを有効にする] チェックボックスをオフにします。

  9. [続行] をクリックします。

  10. 今すぐリポジトリにリンクすることも、後で接続を編集してリンクすることもできます。リポジトリにリンクするには、リストからリポジトリを選択します。

  11. [リンク] をクリックします。

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 接続にリポジトリ リンクを作成するには、次のいずれかのオプションを選択します。

コンソール

  1. Google Cloud コンソールで [リポジトリ] ページを開きます。

    [リポジトリ] ページを開く

  2. [リポジトリをリンクする] をクリックします。

    [Git リポジトリをリンク] ペインが開きます。

  3. 接続リストで、Secure Source Manager 接続を選択します。

  4. [続行] をクリックします。

  5. リポジトリ リストで、リンクするリポジトリを選択します。

  6. [作成] をクリックします。

Developer Connect がリポジトリ リンクを作成し、 Google Cloud コンソールに表示します。

gcloud

gcloud を使用して Git リポジトリ リンクを管理する方法については、gcloud developer-connect connections git-repository-links をご覧ください。

Cloud Build で Developer Connect プロキシを使用する

Cloud Build で Developer Connect プロキシを使用する手順は次のとおりです。

  1. Developer Connect プロジェクトで、Secure Source Manager サービス エージェントに roles/developerconnect.viewer ロール、または developerconnect.gitRepositoryLinks.get 権限を持つロールを付与します。
  2. Secure Source Manager リポジトリを Developer Connect gitRepositoryLink にリンクします。手順については、Secure Source Manager リポジトリにリンクするをご覧ください。
  3. リポジトリのルート ディレクトリにある .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.
      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 インスタンスにポイントすることはできません。

次のステップ