This configuration provisions infrastructure on Amazon Web Services and Google Cloud Platform to demonstrate the cross-provider provisioning functionality available in Terraform.
For AWS: aws.tf uses modules from the Terraform Module Registry to provision a VPC, the necessary networking components and an auto scaling group across multiple AZs. The associated launch configuration launches three instances of the latest Amazon Linux AMI then installs httpd and a custom landing page via a user data script.
For Google: google.tf uses locally defined resources to provision a Managed Instance Group in the default VPC and network, spanning multiple zones. The group configuration launches three VMs running CentOS 7 then installs httpd and a custom landing page via a startup script.
The regions chosen for this demo are hardcoded to AWS eu-west-1 and GCP us-west1
20 minutes.
-
An AWS Access Key and AWS Secret Access Key should be configured on the host running this Terraform configuration. Environment variables are one way to achieve this, eg:
export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
See the 'Configuring the AWS CLI' documentation for guidance
-
Google credentials should be present on the host running this Terraform configuration. Environment variables are one way to acieve this, eg:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/google_credentials.json
See the 'Getting Started with Authentication' GCP documentation for guidance
-
Initialise Terraform to download the required dependencies:
terraform init
-
Execute a plan of the Terraform configuration:
terraform plan -out=1.tfplan
-
Execute an apply of the Terraform configuration:
terraform apply 1.tfplan
To destroy the resources provisioned in this example run:
terraform plan -out=d.tfplan -destroy
terraform apply d.tfplan