Secure Source Manager に接続する

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

始める前に

  1. ログイン Google アカウントにログインします。

    Google アカウントをまだお持ちでない場合は、 新しいアカウントを登録します

  2. 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

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

  4. 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 the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  5. 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

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

  7. 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 the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

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

Secure Source Manager の要件

必要なロール

接続とリンクの作成に必要な権限を取得するには、管理者に次の 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 接続を作成するには、次のいずれかのオプションを選択します。

コンソール

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

    Developer Connect に移動

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

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

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

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

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

  7. [詳細を表示] をクリックすると、省略可能な構成設定が表示されます。

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

コンソール

  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. Secure Source Manager サービス エージェントに、Developer Connect プロジェクトに対する 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.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 インスタンスに接続することはできません。

次のステップ