vmware-archive / terraforming-gcp

use terraform, deploy yourself a pcf
Apache License 2.0
71 stars 87 forks source link
gcp ops-manager terraform

DEPRECATION

This repo is going to be archived. The terraform templates that should be used for deploying an Ops Manager, PAS and/or PKS, can be found at https://github.com/pivotal/paving No PRs or Issues will be responded to here.

Terraforming GCP

How Does One Use This?

Please note that the master branch is generally unstable. If you are looking for something "tested", please consume one of our releases.

What Does This Do?

You will get a booted ops-manager VM plus some networking, just the bare bones basically.

Looking to setup a different IAAS

We have have other terraform templates to help you!

This list will be updated when more infrastructures come along.

Prerequisites

Your system needs the gcloud cli, as well as terraform:

brew update
brew install Caskroom/cask/google-cloud-sdk
brew install terraform

Are you using Platform Automation?

Be sure to skip the creation of the Ops Manager VM. Do not include the vars listed here. If you create your Ops Manager using terraform, you will not be able to manage it with Platform Automation.

Deployment of the infrastructure is still required.

Deploying Infrastructure

Depending if you're deploying PAS, PKS or Control Plane you need to perform the following steps:

  1. cd into the proper directory:
  2. Create terraform.tfvars file
  3. Run terraform apply:
    terraform init
    terraform plan -out=plan
    terraform apply plan

Notes

You will need a key file for your service account to allow terraform to deploy resources. If you don't have one, you can create a service account and a key for it:

gcloud iam service-accounts create ACCOUNT_NAME --display-name "Some Account Name"
gcloud iam service-accounts keys create "terraform.key.json" --iam-account "ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com"
gcloud projects add-iam-policy-binding PROJECT_ID --member 'serviceAccount:ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com' --role 'roles/owner'

You will need to enable the following Google Cloud APIs:

Var File

Copy the stub content below into a file called terraform.tfvars and put it in the root of this project. These vars will be used when you run terraform apply. You should fill in the stub values with the correct content.

env_name         = "some-environment-name"
project          = "your-gcp-project"
region           = "us-central1"
zones            = ["us-central1-a", "us-central1-b", "us-central1-c"]
dns_suffix       = "gcp.some-project.cf-app.com"
opsman_image     = "ops-manager-2-10-build-48"

buckets_location = "US"

ssl_cert = <<SSL_CERT
-----BEGIN CERTIFICATE-----
some cert
-----END CERTIFICATE-----
SSL_CERT

ssl_private_key = <<SSL_KEY
-----BEGIN RSA PRIVATE KEY-----
some cert private key
-----END RSA PRIVATE KEY-----
SSL_KEY

service_account_key = <<SERVICE_ACCOUNT_KEY
{
  "type": "service_account",
  "project_id": "your-gcp-project",
  "private_key_id": "another-gcp-private-key",
  "private_key": "-----BEGIN PRIVATE KEY-----another gcp private key-----END PRIVATE KEY-----\n",
  "client_email": "something@example.com",
  "client_id": "11111111111111",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://accounts.google.com/o/oauth2/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/"
}
SERVICE_ACCOUNT_KEY

Var Details

DNS Records

Isolation Segments (optional)

Cloud SQL Configuration (optional)

Ops Manager (optional)

PAS (optional)

PAS Cloud Controller's Google Cloud Storage Buckets (optional)

Internetless (optional)

Running

Note: please make sure you have created the terraform.tfvars file above as mentioned.

Tearing down environment

Note: This will only destroy resources deployed by Terraform. You will need to clean up anything deployed on top of that infrastructure yourself (e.g. by running om delete-installation)

terraform destroy