Difference between revisions of "Terraform data source: terraform remote state"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
Tags: Mobile web edit, Mobile edit
Line 52: Line 52:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
== Errors ==
 +
* <code>[[Error: AccessDenied: Access Denied]]</code>
 +
* <code>[[Error: Unable to find remote state]]</code>
  
 
== Related ==
 
== Related ==
Line 57: Line 61:
 
* [[Explain the benefits of state]]
 
* [[Explain the benefits of state]]
 
* Buildin [[provider]]
 
* Buildin [[provider]]
* <code>[[Error: AccessDenied: Access Denied]]</code>
 
* <code>[[Error: Unable to find remote state]]</code>
 
  
 
== See also ==
 
== See also ==

Revision as of 15:41, 15 March 2023

terraform_remote_state

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}"
}

Errors

Related

See also

Advertising: