> For the complete documentation index, see [llms.txt](https://docs.keeper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keeper.io/sso-connect-cloud/jp/device-approvals/automator/google-cloud-with-gcp-cloud-run.md).

# 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>

続いて、この新しいプロジェクトで **\[プロジェクトを選択]** をクリックします。

### 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` です。このProject IDは後続のコマンドで使用されます。

### 3. 請求先アカウントをリンク

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

### 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. Artifact Registryを有効化 <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にデプロイします。このサービスは、内部アクセスとロードバランサのみに制限されています。

{% code overflow="wrap" %}

```
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"
```

{% endcode %}

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

* `[PROJECT_ID]` は手順2のProject IDに置き換えます
* `XXX` は手順4で作成した構成キーに置き換えます
* `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にリンクします。

```bash
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サービスにリンクするバックエンドサービスが作成されます。

```bash
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がバックエンドサービスに接続されます。

```bash
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レコードを設定します。

#### Aレコード構成の例

| タイプ | 名前                       | 値             | 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オートメーターサービスは、[イングレス要件](/sso-connect-cloud/jp/device-approvals/automator/ingress-requirements.md)のページに記載のとおり、必要なIPのみに制限する必要があります。

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

{% code overflow="wrap" %}

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

{% endcode %}

この手順では、[イングレス要件](/sso-connect-cloud/jp/device-approvals/automator/ingress-requirements.md)のページに記載のKeeper米国データセンターのIPを接続します。必要に応じて追加のルールを作成してください。

{% code overflow="wrap" %}

```
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
```

{% endcode %}

* オートメーターサービスをテストできるように、外部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をインストールします。バイナリインストーラーを含むインストール手順については、[こちらのページ](/keeperpam/jp/commander-cli/commander-installation-setup.md)をご参照ください。

コマンダーをインストールした後、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 %}

{% hint style="info" icon="pencil-line" %}
`gcpautomator.lurey.com` を[手順16](#id-15-reserve-a-static-ip-address-and-assign-dns-entry)で作成したドメイン名に置き換えてください。
{% endhint %}

続いて、キーを交換します。オートメーター公開キーで暗号化されたエンタープライズ秘密キーがオートメーターへ渡されます。

```
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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
