目次
このページのトピック

Google Cloud Platformコネクタを追加

SDK を使用すると、Google Cloud Platform(GCP)コネクタを追加し、GCPから Workload Securityに仮想マシン(VM)を同期できます。概要については、 Google Cloud Platformサービスアカウントの作成を参照してください。

前提条件:あなたは必要ですGCPサービスアカウントを準備する使用するWorkload Security。

GCPコネクタを追加するには、次の手順を実行します。

  1. GcpConnector オブジェクトを作成し、名前とサービスアカウントを設定します。名前とサービスアカウントは必須のプロパティです。名前の長さは255文字以内で指定してください。
  2. GcpConnectorsApi オブジェクトを作成し、それを使用して Workload Securityに GcpConnector を作成します。

設定可能なプロパティについては、 APIレファレンス/参照情報の[コンピュータの作成]操作を参照してください。

ソースを表示

def create_gcp_connector(api, configuration, api_version, api_exception, name, service_account):
   api_instance = api.GCPConnectorsApi(api.ApiClient(configuration))
   gcp_connector = api.GCPConnector()
   gcp_connector.name = name
   gcp_connector.service_account = service_account

  api_response = api_instance.create_gcp_connector(gcp_connector, api_version)
  return api_response

GCPコネクタの同期処理を送信する

GCPコネクタを作成したら、同期を開始するようGCPコネクタに指示できます。

同期アクションを送信するには、次の高度な手順を使用します。

  1. Action オブジェクトを作成し、そのタイプを「同期」に設定します。タイプは必須プロパティです。
  2. GcpConnectorActionsApi オブジェクトを作成し、それを使用して特定のGCPコネクタIDによる処理を Workload Securityに送信します。

ソースを表示

def create_gcp_connector_action(api, configuration, api_version, api_exception, gcp_connector_id):
   api_instance = api.GCPConnectorActionsApi(api.ApiClient(configuration))
   gcp_connector_action = api.Action()
   gcp_connector_action.type = "synchronize"

  api_response = api_instance.create_gcp_connector_action(gcp_connector_id, gcp_connector_action, api_version)
  return api_response