mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/terraform: remote state resource becomes a data source
As a first example of a real-world data source, the pre-existing terraform_remote_state resource is adapted to be a data source. The original resource is shimmed to wrap the data source for backward compatibility.
This commit is contained in:
parent
64d5ff2e84
commit
76fb7693b5
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
layout: "terraform"
|
layout: "terraform"
|
||||||
page_title: "Terraform: terraform_remote_state"
|
page_title: "Terraform: terraform_remote_state"
|
||||||
sidebar_current: "docs-terraform-resource-remote-state"
|
sidebar_current: "docs-terraform-datasource-remote-state"
|
||||||
description: |-
|
description: |-
|
||||||
Accesses state meta data from a remote backend.
|
Accesses state meta data from a remote backend.
|
||||||
---
|
---
|
||||||
@ -13,7 +13,7 @@ Retrieves state meta data from a remote backend
|
|||||||
## Example Usage
|
## Example Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
resource "terraform_remote_state" "vpc" {
|
data "terraform_remote_state" "vpc" {
|
||||||
backend = "atlas"
|
backend = "atlas"
|
||||||
config {
|
config {
|
||||||
name = "hashicorp/vpc-prod"
|
name = "hashicorp/vpc-prod"
|
||||||
@ -22,7 +22,7 @@ resource "terraform_remote_state" "vpc" {
|
|||||||
|
|
||||||
resource "aws_instance" "foo" {
|
resource "aws_instance" "foo" {
|
||||||
# ...
|
# ...
|
||||||
subnet_id = "${terraform_remote_state.vpc.output.subnet_id}"
|
subnet_id = "${data.terraform_remote_state.vpc.output.subnet_id}"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -8,23 +8,16 @@ description: |-
|
|||||||
|
|
||||||
# Terraform Provider
|
# Terraform Provider
|
||||||
|
|
||||||
The terraform provider exposes resources to access state meta data
|
The terraform provider provides access to outputs from the Terraform state
|
||||||
for Terraform outputs from shared infrastructure.
|
of shared infrastructure.
|
||||||
|
|
||||||
The terraform provider is what we call a _logical provider_. This has no
|
Use the navigation to the left to read about the available data sources.
|
||||||
impact on how it behaves, but conceptually it is important to understand.
|
|
||||||
The terraform provider doesn't manage any _physical_ resources; it isn't
|
|
||||||
creating servers, writing files, etc. It is used to access the outputs
|
|
||||||
of other Terraform states to be used as inputs for resources.
|
|
||||||
Examples will explain this best.
|
|
||||||
|
|
||||||
Use the navigation to the left to read about the available resources.
|
|
||||||
|
|
||||||
## Example Usage
|
## Example Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
# Shared infrastructure state stored in Atlas
|
# Shared infrastructure state stored in Atlas
|
||||||
resource "terraform_remote_state" "vpc" {
|
data "terraform_remote_state" "vpc" {
|
||||||
backend = "atlas"
|
backend = "atlas"
|
||||||
config {
|
config {
|
||||||
path = "hashicorp/vpc-prod"
|
path = "hashicorp/vpc-prod"
|
||||||
@ -33,6 +26,6 @@ resource "terraform_remote_state" "vpc" {
|
|||||||
|
|
||||||
resource "aws_instance" "foo" {
|
resource "aws_instance" "foo" {
|
||||||
# ...
|
# ...
|
||||||
subnet_id = "${terraform_remote_state.vpc.output.subnet_id}"
|
subnet_id = "${data.terraform_remote_state.vpc.output.subnet_id}"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user