# Google Cloud (GCP Cloud Run)

<figure><img src="https://1914737032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mfd2v-YT48Ljtykb8qm%2Fuploads%2FQ7q3AGwY5crt3WtMOgax%2FGoogle%20Cloud%20(GCP%20Cloud%20Run).avif?alt=media&#x26;token=d190e983-87a9-4d4c-90bd-eb1d5729747b" alt=""><figcaption></figcaption></figure>

## 概要 <a href="#overview" id="overview"></a>

本ガイドでは、特にGCP Cloud Runサービスを使用してGoogle CloudでKeeperオートメーターサービスを実行する手順について取り扱います。オートメーターは、KeeperのインフラストラクチャIPへのアクセスを制限するために、Google Armorサービスによっても保護されています。

### 1. プロジェクトを作成する

Google Cloudコンソール (<https://console.cloud.google.com>) から新しいプロジェクトを作成します。

<figure><img src="https://docs.keeper.io/~gitbook/image?url=https%3A%2F%2F2503956294-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MB_i6vKdtG6Z2n6zWgJ%252Fuploads%252Fec5L0yjhDAYDFJvDzRIh%252FScreenshot%25202024-10-25%2520at%25207.40.55%25E2%2580%25AFAM.png%3Falt%3Dmedia%26token%3D8392ca16-40be-40a9-a65b-1159063f7653&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=12454245&#x26;sv=1" alt=""><figcaption><p>新しいプロジェクトを作成する</p></figcaption></figure>

次に、この新しいプロジェクト&#x3067;**\[プロジェクトを選択]**&#x3092;クリックします。

### 2. クラウドシェルを起動する <a href="#id-2-start-the-cloud-shell" id="id-2-start-the-cloud-shell"></a>

本ページでは、ウェブインターフェースからGoogle Cloud Shellを使用します。クリックしてCloud Shellを有効にするか、ローカルマシンにインストールしてください。

<figure><img src="https://1914737032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mfd2v-YT48Ljtykb8qm%2Fuploads%2FMQw2N9hV3f9BTSQo8XDp%2Fimage.png?alt=media&#x26;token=e47587bf-dd98-4fd1-9be3-90c0ad214fac" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1914737032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mfd2v-YT48Ljtykb8qm%2Fuploads%2FyBN67XaLks7Pjd4Tvzmc%2Fimage.png?alt=media&#x26;token=1937edec-cc82-4fdf-a799-1ba4ce89953f" alt=""><figcaption><p>Google Cloud Shellを起動</p></figcaption></figure>

* **Project ID**をメモしておきます。この場合は`keeper-automator-439714`となります。このプロジェクトIDは後続のコマンドで使用されます。

### 3. 請求先アカウントをリンクする <a href="#id-3-link-a-billing-account" id="id-3-link-a-billing-account"></a>

まだお済みでない場合は、有効な請求先アカウントをプロジェクトにリンクする必要があります。これは、Google Cloudユーザーインターフェース&#x306E;**\[お支払い]**&#x30E1;ニューから実行します。

### 4. オートメーターConfigキーを作成する <a href="#id-3-create-an-automator-config-key" id="id-3-create-an-automator-config-key"></a>

Cloud Shellから、URLエンコード形式で256ビットのAESキーを生成します。

```
openssl rand -base64 32
```

キーの例:`6C45ibUhoYqkTD4XNFqoZoZmslvklwyjQO4ZqLdUECs=`

結果のキーをKeeperに保存します。これは、コンテナをデプロイするときに環境変数として使用されます。このキーにより、起動時に一時的なコンテナが構成されるようになります。

### 5. アーティファクトレジストリを有効にする <a href="#id-4-enable-the-artifact-registry" id="id-4-enable-the-artifact-registry"></a>

```
gcloud services enable run.googleapis.com artifactregistry.googleapis.com
```

### 6. 地域を選択 <a href="#id-5-select-a-region" id="id-5-select-a-region"></a>

サービスを実行するには、地域を選択する必要があります。使用可能な地域コードは、以下のコマンドを使用して確認できます。

```
gcloud run regions list
```

この例では、`us-east1`を使用します。

### 7. オートメーターサービス用のArtifact Registryを作成する

以下の 2 つのコマンドを実行し、「us-east1」を手順6の値に置き換えます。

```
gcloud artifacts repositories create keeper-automator-repo \
    --repository-format=docker \
    --location=us-east1 \
    --description="Artifact registry for Keeper Automator service"
```

```
gcloud auth configure-docker us-east1-docker.pkg.dev
```

### 8. オートメーターコンテナをArtifact Registryにアップロードする <a href="#id-7-upload-the-automator-container-to-the-artifact-registry" id="id-7-upload-the-automator-container-to-the-artifact-registry"></a>

次の内容を含む`cloudbuild.yaml`というファイルを作成し、文字列`us-east1`を手順6の地域に置き換えます。その他の内容はすべてそのままにします。

{% code title="Cloudbuild.yaml" overflow="wrap" %}

```yaml
steps:
  - name: 'gcr.io/cloud-builders/docker'
    args: ['pull', 'keeper/automator:latest']
  - name: 'gcr.io/cloud-builders/docker'
    args: [
      'tag',
      'keeper/automator:latest',  
      'us-east1-docker.pkg.dev/$PROJECT_ID/keeper-automator-repo/keeper-automator:latest'
    ]
  - name: 'gcr.io/cloud-builders/docker'
    args: [
      'push',
      'us-east1-docker.pkg.dev/$PROJECT_ID/keeper-automator-repo/keeper-automator:latest'
    ]
images:
  - 'us-east1-docker.pkg.dev/$PROJECT_ID/keeper-automator-repo/keeper-automator:latest'
```

{% endcode %}

* `us-east1`を[手順6](#id-5-select-a-region)の地域に置き換えます

このファイルをCloud Shellユーザーインターフェースからアップロードするか、Cloud Shellでテキストファイルを作成します。

Cloud Shellから、以下を実行します。

```
gcloud services enable cloudbuild.googleapis.com
```

次にビルドを実行します。

```
gcloud builds submit --config cloudbuild.yaml
```

これにより、最新のオートメーターコンテナがGoogle Artifact Registryに同期されます。

### 9. オートメーターサービスをデプロイする <a href="#id-8-deploy-the-automator-service" id="id-8-deploy-the-automator-service"></a>

以下のコマンドで、Artifact RegistryからKeeperオートメーターサービスをGoogle Cloud Runにデプロイします。このサービスは、内部アクセスとロードバランサのみに制限されています。

```
gcloud run deploy keeper-automator \
    --image us-east1-docker.pkg.dev/[PROJECT ID]/keeper-automator-repo/keeper-automator:latest \
    --platform managed \
    --region us-east1 \
    --allow-unauthenticated \
    --ingress internal-and-cloud-load-balancing \
    --min-instances 1 \
    --max-instances 2 \
    --set-env-vars "AUTOMATOR_CONFIG_KEY=XXX,AUTOMATOR_PORT=8080,DISABLE_SNI_CHECK=true,SSL_MODE=none"
```

以下の点にご注意ください。

* `[PROJECT_ID]`は手順2のProject IDに置き換えます。
* `XXX`を上記の手順 3 で作成した構成キーに置き換えます。
* `AUTOMATOR_PORT`がコンテナにポート8080をリッスンするように指示します。
* `SSL_MODE`でSSL接続をロードバランサで終了できるようになります。
* `DISABLE_SNI_CHECK`でロードバランサーの背後でリクエストを完了できるようになります。
* インスタンスの最小数は 1 であり、これはほとんどの環境で許容されます。
* 最小/最大が設定されていない場合、サービスはインスタンスをゼロに減らし、最初のリクエストで起動します。

### 10. マネージド証明書の作成 <a href="#id-9-create-managed-certificate" id="id-9-create-managed-certificate"></a>

Keeperシステムは、パブリックにルーティング可能なDNS名を介してオートメーターサービスと通信します。この例では、`gcpautomator.lurey.com`を使用しています。設定には、まずマネージドSSL証明書を作成する必要があります。以下はそのためのコマンドとなります。

```
gcloud compute ssl-certificates create automator-compute-certificate \
    --domains gcpautomator.lurey.com \
    --global
```

* `gcpautomator.lurey.com`を任意の名前に置き換えてください。

### 11. サーバーレスネットワークエンドポイントグループを作成する <a href="#id-10-create-a-serverless-network-endpoint-group" id="id-10-create-a-serverless-network-endpoint-group"></a>

次のコマンドで、Cloud RunサービスをGoogle Cloud Load Balancerにリンクします。

```
gcloud compute network-endpoint-groups create keeper-automator-neg \
    --region us-east1 \
    --network-endpoint-type=serverless \
    --cloud-run-service keeper-automator
```

* `us-east1`を[手順6](#id-5-select-a-region)のCloud Runサービスのリージョンに置き換えます。

### 12. **NEGを**使用する**バックエンドサービスを作成する** <a href="#id-11-create-a-backend-service-that-will-use-the-neg" id="id-11-create-a-backend-service-that-will-use-the-neg"></a>

これにより、Cloud Runサービスにリンクするバックエンドサービスが作成されます。

```
gcloud compute backend-services create keeper-automator-backend \
    --global \
    --protocol HTTP
```

### 13. バックエンドサービスに**NEGをアタッチする** <a href="#id-12-attach-the-neg-to-the-backend-service" id="id-12-attach-the-neg-to-the-backend-service"></a>

これにより、NEGがバックエンド サービスに接続されます。

```
gcloud compute backend-services add-backend keeper-automator-backend \
    --global \
    --network-endpoint-group keeper-automator-neg \
    --network-endpoint-group-region us-east1
```

* `us-east1`を[手順6](#id-5-select-a-region)で指定した場所に置き換えます。

### 14. 受信トラフィックをバックエンドサービスに誘導するURLマップを作成する <a href="#id-13-create-a-url-map-that-directs-incoming-traffic-to-the-backend-service" id="id-13-create-a-url-map-that-directs-incoming-traffic-to-the-backend-service"></a>

```
gcloud compute url-maps create keeper-automator-url-map \
    --default-service keeper-automator-backend
```

### 15. HTTPSターゲットプロキシを作成し、オートメーター証明書をマップする <a href="#id-14-create-the-https-target-proxy-and-map-the-automator-certificate" id="id-14-create-the-https-target-proxy-and-map-the-automator-certificate"></a>

```
gcloud compute target-https-proxies create keeper-automator-target-proxy \
    --url-map keeper-automator-url-map \
    --ssl-certificates automator-compute-certificate
```

### 16. 静的IPアドレスを予約し、DNSエントリを割り当てる <a href="#id-15-reserve-a-static-ip-address-and-assign-dns-entry" id="id-15-reserve-a-static-ip-address-and-assign-dns-entry"></a>

```
gcloud compute addresses create keeper-automator-ip --global
```

IPアドレスを取得して、後で使用するためにメモしておきます。

```
gcloud compute addresses list
```

IPアドレスは有効な DNSにマッピングする必要があります。

DNSプロバイダで、IPを指すA-recordを設定します。

**A-Record構成の例**

| タイプ | 名前                       | 値             | TTL |
| --- | ------------------------ | ------------- | --- |
| A   | `gcpautomator.lurey.com` | `xx.xx.xx.xx` | 60  |

* この手順は重要です。目的のドメイン名が指定されたIP アドレスを指していることを確かにしてください。この手順はDNSプロバイダで直接実行する必要があります。

### 17. グローバル転送ルールを作成する <a href="#id-16-create-a-global-forwarding-rule" id="id-16-create-a-global-forwarding-rule"></a>

受信リクエストをターゲットプロキシに転送するための**グローバル転送ルール**を作成します。

```
gcloud compute forwarding-rules create keeper-automator-forwarding-rule \
    --global \
    --target-https-proxy keeper-automator-target-proxy \
    --ports 443 \
    --address keeper-automator-ip
```

### 18. 特定のIPへのアクセスをロックダウンする <a href="#id-17-lock-down-access-to-specific-ips" id="id-17-lock-down-access-to-specific-ips"></a>

Keeperオートメーターサービスは、[イングレス要件のページ](https://docs.keeper.io/jp/sso-connect-cloud/device-approvals/automator/inguresu)に記載の通り、必要なIPのみに制限する必要があります。

特定のIPアドレスへのアクセスを制限する**Cloud Armorセキュリティポリシー**を作成しましょう。

{% code overflow="wrap" %}

```
gcloud compute security-policies create allow-specific-ips-policy --description "Allow specific IPs"
```

{% endcode %}

この手順では、[こちらのページ](https://docs.keeper.io/jp/sso-connect-cloud/device-approvals/automator/inguresu)に記載のKeeperの米国データセンターのIPを接続します。必要に応じて追加のルールを作成してください。

```
gcloud compute security-policies rules create 1000 \
    --security-policy allow-specific-ips-policy \
    --src-ip-ranges 54.208.20.102,34.203.159.189 \
    --action allow
```

* オートメーターサービスをテストできるように、外部IPをこのリストに追加することをお勧めします。

他のトラフィックを制限するために、デフォルトの「拒否」ルールも追加します。

```
gcloud compute security-policies rules create 2000 \
    --security-policy allow-specific-ips-policy \
    --action deny-404 \
    --src-ip-ranges '*'
```

最後に、**Cloud Armorセキュリティポリシーを**バックエンドサービスにアタッチします。

```
gcloud compute backend-services update keeper-automator-backend \
    --global \
    --security-policy allow-specific-ips-policy
```

この時点で、オートメーターサービスが実行され、サービスはKeeperインフラストラクチャにのみ公開されます。

次の手順では、Keeperコマンダーのユーティリティを使用して構成を完了します。

### 19. Keeperコマンダーにログイン <a href="#id-18-login-to-keeper-commander" id="id-18-login-to-keeper-commander"></a>

オートメーター設定の最終手順を実行するには、Keeperコマンダーが必要となります。コマンダーはどこからでも実行でき、サーバーにインストールする必要はありません。

ワークステーションまたはサーバーに、KeeperコマンダーCLI をインストールします。バイナリインストーラーを含むインストール手順については、[こちらのページ](https://app.gitbook.com/s/PL6k1aGsLiFiiJ3Y7zCl/commander-cli/commander-installation-setup)をご参照ください。

コマンダーをインストールした後、Keeperコマンダーを起動するか、既存のターミナルから`keeper shell`と入力してセッションを開いてから、`login`コマンドを使用してログインします。オートメーターを設定するには、Keeper管理者かSSOノードを管理する権限を持つ管理者としてログインする必要があります。

```
$ keeper shell

My Vault> login admin@company.com

  _  __  
 | |/ /___ ___ _ __  ___ _ _ 
 | ' </ -_) -_) '_ \/ -_) '_|
 |_|\_\___\___| .__/\___|_|
 v16.x.xxx    |_|

 password manager & digital vault

Logging in to Keeper Commander
Enter password for admin@company.com
Password: ********************
Successfully authenticated with Master Password
Syncing...
Decrypted [58] record(s)

My Vault>
```

### 20. オートメーターを作成する <a href="#id-19-create-the-automator" id="id-19-create-the-automator"></a>

`automator create`で始まる一連のコマンドを使用してオートメーターを作成します。

```
My Vault> automator create --name "My Automator" --node "Azure Cloud"
```

ノード名 (この場合は「Azure Cloud」) は、以下に見られるように管理コンソールから取得します。

<figure><img src="https://docs.keeper.io/~gitbook/image?url=https%3A%2F%2F2503956294-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MB_i6vKdtG6Z2n6zWgJ%252F-MjGtCqu00Eduh1ZVB0V%252F-MjGwSk57QheWM55KqUd%252FScreen%2520Shot%25202021-09-10%2520at%25203.59.58%2520PM.png%3Falt%3Dmedia%26token%3D732b0e49-b10f-4718-a78e-f48af15ef50c&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=173c44f&#x26;sv=1" alt=""><figcaption><p>オートメーター作成</p></figcaption></figure>

コマンドの出力には、IDプロバイダからのメタデータを含むオートメーター設定が表示されます。

```
                    Automator ID: XXXX
                            Name: My Automator
                             URL: 
                         Enabled: No
                     Initialized: No
                          Skills: Device Approval
```

「URL」はまだ入力されていないことに注意してください。これは、オートメーターURLが入力されます。

以下のように、`automator edit`コマンドを実行します。これにより、URLが設定され、スキル ( `team`、`team_for_user`、`device`) も設定されます。

{% code overflow="wrap" %}

```
automator edit --url https://gcpautomator.lurey.com --skill=team --skill=team_for_user --skill=device "My Automator"
```

{% endcode %}

* 注: `gcpautomator.lurey.com`を[手順16](#id-15-reserve-a-static-ip-address-and-assign-dns-entry)で作成したドメイン名に置き換えます。

次に、キーを交換します。オートメーター公開キーで暗号化されたエンタープライズ秘密キーがオートメーターに提供されます。

```
automator setup "My Automator"
```

新しい設定でオートメーターを初期化します。

```
automator init "My Automator"
```

サービスを有効にします。

```
automator enable "My Automator"
```

### ユーザー体験のテスト <a href="#testing-the-user-experience" id="testing-the-user-experience"></a>

Keeperオートメーターがデプロイされましたので、エンドユーザー体験をテストできます。ユーザーが SSOのIDプロバイダで認証した後は、承認を求めるポップアップが表示されなくなります。

最も簡単にテストするには、Keeperウェブボルトをシークレットモードのウィンドウで開いて、クラウドSSOでログインします。デバイスの承認は求められなくなっています。

***

## コンテナの更新 <a href="#updating-the-container" id="updating-the-container"></a>

Keeperから新しいバージョンが利用可能になる際にGoogleのコンテナを更新するには、以下のコマンドを実行します。

* [手順8](#id-7-upload-the-automator-container-to-the-artifact-registry)を繰り返す。
* [手順9](#id-8-deploy-the-automator-service)を繰り返す。

## サポートが必要な場合 <a href="#need-help" id="need-help"></a>

サポートが必要な場合は、**<commander@keepersecurity.com>**&#x307E;でメールでお問い合わせいただくか、[サポートチケット](https://keepersecurity.servicenowservices.com/csm?id=csm_index)を提出ください。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/jp/sso-connect-cloud/device-approvals/automator/google-cloud-with-gcp-cloud-run.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
