Search code examples
google-cloud-platformgoogle-cloud-dlp

Multiple actions provided from the API for in GCP's DLP does not work


Goal: Read CSV file from Cloud Storage bucket and publish the findings to Pub/Sub and write findings to BigQuery

Issue: I am able to do this using the Console, but when I try to do it using the API, only of the actions work. Following is a sample from my code:

'actions': [{
          'pub_sub': {
              'topic':
                  'projects/{project_id}/topics/{topic_id}'.format(
                      project_id=PROJECT_ID, topic_id=PUB_SUB_TOPIC)
          },
          
        'save_findings': {
            "output_config": {
                "table": {
                    "project_id": PROJECT_ID,
                    "dataset_id": DATASET_ID,
                    "table_id": TABLE_ID
               
                }
            }
        }
      }]

In the above code, only the option of publishing to BigQuery will work as it is written later. I came across the documentation given at this link, which says 'Union field action can be only one of the following'

Questions: Is my understanding correct, that using the API only one of the actions is possible (write to the database or publish to pub/sub etc)?

If Yes, is there going to be support for multiple actions using the APIs similar to the console?

Appendix: PFA screenshot of the configuration of a DLP job using the console having multiple actionsenter image description here


Solution

  • Your objects are not nested quite right.

    "actions": [
      {
        "pubSub": {
          "topic": "mytopic"
        }
      },
      {
        "saveFindings": {
          "outputConfig": {
            "outputSchema": "BIG_QUERY_COLUMNS",
            "table": {
              "datasetId": "",
              "tableId": "",
              "projectId": ""
            }
          }
        }
      }
    ]