Deploy a GCP server with Terraform
This topic explains how to deploy an Ubuntu or Debian Google Cloud Platform (GCP) Server with systemd using Terraform. You may need to modify this process to fit your specific needs.
Creating a cloud server with Terraform means installing the Terraform tool on your personal machine and using an Access ID, enrollment token, and secret ID to create servers on the GCP console. After being created, your new servers should appear automatically within the Advanced Server Access dashboard
This topic uses the ScaleFT Starter Kit as its Terraform module. View the kit on GitHub. For your setup, use your company's Terraform repository for your production environment. The configuration values in your terraform.tfvars file should be similar to those outlined later in this topic.
- Download and install Terraform
- Create an Advanced Server Access enrollment token
- Create a GCP project
- Create and configure your Terraform.tfvars file
- Enable the Google Compute Engine API for your project
- Run Terraform commands to create your server
- Next steps
Google Cloud Platform
|Google Cloud Platform account||A Google Cloud Platform account is needed to access the GCP console, where you create virtual machines for your team.|
Advanced Server Access
|Advanced Server Access team||The top-level object that represents an Okta org within Advanced Server Access.|
|Advanced Server Access project||The authorization-scope of your team, organizing your users, groups, and servers.|
- Download the Terraform installer. See the Terraform website.
- Unzip the downloaded file and run the unix executable.
- From the Advanced Server Access dashboard, click Projects.
- Select the project you want to add the server to.
Go to the Enrollment tab and click Create Enrollment Token.
Note: You can use the same enrollment token every time you add a server to your team. If you have already created an enrollment token, skip this step.
- Enter a description for the token, then click Submit.
After the token has been successfully created, note the string of characters from the Token field and store them in a safe location.
- Navigate to the Google Cloud Platform console and sign in to your account.
- From the Select a project menu, click New Project.
- Create a new name for your project and use the Location field to set its parent organization or folder .
- Click Create when you've finished creating your project.
- From the dashboard of your new project, copy the Project ID number from the Project Info section and store it in a safe location.
Note: To locate the project dashboard, use the Select a project field at the top of the console.
- Create a file named terraform.tfvars and add the following text:
- Replace <project-id> with your GCP project ID.
- Replace <enrollment-token> with your Advanced Server Access enrollment token.
- Save the file and place it in your Terraform module.
- Navigate to your project's dashboard in the Google Cloud Platform console.
- In the left sidebar, use the APIs & Services tab to click the Dashboard option.
- Click ENABLE APIS AND SERVICES under the search bar to navigate to the API Library.
- Under Category on the left side of the page, click Compute.
- Select the tab for Compute Engine API.
- Click Enable.
- In your machine's console, run which terraform to confirm that your Terraform path exists.
Depending on your platform, the output should look something like:
- Confirm that you are in your Terraform module, then run terraform init
- Confirm that the information in terraform.tfvars is correct by running terraform plan. If you receive any errors, troubleshoot as needed before proceeding.
- Run terraform apply to begin creating your servers.
Enter yes if prompted for approval.
Confirm that your new servers are listed in Advanced Server Access before you attempt to connect to them.