Google Cloud Platform + Infrastructure as Code


                              

This is a project to generate a Infrastructure in Google Cloud Platform. This works with many modules made with Terraform to set all configuration.


Requirements

  • Google Cloud Platform account
  • Create a project
  • Create a Service Account - and get the credentials JSON
  • Create on google-cloud-storage (optional)
    • bucket to storage .tfstate
    • set backend name in providers.tf

How to run

To init

terraform init -upgrade

To run

terraform apply --auto-approve

To destroy

terraform destroy --auto-approve

To connect on cluster

gcloud container clusters get-credentials <CLUSTER_NAME> --region us-central1 --project <PROJECT_NAME>

To format code

terraform fmt -recursive

To validate code

terraform validate


Inputs

  • project_id
    • The Project Id
  • credentials
    • JSON file with credentials
  • zone
  • region

Outputs

  • db_info
    • public_ip_address
    • database
    • user
    • password
    • sensitive = true
  • cluster_info
    • cluster_ca_certificate
    • cluster_auth
    • cluster_endpoint
    • sensitive = true