• Stars
    star
    138
  • Rank 264,508 (Top 6 %)
  • Language HCL
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Executes Google Cloud CLI commands within Terraform

terraform-google-gcloud

This module allows you to use gcloud, gsutil, any gcloud component, and jq in Terraform. Sometimes, there isn't Terraform GCP support for a particular feature, or you'd like to do something each time Terraform runs (ie: upload a file to a Kubernetes pod) that lacks Terraform support.

This module does not create any resources on GCP itself, rather exposes the GCP SDK to you for usage in null resources & external data resources.

Usage

Basic usage of this module is as follows:

module "gcloud" {
  source  = "terraform-google-modules/gcloud/google"
  version = "~> 2.0"

  platform = "linux"
  additional_components = ["kubectl", "beta"]

  create_cmd_entrypoint  = "gcloud"
  create_cmd_body        = "version"
  destroy_cmd_entrypoint = "gcloud"
  destroy_cmd_body       = "version"
}

Functional examples are included in the examples directory.

The jq binary is also included in this module so you can use it as well for either of your create_cmd_entrypoint or destroy_cmd_entrypoint values.

Downloading

By default, this module assumes you already have gcloud installed in your $PATH.

If you need to run Terraform in environments without a gcloud binary available, you can override this behavior by setting the skip_download variable to false.

You can also override the behavior by setting the GCLOUD_TF_DOWNLOAD environment variable. This environment variable will override all other settings. Setting it to never will never gcloud download and setting it to always will always download gcloud.

Inputs

Name Description Type Default Required
additional_components Additional gcloud CLI components to install. Defaults to none. Valid value are components listed in gcloud components list list(string) [] no
create_cmd_body On create, the command body you'd like to run with your entrypoint. string "info" no
create_cmd_entrypoint On create, the command entrypoint you'd like to use. Can also be set to a custom script. Module's bin directory will be prepended to path. string "gcloud" no
create_cmd_triggers List of any additional triggers to re-run the create command execution when either of values in the maps change. Some keys are reserved and will be overwritten if specified in this option. (eg. md5, arguments, download_gcloud_command, download_jq_command, etc. See details in the source.) map(any) {} no
destroy_cmd_body On destroy, the command body you'd like to run with your entrypoint. string "info" no
destroy_cmd_entrypoint On destroy, the command entrypoint you'd like to use. Can also be set to a custom script. Module's bin directory will be prepended to path. string "gcloud" no
enabled Flag to optionally disable usage of this module. bool true no
gcloud_download_url Custom gcloud download url. Optional. string "" no
gcloud_sdk_version The gcloud sdk version to download. string "434.0.0" no
jq_download_url Custom jq download url. Optional. string "" no
jq_version The jq version to download. string "1.6" no
module_depends_on List of modules or resources this module depends on. list(any) [] no
platform Platform CLI will run on. Defaults to linux. Valid values: linux, darwin string "linux" no
service_account_key_file Path to service account key file to run gcloud auth activate-service-account with. Optional. string "" no
skip_download Whether to skip downloading gcloud (assumes gcloud is already available outside the module) bool true no
upgrade Whether to upgrade gcloud at runtime bool true no
use_tf_google_credentials_env_var Use GOOGLE_CREDENTIALS environment variable to run gcloud auth activate-service-account with. Optional. bool false no

Outputs

Name Description
bin_dir The full bin path of the modules executables
create_cmd_bin The full bin path & command used on create
destroy_cmd_bin The full bin path & command used on destroy
downloaded Whether gcloud was downloaded or not
wait An output to use when you want to depend on cmd finishing

Requirements

These sections describe requirements for using this module.

Software

The following dependencies must be available:

Service Account

A service account must be created, along with a key, to use this module. The service account must have the proper IAM roles for whatever commands you're running with this module.

APIs

A project is not required to host resources of this module, since this module does not create any resources.

However you will likely need a project for your service account and any resources you'd like to interact with while using this module.

Contributing

Refer to the contribution guidelines for information on contributing to this module.

More Repositories

1

terraform-example-foundation

Shows how the CFT modules can be composed to build a secure cloud foundation
HCL
1,211
star
2

terraform-google-kubernetes-engine

Configures opinionated GKE clusters
HCL
1,131
star
3

terraform-google-project-factory

Creates an opinionated Google Cloud project by using Shared VPC, IAM, and Google Cloud APIs
HCL
826
star
4

terraform-google-network

Sets up a new VPC network on Google Cloud
HCL
411
star
5

terraform-google-lb-http

Creates a global HTTP load balancer for Compute Engine by using forwarding rules
HCL
315
star
6

terraform-docs-samples

Terraform samples intended for inclusion in cloud.google.com
HCL
290
star
7

terraform-google-sql-db

Creates a Cloud SQL database instance
HCL
263
star
8

terraform-google-vm

Provisions VMs in Google Cloud
HCL
220
star
9

terraform-google-bootstrap

Bootstraps Terraform usage and related CI/CD in a new Google Cloud organization
HCL
210
star
10

terraform-google-vault

Deploys Vault on Compute Engine
HCL
192
star
11

terraform-google-bigquery

Creates opinionated BigQuery datasets and tables
HCL
190
star
12

