Prerequisites¶
- Terraform installed on a server will be used to run Terraform commands. Visit Terraform documentation on how to install Terraform
- GCP account with permission to create service accounts
-
Ensure the following cloud service's API is enabled in the GCP project. Visit Valtix Getting Started page on how to enable these services.
- Secret Manager API
- Compute API
- IAM API
- Cloud Resource Manager API
-
This lab example will be run inside the us-central1 region
-
SSH key pair used for login to your compute instance
- To generate SSH key for GCP compute instance, follow this documentation
-
Add the SSH key pair to project metadata. Below gives an overview of the steps. For more details visit GCP documentation
- From the Google Cloud console, go to the Metadata page
- Click on Edit, then click on Add item. A text box opens.
- Add your public key generated in step 3 into the text box
- Click Save
-
Create a Service Account. Please refer to GCP documentation for more details
- Note that this Service Account is used to create necessary component to onboard GCP projects onto Valtix Platform. As part of initial setup, this service account will create 2 additional service accounts, one for Valtix Controller and one for Valtix Gateway. Upon onboarding, most actions will be performed using Valtix Controller role.
-
Below shows the steps to create the Service Account for the purpose of this tutorial
- Search for "Service Account" at the top search bar in Google Cloud console.
- Click on CREATE SERVICE ACCOUNT
- Enter Service account details
-
Grant the following roles to this service account
- Service Account Admin
- Security Admin
- Compute Admin
-
Save the service account credential file. This is needed for this workshop.
-
Clone the GCP-workshop repository. Visit Github documentation on how to clone repository.
- The repository will contain 2 folders: sample_app and valtix-tutorial
- "sample_app" contains Terraform template to deploy sample app to be used in this workshop
- "valtix-tutorial" contains the Terraform template to deploy Valtix security to protect the sample application.
-
Deploy the sample application in the GCP account. This will be referred to as "spoke".
- Navigate to GCP-workshop/sample_app directory that was cloned in previous step
- This Terraform template deploys a compute instance in a subnet in the us-central1 region
- Copy your service account credential file into sample_app folder
-
Modify the variables in terraform.tfvars file
Parameter Description service_account This is the service account credentials that you downloaded in step 5. This should be a .json file. execution_server_ip This is the public IP address of the machine you will use to login to the compute instance from. If you are running everything on your laptop, this would be your laptop's public IP address gcp_project_id This value can be found in your service account credentials. -
Execute
terraform init
- Execute
terraform plan
- Execute
terraform apply
-
A login to Valtix Controller Portal. To obtain an account to Valtix Controller, sign up for our Free Tier
-
Generate Valtix API key.
- Login to Valtix Controller Portal.
- If account setup screen pops up, click on "Skip, I will add it later" to skip the account onboarding. (This will be done through Terraform in this tutorial)
- Click on ADMINISTRATION tab on the top right
- Click on API Keys, then click on Create API Key button
- Enter a name and for Role, select admin_rw
- Save the API key. This will be used in tutorial to run operations in Terraform.
-
Copy Service Account credentials and Valtix API key to GCP-workshop/gcp-tutorial folder