# Deploying the image

* You will receive a template file from Vectra. Save both to a locally accessible directory from where you will run the gcloud deployment command.
  * `<VERSION>_example.tf` - Save a new copy of this and edit it to customize the deployment for your needs.
* This template contains instructions and syntax for the deployment command.

{% hint style="warning" %}

* Do NOT change the `source` argument. Only use the source specified in the `<VERSION>_example.tf` file.
* Vectra recommends that you do not have any other files in the directory from which you run the deployment command. The gcloud command could run more slowly or error if there are other terraform files in the directory.
  {% endhint %}

- Below is a sample edited `<VERSION>_example.tf` file.
  * In this case, the file was called `9.7_example.tf` .

```
####################################################################################
# This configuration deploys resources necessary for the Vectra Sensor product.    #
#                                                                                  #
# This template can be deployed with the `gcloud` commandline tool.                #
# Please save this file into an empty directory of your choosing.                  #
# Before deploying the template, update the arguments in this file to              #
# the desired values. The comment above each argument should explain the argument. #
#                                                                                  #
# Then, from within the directory, run: (replacing the placeholders in <>)         #
# $ gcloud infra-manager deployments apply \                                       #
#  --service-account <your_service_account> \                                      #
#  --project <your_project> \                                                      #
#  projects/<your_project>/locations/<your_region>/deployments/<deployment_name> \ #
#  --local-source=./                                                               #
#                                                                                  #
# You may also use Terraform on its own if you are familiar with using Terraform.  #
#                                                                                  #
####################################################################################
 
# the label of the module ("my_test_brain") is only used internally by terraform, 
# so you can set it to anything 
module "my_test_sensor" {
  source = "https://cognito-public-deployment-tools.s3.us-west-2.amazonaws.com/GCPSensor/9.7.zip"
  # Name of the resources to be created (will be appended to; e.g. the name `vectra-brain` will create `vectra-brain-vm` and `vectra-brain-os`)
  name = "sensor-resources"
  # IP address or hostname of the brain to register with
  brain-ip = "192.0.2.16"
  # Token for registration with headend, 32 letters long
  registration-token = "pxthwxzgzlxpyqxqqygvcdkzkbmnzrzp"
  # SSH public key for vectra user (format: ssh-rsa XXXX)
  ssh-key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAtruncatedforvisibilityreasons"
  # Project in which to deploy (project ID)
  project = "example-dev"
  # Region in which to deploy
  region = "us-east4"
  # Zone in which to deploy (actual zone, not just region)
  zone = "us-east4-a"
  # Size of sensor VM, must be one of e2-standard-2, e2-standard-4, e2-standard-8, e2-standard-16, e2-standard-32
  size = "n2-highmem-96"
  # Base image provided by Vectra
  image = "projects/vectra-shared-images/global/images/vectra-gcp-embryo-9-6"
  # Management subnetwork for VM (subnetwork selflink, such as projects/PROJ/regions/REG/subnetworks/SUBNET)
  subnetwork = "projects/example-dev/regions/us-east4/subnetworks/mgt"
  # Traffic subnetwork for VM (subnetwork selflink, such as projects/PROJ/regions/REG/subnetworks/SUBNET)
  traffic-subnetwork = "projects/example-dev/regions/us-east4/subnetworks/traffic"
  # Traffic network for VM (network selflink, such as projects/PROJ/global/networks/NET)
  traffic-network = "projects/example-dev/global/networks/traffic"
}
```

* After editing the `<VERSION>_example.tf` file you are now ready to deploy the Sensor.
* Perform the deployment using the `gcloud infra-manager deployments apply` command. Be sure to specify the service account created for Infrastructure Manager.
* If the deployment fails, you can view the logs by going to Infrastructure Manager in the Google Cloud console, and clicking on the deployment that failed. (The example shown is for a Brain, but this screen looks the same for a Sensor.)

<figure><img src="https://4227135129-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHJ1ltuWFvsArFWtevnRn%2Fuploads%2FIJwYrFgLq95lcokKyj5e%2Fimage.png?alt=media&#x26;token=1dccf5aa-9ba5-42ba-82da-264d083927ae" alt=""><figcaption></figcaption></figure>

* For example, this deployment failed because the image was not yet shared with the example customer:

<figure><img src="https://4227135129-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHJ1ltuWFvsArFWtevnRn%2Fuploads%2FYxtkD6iFUzJBnmWTUNMQ%2Fimage.png?alt=media&#x26;token=8b72fe83-240b-4893-a337-e00c68515579" alt=""><figcaption></figcaption></figure>

* If you have failed deployments for any reason, you can simply delete them by name as in this example:

```
$ gcloud infra-manager deployments delete --project example-dev projects/example-dev/locations/us-east4/deployments/vectra-sensor 
You are about to delete deployment [vectra-sensor] 
  
Do you want to continue (Y/n)?  y 
  
Delete request issued for: [vectra-sensor] 
Waiting for operation [projects/example-dev/locations/us-east4/operations/operation-1764970842168-6453b4c161c8d-963ce3b4-a67084ef] to complete...done.                                                                                                                               
Deleted deployment [vectra-sensor].
```

* You can list deployments as follows:
  * `gcloud infra-manager deployments list -–project <PROJECT> --location <REGION>`
* To see resources created with a deployment, you can click on the **Resources** tab on the deployment page in the GCP console.

{% hint style="success" %}
Congratulations!! You have now deployed the Sensor in GCP and can move on to [Pairing your GCP vSensor with your Brain](https://docs.vectra.ai/deployment/ndr-virtual-cloud-appliances/gcp-vsensor/pairing-gcp-vsensors) as the next step in your overall GCP vSensor deployment.
{% endhint %}
