Deploy an Ubuntu/Debian Google Cloud Platform Server with Terraform

Overviews

This guide provides the information you need to deploy an Ubuntu/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 your steps as needed to fit your team or refer to a different guide on the cloud deployments page.

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 Amazon Web Services console. Once created, your new servers should list automatically within your team's console in Advanced Server Access.

Note: For this guide we used the ScaleFT ubuntu-basic StarterKit provided by Okta on Github as our terraform module. For your setup, use your company's Terraform repo for you production environment instead, though you should still end up with similar configuration values in your terraform.tfvars file.

Prerequisites

You need the following permissions you need to deploy an Amazon Web Services Server with Terraform

Google Cloud Platform

Requirement Description
Google Cloud Platform Account A Google Cloud Platform account is needed to access the AWS Management console, where you can create a Virtual Machine for your team.

Advanced Server Access

Requirement Description
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.

Procedures

Deploying an Amazon Web Services Server with Terraform can be done in the following steps:

  1. Download and Install Terraform
  2. Create an Advanced Server Access Enrollment token
  3. Create and Save your Google Cloud Platform Project ID
  4. Create and Configure your terraform.tfvars file
  5. Enable the Google Compute Engine API for your Project
  6. Run Terraform Commands to Create your Server

Download and Install Terraform

  1. Download the Terraform installer from the official site

  2. Unzip the downloaded file and run the unix executable

Create an Advanced Server Access Enrollment token

  1. Within the Advanced Server Access console, select the Projects header at the top of the page
  2. Select the project you want to add your server to
  3. Click the Enrollment tab within that Project's console and click the Create an Enrollment Token button

    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.

  4. Create a description for your new Enrollment token if prompted, and click Submit
  5. Once the token has been successfully created, copy the string of characters in the Token field and store it in a safe location

Create and Save your Google Cloud Platform Project ID

  1. Navigate to the Google Cloud Platform console and log in to your account
  2. Use the Select a project dropdown at the top of the page to click the New Project button

  3. Create a new name for your project and use the Location field to set it's parent organization or folder
  4. Click the Create button when you are finished creating your project
  5. In your new Project's Dashboard, copy the Project ID number listed in the Project Info section and store it in a safe location

    Note: To find your project's dashboard, use the Select a project dropdown at the top of the console

Create and Configure your Terraform.tfvars file

  1. Open your machine's console and run the ls -a command to see the folders in your home directory

  2. Create a file named terraform.tfvars and add the following lines:

    project: "<project-id>"
    enrollment_token:"<enrollment-token>"
  3. Replace <project-id> with the Project ID you copied from the Create and Save your Google Cloud Platform Project ID section
  4. Replace <enrollment-token> with the characters you copied from the Create an Advanced Server Access Enrollment Token section
  5. Save the file and place it in your Terraform module

Enable the Google Compute Engine API for your Project

  1. Navigate to your project's dashboard in the Google Cloud Platform console

  2. In the left sidebar, use the APIs & Services tab to click the Dashboard option
  3. Click ENABLE APIS AND SERVICES under the search bar to navigate to the API Library
  4. Under Category on the left side of the page, click the Compute option
  5. Select the tab for Compute Engine API
  6. Click the Enable button

Run Terraform Commands to Create Your Server

  1. In your machine's console, run the which terraform command to confirm that your terraform path exists. Depending on your platform, the output should look something like the following: 

    /Users/user/bin/terraform

  2. Confirm that you are in your Terraform module before running the terraform init command to initialize the terraform program
  3. Confirm that the information you saved to you terraform.tfvars file is correct by running the terraform plan command. If you receive any errors, troubleshoot as needed before proceeding
  4. Run terraform apply to begin creating your servers. If prompted for approval, type yes and press return on your keyboard

Navigate to the Advanced Server Access console and confirm that your new servers are listed before attempting to SSH into your team's servers.

Top