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

Google Cloud Platformコネクタを追加

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

開始する前に、Workload Securityで使用する GCPサービスアカウントを準備 する必要があります。

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 オブジェクトを作成し、タイプを synchronizeに設定します。このタイプは必須プロパティです。 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