Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Executes Google Cloud CLI commands within Terraform

License

NotificationsYou must be signed in to change notification settings

terraform-google-modules/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 moduledoes 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="~> 4.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 theexamples directory.

Thejq binary is also included in this module so you can use it as well for either of yourcreate_cmd_entrypoint ordestroy_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 theskip_download variable tofalse.

You can also override the behavior by setting theGCLOUD_TF_DOWNLOAD environment variable.This environment variable will override all other settings.Setting it tonever willnever gcloud download and setting it toalways will always download gcloud.

Inputs

NameDescriptionTypeDefaultRequired
activate_service_accountSet to false to skip runninggcloud auth activate-service-account. Optional.booltrueno
additional_componentsAdditional gcloud CLI components to install. Defaults to none. Valid value are components listed ingcloud components listlist(string)[]no
create_cmd_bodyOn create, the command body you'd like to run with your entrypoint.string"info"no
create_cmd_entrypointOn 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_triggersList 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 inthe source.)map(any){}no
destroy_cmd_bodyOn destroy, the command body you'd like to run with your entrypoint.string"info"no
destroy_cmd_entrypointOn 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
enabledFlag to optionally disable usage of this module.booltrueno
gcloud_download_urlCustom gcloud download url. Optional.string""no
gcloud_sdk_versionThe gcloud sdk version to download.string"481.0.0"no
jq_download_urlCustom jq download url. Optional.string""no
jq_versionThe jq version to download.string"1.6"no
module_depends_onList of modules or resources this module depends on.list(any)[]no
platformPlatform CLI will run on. Defaults to linux. Valid values: linux, darwinstring"linux"no
service_account_key_filePath to service account key file to rungcloud auth activate-service-account with. Optional.string""no
skip_downloadWhether to skip downloading gcloud (assumes gcloud is already available outside the module)booltrueno
upgradeWhether to upgrade gcloud at runtimebooltrueno
use_tf_google_credentials_env_varUseGOOGLE_CREDENTIALS environment variable to rungcloud auth activate-service-account with. Optional.boolfalseno

Outputs

NameDescription
bin_dirThe full bin path of the modules executables
create_cmd_binThe full bin path & command used on create
destroy_cmd_binThe full bin path & command used on destroy
downloadedWhether gcloud was downloaded or not
waitAn 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 whatevercommands you're running with this module.

APIs

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

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

Contributing

Refer to thecontribution guidelines forinformation on contributing to this module.


[8]ページ先頭

©2009-2025 Movatter.jp