terraform-google-iam

Manages multiple IAM roles for resources on Google Cloud
HCL
189
star
13

terraform-google-github-actions-runners

Creates self-hosted GitHub Actions Runners on Google Cloud
HCL
181
star
14

terraform-google-cloud-storage

Creates one or more Cloud Storage buckets and assigns basic permissions on them to arbitrary users
HCL
168
star
15

terraform-google-container-vm

Deploys containers on Compute Engine instances
HCL
155
star
16

terraform-google-bastion-host

Generates a bastion host VM compatible with OS Login and IAP Tunneling that can be used to access internal VMs
HCL
126
star
17

terraform-google-service-accounts

Creates one or more service accounts and grants them basic roles
HCL
115
star
18

docs-examples

Open in Cloud Shell Examples for the Google provider docs
HCL
110
star
19

cloud-foundation-training

HCL
96
star
20

terraform-google-lb

Creates a regional TCP proxy load balancer for Compute Engine by using target pools and forwarding rules
HCL
92
star
21

terraform-google-gke-gitlab

Installs GitLab on Kubernetes Engine
HCL
90
star
22

terraform-google-vpn

Sets up a Cloud VPN gateway
HCL
88
star
23

terraform-google-log-export

Creates log exports at the project, folder, or organization level
HCL
88
star
24

terraform-google-pubsub

Creates Pub/Sub topic and subscriptions associated with the topic
HCL
85
star
25

terraform-google-lb-internal

Creates an internal load balancer for Compute Engine by using forwarding rules
HCL
81
star
26

terraform-google-org-policy

Manages Google Cloud organization policies
HCL
80
star
27

terraform-google-cloud-nat

Creates and configures Cloud NAT
HCL
80
star
28

terraform-google-startup-scripts

Provides a library of useful startup scripts to embed in VMs
Shell
73
star
29

terraform-google-k8s-gce

Modular Kubernetes Cluster for GCE using Terraform
HCL
71
star
30

terraform-google-scheduled-function

Sets up a scheduled job to trigger events and run functions
Go
71
star
31

terraform-google-slo

Creates SLOs on Google Cloud from custom Stackdriver metrics capability to export SLOs to Google Cloud services and other systems
HCL
63
star
32

terraform-google-address

Manages Google Cloud IP addresses
Shell
60
star
33

terraform-google-vpc-service-controls

Handles opinionated VPC Service Controls and Access Context Manager configuration and deployments
HCL
60
star
34

terraform-google-cloud-dns

Creates and manages Cloud DNS public or private zones and their records
HCL
57
star
35

terraform-google-event-function

Responds to logging events with a Cloud Function
HCL
52
star
36

terraform-google-composer

Manages Cloud Composer v1 and v2 along with option to manage networking
HCL
52
star
37

terraform-google-module-template

Provides a template for creating a Cloud Foundation Toolkit Terraform module
HCL
52
star
38

terraform-google-cloud-router

Manages a Cloud Router on Google Cloud
HCL
48
star
39

terraform-google-folders

Creates several Google Cloud folders under the same parent
HCL
47
star
40

terraform-google-cloud-operations

Manages Cloud Logging and Cloud Monitoring
HCL
47
star
41

terraform-google-kms

Allows managing a keyring, zero or more keys in the keyring, and IAM role bindings on individual keys
HCL
44
star
42

terraform-google-memorystore

Creates a fully functional Google Memorystore (redis) instance
HCL
43
star
43

terraform-google-group

Manages Google Groups
HCL
40
star
44

terraform-google-dataflow

Handles opinionated Dataflow job configuration and deployments
HCL
34
star
45

terraform-google-jenkins

Creates a Compute Engine instance running Jenkins
HCL
31
star
46

terraform-google-sap

Deploys SAP products
HCL
31
star
47

terraform-google-cloud-datastore

Manages Datastore
HCL
22
star
48

terraform-google-gsuite-export

Creates a Compute Engine VM instance and sets up a cronjob to export GSuite Admin SDK data to Cloud Logging on a schedule
HCL
18
star
49

terraform-google-utils

Gets the short names for a given Google Cloud region
HCL
14
star
50

terraform-google-data-fusion

Manages Cloud Data Fusion
HCL
14
star
51

terraform-google-endpoints-dns

This module creates a DNS record on the .cloud.goog domain using Cloud Endpoints.
HCL
11
star
52

terraform-google-healthcare

Handles opinionated Google Cloud Healthcare datasets and stores
HCL
11
star
53

terraform-google-migrate

Terraform module to help with migrating VMs to GCP.
HCL
10
star
54

terraform-example-shared-services

Example of using CFT to build a Shared Services architecture on GCP
HCL
6
star
55

terraform-google-datalab

Creates DataLab instances with support for GPU instances
HCL
6
star
56

terraform-google-secret

This Terraform module makes it easier to manage to manage secrets for your Google Cloud environment, such as api keys, tokens, etc.
Python
6
star
57

terraform-google-redis

HCL
5
star
58

terraform-google-airflow

HCL
4
star
59

terraform-google-api-police

HCL
3
star
60

.allstar

1
star
61

terraform-google-mariadb

HCL
1
star