Skip to content

Overview

This directory contains Terraform configuration files that let you deploy the system project. This example is a good entry point for testing the reference architecture and learning how it can be incorportated into your own infrastructure as code processes.

Architecture

architecture-per-project

For an explanation of the components of the sandboxes reference architecture and the interaction flow, read the main Architecture section.

Before you begin

In this section you prepare a folder for deployment.

  1. Open the Cloud Console
  2. Activate Cloud Shell \ At the bottom of the Cloud Console, a Cloud Shell session starts and displays a command-line prompt.

  3. In Cloud Shell, clone this repository

    git clone https://github.com/GoogleCloudPlatform/platform-engineering.git
    
  4. Export variables for the working directories

    export SANDBOXES_DIR="$(pwd)/reference-architectures/examples/gcp-sandboxes"
    export SANDBOXES_CLI="$(pwd)/reference-architectures/examples/cli"
    

Preparing the Sandboxes Folder

In this section you prepare your environment for deploying the system project.

  1. Go to the Manage Resources page in the Cloud Console in the IAM & Admin menu.

  2. Click Create folder, then choose Folder.

  3. Enter a name for your folder. This folder will be used to contain the system and sandbox projects.

  4. Click Create

  5. Copy the folder ID from the Manage resources page, you will need this value later for use as Terraform variable.

Deploying the reference architecture

  1. Set the project ID and region in the corresponding Terraform environment variables

    export TF_VAR_billing_account="<your billing account id>"
    export TF_VAR_sandboxes_folder="folders/<folder id from step 5>"
    export TF_VAR_system_project_name="<name for the system project>"
    
  2. Change directory into the Terraform example directory and initialize Terraform.

    cd "${SANDBOXES_DIR}"
    terraform init
    
  3. Apply the configuration. Answer yes when prompted, after reviewing the resources that Terraform intends to create.

    terraform apply
    

Creating a sandbox

Now that the system project has been deployed, create a sandbox using the example cli.

  1. Change directory into the example command-line tool directory

    cd "${SANDBOXES_DIR}"
    
  2. Install there required Python libraries

    pip install -r requirements.txt
    
  3. Create a Sandbox using the cli

    python ./sandbox.py create \
    --system="<name of your system project>" \
    --project_id="<name of the sandbox to create>"
    

Next steps

Your sandboxes infrastructure is ready, you may continue to use the example cli to create and delete sandboxes. At this point it is recommended that you: