Documentation ¶
Overview ¶
Package terraform provides helpers for working with Terraform.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply applies the config. The config will be written as a .tf.json file in the given dir. All imports in opts.Imports will be imported prior being applied. Thus, if a resource exists it will be imported to the terraform state. Without importing an existing resource terraform can fail with an "ALREADY EXISTS" error when it tries to create it.
Types ¶
type ActionFunc ¶
ActionFunc are functions that can implement extra actions to run on existing Terraform deployments.
type Backend ¶
Backend provides a terraform backend config. See https://www.terraform.io/docs/backends/types/gcs.html.
func (*Backend) MarshalJSON ¶
MarshalJSON implements a custom marshaller which marshals the backend under a "gcs" block.
type Config ¶
type Config struct { Providers []*Provider `json:"provider,omitempty"` Terraform *Terraform `json:"terraform,omitempty"` Data []*Resource `json:"data,omitempty"` Modules []*Module `json:"module,omitempty"` Resources []*Resource `json:"resource,omitempty"` Outputs []*Output `json:"output,omitempty"` }
Config represents a Terraform config. See https://www.terraform.io/docs/configuration/syntax-json.html for documentation. Note: Terraform resources and modules are keyed Type+ID. So google_storage_bucket.foo and google_bigquery_dataset.foo are acceptable in the same config.
type Import ¶
Import defines fields used for a terraform import. See https://www.terraform.io/docs/import/usage.html.
type Module ¶
type Module struct { Name string `json:"-"` Source string `json:"source"` Properties interface{} `json:"-"` }
Module provides a terraform module config. See https://www.terraform.io/docs/configuration/modules.html for details.
func (*Module) MarshalJSON ¶
MarshalJSON implements a custom marshaller which marshals properties to the top level.
type Options ¶
type Options struct { Imports []Import CustomConfig map[string]interface{} ApplyFlags []string ExtraActions []ActionFunc }
Options configure a terraform apply call.
type Output ¶
Output provides a terraform output config. See https://www.terraform.io/docs/configuration/outputs.html.
func (*Output) MarshalJSON ¶
MarshalJSON implements a custom marshaller which marshals value to be under name.
type Provider ¶
Provider provides a terraform provider config.
func (*Provider) MarshalJSON ¶
MarshalJSON implements a custom marshaller which marshals properties to be under name.
type Resource ¶
type Resource struct { Name string `json:"name"` Type string `json:"type"` Properties interface{} `json:"properties"` }
Resource defines a terraform resource config.
Dependencies can be created between resources using terraform references. See https://www.terraform.io/docs/configuration/resources.html#resource-dependencies.
Meta-arguments are also supported. See https://www.terraform.io/docs/configuration/resources.html#meta-arguments This is especially useful when wanting to create multiple resources that share a common set of fields, such as IAM members of a data resource (e.g. storage_bucket_iam_member). Instead of creating a separate config for each IAM member, a single IAM member using a meta-argument like for_each or count can be expanded by terraform to deploy all IAM members of a resource.
func (*Resource) MarshalJSON ¶
MarshalJSON implements a custom marshaller which marshals the resource to have the following hierarchy: type - name - properties.
type Terraform ¶
type Terraform struct { RequiredVersion string `json:"required_version,omitempty"` Backend *Backend `json:"backend,omitempty"` }
Terraform provides a terraform block config. See https://www.terraform.io/docs/configuration/terraform.html for details.