Table of contents

GCP auto scaling and Workload Security

You can set up automatic protection in Workload Security for new GCP VM instances created through GCP managed instance groups (MIGs) to support auto scaling.

Each GCP VM instance created through a MIG must have an agent installed on it. There are two ways that you can do this: you can include a preinstalled agent in the GCP VM instance used to create the instance template, or you can install the agent by including a deployment script in the instance template for the image. There are pros and cons for each option:

  • If you include a pre-installed agent, instances spin up more quickly because there is no need to download and install the agent software. The downside is that the agent software might not be the latest. To work around this issue, you can enable the upgrade on activation.
  • If you use a deployment script to install the agent, it always gets the latest version of the agent software from Workload Security.

Preinstall the agent

If you have a GCP VM instance already configured with an agent, you can use that instance to create the instance template for the MIG. Before creating the instance template, you must deactivate the agent on the GCP VM instance and stop the instance:

dsa_control -r

Each new GCP VM instance created by the MIG needs to have its agent activated and a policy applied to it, if it does not have one already. There are two ways to do this:

  • You can create a deployment script that activates the agent and optionally applies a policy. Then add the deployment script to the GCP instance template so that it is run when a new instance is created. For instructions, see the Install the agent with a deployment script, but omit the section of the deployment script that gets and installs the agent. You only need the dsa_control -a section of the script.

    For the deployment scripts to work, the agent-initiated communication must be enabled in Workload Security. For details, see Activate and protect agents using agent-initiated activation and communication.

  • You can set up an event-based task in the Workload Security console that activates the agent and optionally apply a policy when an instance is launched and the Computer Created (By System) event occurs.

Install the agent with a deployment script

Workload Security provides the ability to generate customized deployment scripts that you can run when GCP VM instances are created. If the GCP VM instance does not contain a preinstalled agent, the deployment script should install the agent, activate it, apply a policy, and optionally assign the machine to a computer group and relay group.

You can generate deployment scripts to automate the agent installation using the Workload Security API. For more information, see Generate a deployment script.

In order for the deployment script to work:

The displayed code is an example of a generated deployment script. Depending on your region, the deployment script you generate might be different.

To set up automatic protection for instances using a deployment script:

  1. Sign in to the Workload Security console.
  2. From the Support menu at the top right, select Deployment Scripts.
  3. Select your platform.
  4. Select Activate Agent automatically after installation.
  5. Select the appropriate Security Policy, Computer Group and Relay Group.
  6. Click Copy to Clipboard.
  7. Go to the GCP instance templates, expand Management, security, disks, networking, sole tenancy and paste the deployment script into Startup script.

    GCP intance templates with Startup script

Delete instances from Workload Security as a result of GCP MIGs

After you have added a GCP account in Workload Security, instances that no longer exist in GCP as a result of Managed Instance Group are automatically removed from Workload Security.

See Add a Google Cloud Platform account for details on adding a GCP account.