Deploy an Ubuntu or Debian Google Cloud Platform server with Terraform
This guide provides the information you need to deploy an Ubuntu or Debian Google Cloud Platform Server with systemd using Terraform. Depending on your target server and enrollment type some topics in this guide may not apply to you, such as if your team's project will not be using Terraform or if you plan to add a different server type to your project. Modify these steps as needed to fit your team or refer to another cloud deployment guide.
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 Google Cloud Platform console. After being created, your new servers should automatically be listed in your team's Advanced Server Access console.
Note: This guide 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 in this guide.
- Download and install Terraform
- Create an Advanced Server Access enrollment token
- Create and save your Google Cloud Platform project ID
- 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
You need the following to deploy a Google Cloud Platform server with Terraform:
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||This is the top-level object that is representing an organization within Advanced Server Access.|
|Advanced Server Access project||This is the authorization-scope of your team, organizing your users, groups, and servers.|
- Download the Terraform installer.
- Unzip the downloaded file and run the executable.
- On the Advanced Server Access dashboard, click Projects.
- Select the project you want to add the server to.
Select the Enrollment tab, then 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, copy the string of characters from the Token field and store it in a safe location.
- Navigate to the Google Cloud Platform console and sign in to your account.
Use the Select a project dropdown at the top of the page to click the New Project button.
- 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 find your project's dashboard, use the Select a project box at the top of the console.
Create a file named terraform.tfvars and add the following lines:
- Replace <project-id> with your Google Cloud Platform 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 the command which terraform to confirm that your terraform path exists. Depending on your platform, the output should look similar to:/Users/user/bin/terraform
- 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.