Terraform data source: terraform remote state
Revision as of 04:50, 21 February 2022 by Chmod15 (talk | contribs) (→Example Usage (remote Backend))
terraform_remote_state
Controlled Remote State Access feature in Terraform Cloud and Terraform Enterprise, users now have a new way to establish granular controls for state accessibility.
Example Usage (remote Backend)
data "terraform_remote_state" "vpc" { backend = "remote" config = { organization = "hashicorp" workspaces = { name = "vpc-prod" } } } # Terraform >= 0.12 resource "aws_instance" "foo" { # ... subnet_id = data.terraform_remote_state.vpc.outputs.subnet_id } # Terraform <= 0.11 resource "aws_instance" "foo" { # ... subnet_id = "${data.terraform_remote_state.vpc.subnet_id}" }
Example Usage (local Backend)
data "terraform_remote_state" "vpc" { backend = "local" config = { path = "..." } } # Terraform >= 0.12 resource "aws_instance" "foo" { # ... subnet_id = data.terraform_remote_state.vpc.outputs.subnet_id } # Terraform <= 0.11 resource "aws_instance" "foo" { # ... subnet_id = "${data.terraform_remote_state.vpc.subnet_id}" }
Related
See also
- Terraform state:
terraform [ state | replace-provider | mv ]
,backend.tf
, Remote state backends to manage Terraform state, State locking,terraform force-unlock
- Terraform data sources:
aws_vpc
,template_file
,aws_subnet_ids
,terraform remote state
,aws_eks_cluster
,aws_ami, aws_availability_zones, aws_partition, archive_file
- Terraform, OpenTofu, Terrakube.org, Installation, Terraform AWS, Terraform GCP, Terraform commands, Terraform Cloud, Terraform Enterprise (TFE), HCL, HIL, meta-arguments, providers, modules, resource, provisioners, data sources, backends: remote backends, examples, configuration files, state files, variables, types, Terraform Registry, conditionals:
depends_on
, functions, Blocks, dynamic blocks, errors, Terragrunt, Terraformer, Terratest, Terraform certifications, Terraform map type, Terraform Associate, Terraform: list type,TF_VAR_, TF_LOG
, Terraform provider versioning, Terraform Style Conventions, Required version, Terraform plugin, Terraform Named Values, tags, Changelog,tfsec, tflint
, Operators, Expressions:for, splat
, Debugging, Namespaces, Terraform Landing Zones, CDKTF, Atmos
Advertising: