There’s a wealth of existing modules for AWS, GCP and Azure on registry.terraform.io (Also read, reusable modules in Terraform, getting started )

Look for something of interest to you here : https://registry.terraform.io/browse/modules.

Once you locate the module , there should be a ‘usage’ instruction. Basically, here’s what you need to do to use that module in your own source code.

  1. Explicitly spell out the source of your module  – as shown below. (It will automatically reach out over the internet to this public repo)
  2. Pass in values for all the REQUIRED variables, inside the module block, as shown below.
module "project-factory" {

  source  = "terraform-google-modules/project-factory/google"

  version = "9.2.0"

  billing_account = "account id here"

  budget_alert_pubsub_topic = `projects/{project_id}/topics/{topic_id}`

  budget_amount = 20

  name = "test_budget_alerts"

  org_id = "your_org_id here"

  vpc_service_control_perimeter_name = "test_project_permiter"

}

Summary

That’s really all there is to it.  Instead of writing all this code from scratch, you simply reference the publicly available module. And pass in the required (and optional ) variable values.

A note on security 

If you leverage a module provided by AWS or Google or Microsoft, you can rest assured that they have passed certain security and coding standards. However, there are also ‘unverified’ modules out there on the public registry. Use these with caution.

Next Steps?

Need help with your Terraform or PowerShell or other automation effort? Set up a free consultation – Start the conversation today.