From 678feaaed7005e4975dc851593367f144729fd8e Mon Sep 17 00:00:00 2001 From: John Engelman Date: Tue, 26 May 2015 08:35:19 -0500 Subject: [PATCH 01/14] Add Terraform/Remote State documentation to provider/resource section. Issue #2074 --- index.html.markdown | 38 ++++++++++++++++++++++++++++++++++++++ r/remote_state.html.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 index.html.markdown create mode 100644 r/remote_state.html.md diff --git a/index.html.markdown b/index.html.markdown new file mode 100644 index 0000000000..e5ccbff59e --- /dev/null +++ b/index.html.markdown @@ -0,0 +1,38 @@ +--- +layout: "terraform" +page_title: "Provider: Terraform" +sidebar_current: "docs-terraform-index" +description: |- + The Terraform provider is used to access meta data from shared infrastructure. +--- + +# Terraform Provider + +The terraform provider exposes resources to access state meta data +for Terraform outputs from shared infrastructure. + +The terraform provider is what we call a _logical provider_. This has no +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 + +``` +# Shared infrastructure state stored in Atlas +resource "terraform_remote_state" "vpc" { + backend = "atlas" + config { + path = "hashicorp/vpc-prod" + } +} + +resource "aws_instance" "foo" { + # ... + subnet_id = "${terraform_remote_state.vpc.output.subnet_id}" +} +``` diff --git a/r/remote_state.html.md b/r/remote_state.html.md new file mode 100644 index 0000000000..b02ddfee99 --- /dev/null +++ b/r/remote_state.html.md @@ -0,0 +1,42 @@ +--- +layout: "terraform" +page_title: "Terraform: terraform_remote_state" +sidebar_current: "docs-terraform-resource-remote-state" +description: |- + Accesses state meta data from a remote backend. +--- + +# remote\_state + +Retrieves state meta data from a remote backend + +## Example Usage + +``` +resource "terraform_remote_state" "vpc" { + backend = "atlas" + config { + path = "hashicorp/vpc-prod" + } +} + +resource "aws_instance" "foo" { + # ... + subnet_id = "${terraform_remote_state.vpc.output.subnet_id}" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `backend` - (Required) The remote backend to use. +* `config` - (Optional) The configuration of the remote backend. + +## Attributes Reference + +The following attributes are exported: + +* `backend` - See Argument Reference above. +* `config` - See Argument Reference above. +* `output` - The values of the configured `outputs` for the root module referenced by the remote state. From 64d5ff2e847710e0c4d2c8796dc7d42ed2f035f8 Mon Sep 17 00:00:00 2001 From: Craig Marsden Date: Wed, 3 Feb 2016 13:20:35 +0000 Subject: [PATCH 02/14] correct remote state documentation and add config sub-arguments for atlas. --- r/remote_state.html.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/r/remote_state.html.md b/r/remote_state.html.md index b02ddfee99..dbe19fd312 100644 --- a/r/remote_state.html.md +++ b/r/remote_state.html.md @@ -16,7 +16,7 @@ Retrieves state meta data from a remote backend resource "terraform_remote_state" "vpc" { backend = "atlas" config { - path = "hashicorp/vpc-prod" + name = "hashicorp/vpc-prod" } } @@ -32,6 +32,7 @@ The following arguments are supported: * `backend` - (Required) The remote backend to use. * `config` - (Optional) The configuration of the remote backend. + * Remote state config docs can be found [here](https://www.terraform.io/docs/state/remote/atlas.html) ## Attributes Reference From 76fb7693b5a2714e63546d807a3eae4140717c33 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Sun, 1 May 2016 16:05:54 -0700 Subject: [PATCH 03/14] 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. --- {r => d}/remote_state.html.md | 6 +++--- index.html.markdown | 17 +++++------------ 2 files changed, 8 insertions(+), 15 deletions(-) rename {r => d}/remote_state.html.md (84%) diff --git a/r/remote_state.html.md b/d/remote_state.html.md similarity index 84% rename from r/remote_state.html.md rename to d/remote_state.html.md index dbe19fd312..683ba264e3 100644 --- a/r/remote_state.html.md +++ b/d/remote_state.html.md @@ -1,7 +1,7 @@ --- layout: "terraform" page_title: "Terraform: terraform_remote_state" -sidebar_current: "docs-terraform-resource-remote-state" +sidebar_current: "docs-terraform-datasource-remote-state" description: |- Accesses state meta data from a remote backend. --- @@ -13,7 +13,7 @@ Retrieves state meta data from a remote backend ## Example Usage ``` -resource "terraform_remote_state" "vpc" { +data "terraform_remote_state" "vpc" { backend = "atlas" config { name = "hashicorp/vpc-prod" @@ -22,7 +22,7 @@ resource "terraform_remote_state" "vpc" { resource "aws_instance" "foo" { # ... - subnet_id = "${terraform_remote_state.vpc.output.subnet_id}" + subnet_id = "${data.terraform_remote_state.vpc.output.subnet_id}" } ``` diff --git a/index.html.markdown b/index.html.markdown index e5ccbff59e..20a9dfee3c 100644 --- a/index.html.markdown +++ b/index.html.markdown @@ -8,23 +8,16 @@ description: |- # Terraform Provider -The terraform provider exposes resources to access state meta data -for Terraform outputs from shared infrastructure. +The terraform provider provides access to outputs from the Terraform state +of shared infrastructure. -The terraform provider is what we call a _logical provider_. This has no -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. +Use the navigation to the left to read about the available data sources. ## Example Usage ``` # Shared infrastructure state stored in Atlas -resource "terraform_remote_state" "vpc" { +data "terraform_remote_state" "vpc" { backend = "atlas" config { path = "hashicorp/vpc-prod" @@ -33,6 +26,6 @@ resource "terraform_remote_state" "vpc" { resource "aws_instance" "foo" { # ... - subnet_id = "${terraform_remote_state.vpc.output.subnet_id}" + subnet_id = "${data.terraform_remote_state.vpc.output.subnet_id}" } ``` From f49f6cbd5f43dac4c677ada42ea3124caf463864 Mon Sep 17 00:00:00 2001 From: Mike Tougeron Date: Mon, 25 Jul 2016 13:41:24 -0700 Subject: [PATCH 04/14] Terraform 0.7.0 data resource for remote state does not use the 'output' path (#7802) --- d/remote_state.html.md | 2 +- index.html.markdown | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/d/remote_state.html.md b/d/remote_state.html.md index 683ba264e3..5adc371705 100644 --- a/d/remote_state.html.md +++ b/d/remote_state.html.md @@ -22,7 +22,7 @@ data "terraform_remote_state" "vpc" { resource "aws_instance" "foo" { # ... - subnet_id = "${data.terraform_remote_state.vpc.output.subnet_id}" + subnet_id = "${data.terraform_remote_state.vpc.subnet_id}" } ``` diff --git a/index.html.markdown b/index.html.markdown index 20a9dfee3c..aba8053494 100644 --- a/index.html.markdown +++ b/index.html.markdown @@ -26,6 +26,6 @@ data "terraform_remote_state" "vpc" { resource "aws_instance" "foo" { # ... - subnet_id = "${data.terraform_remote_state.vpc.output.subnet_id}" + subnet_id = "${data.terraform_remote_state.vpc.subnet_id}" } ``` From e3160eea07604d1786be391d095dbc09b3868889 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Wed, 3 Aug 2016 14:07:57 +0100 Subject: [PATCH 05/14] Fix terraform_remote_state documentation Fixing minor typo to match documentation on https://www.terraform.io/docs/providers/terraform/d/remote_state.html --- index.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html.markdown b/index.html.markdown index aba8053494..815c136223 100644 --- a/index.html.markdown +++ b/index.html.markdown @@ -20,7 +20,7 @@ Use the navigation to the left to read about the available data sources. data "terraform_remote_state" "vpc" { backend = "atlas" config { - path = "hashicorp/vpc-prod" + name = "hashicorp/vpc-prod" } } From ab14f5274863f64fd4de67a7bd4b67f85578076f Mon Sep 17 00:00:00 2001 From: James Nugent Date: Fri, 19 Aug 2016 00:50:43 +0100 Subject: [PATCH 06/14] docs: Remove output from `terraform_remote_state` Fixes #8296. --- d/remote_state.html.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/d/remote_state.html.md b/d/remote_state.html.md index 5adc371705..68386e8b86 100644 --- a/d/remote_state.html.md +++ b/d/remote_state.html.md @@ -40,4 +40,6 @@ The following attributes are exported: * `backend` - See Argument Reference above. * `config` - See Argument Reference above. -* `output` - The values of the configured `outputs` for the root module referenced by the remote state. + +In addition, each output in the remote state appears as a top level attribute +on the `terraform_remote_state` resource. From 4acd4a2bcf52a2ac81bfb6e6ef0613523b2fb1f0 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 24 Oct 2016 14:14:49 -0700 Subject: [PATCH 07/14] Update remote_state.html.md --- d/remote_state.html.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/d/remote_state.html.md b/d/remote_state.html.md index 68386e8b86..d5ec49fa08 100644 --- a/d/remote_state.html.md +++ b/d/remote_state.html.md @@ -43,3 +43,21 @@ The following attributes are exported: In addition, each output in the remote state appears as a top level attribute on the `terraform_remote_state` resource. + +## Root Outputs Only + +Only the root level outputs from the remote state are accessible. Outputs from modules within the state cannot be accessed. If you want a module output to be accessible via a remote state, you must thread the output through to a root output. + +An example is shown below: + +``` +module "app" { + source = "..." +} + +output "app_value" { + value = "${module.app.value}" +} +``` + +In this example, the output `value` from the "app" module is available as "app_value". If this root level output hadn't been created, then a remote state resource wouldn't be able to access the `value` output on the module. From f70d15dd3da8879164f214bc594c4192d572c6cb Mon Sep 17 00:00:00 2001 From: George Christou Date: Sat, 18 Feb 2017 22:48:50 +0000 Subject: [PATCH 08/14] website/docs: Run `terraform fmt` on code examples (#12075) * docs/vsphere: Fix code block * docs: Convert `...` to `# ...` to allow `terraform fmt`ing * docs: Trim trailing whitespace * docs: First-pass run of `terraform fmt` on code examples --- index.html.markdown | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/index.html.markdown b/index.html.markdown index 815c136223..3fca182572 100644 --- a/index.html.markdown +++ b/index.html.markdown @@ -18,14 +18,15 @@ Use the navigation to the left to read about the available data sources. ``` # Shared infrastructure state stored in Atlas data "terraform_remote_state" "vpc" { - backend = "atlas" - config { - name = "hashicorp/vpc-prod" - } + backend = "atlas" + + config { + name = "hashicorp/vpc-prod" + } } resource "aws_instance" "foo" { - # ... - subnet_id = "${data.terraform_remote_state.vpc.subnet_id}" + # ... + subnet_id = "${data.terraform_remote_state.vpc.subnet_id}" } ``` From 65ea9c30347b94c6dffbce798c299522e3e0b16a Mon Sep 17 00:00:00 2001 From: clint shryock Date: Wed, 15 Mar 2017 12:20:26 -0500 Subject: [PATCH 09/14] docs: fix some broken links related to remote state --- d/remote_state.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d/remote_state.html.md b/d/remote_state.html.md index d5ec49fa08..b2e6a3f088 100644 --- a/d/remote_state.html.md +++ b/d/remote_state.html.md @@ -32,7 +32,7 @@ The following arguments are supported: * `backend` - (Required) The remote backend to use. * `config` - (Optional) The configuration of the remote backend. - * Remote state config docs can be found [here](https://www.terraform.io/docs/state/remote/atlas.html) + * Remote state config docs can be found [here](/docs/backends/types/atlas.html) ## Attributes Reference From f1df7afadc9fe01ca604d303d93eee57a9d4cec7 Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Wed, 5 Apr 2017 10:53:18 +0200 Subject: [PATCH 10/14] Document the `environment` attribute. (#13360) The existence of the attribute is mentioned here already: https://www.terraform.io/docs/state/environments.html --- d/remote_state.html.md | 1 + 1 file changed, 1 insertion(+) diff --git a/d/remote_state.html.md b/d/remote_state.html.md index b2e6a3f088..b24207773a 100644 --- a/d/remote_state.html.md +++ b/d/remote_state.html.md @@ -31,6 +31,7 @@ resource "aws_instance" "foo" { The following arguments are supported: * `backend` - (Required) The remote backend to use. +* `environment` - (Optional) The Terraform environment to use. * `config` - (Optional) The configuration of the remote backend. * Remote state config docs can be found [here](/docs/backends/types/atlas.html) From 2ff3d47f30c9dd3bc603fdd50905b3b46c8f040f Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 7 Apr 2017 00:14:57 -0400 Subject: [PATCH 11/14] Fix broken links --- d/remote_state.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d/remote_state.html.md b/d/remote_state.html.md index b24207773a..c54fdb014c 100644 --- a/d/remote_state.html.md +++ b/d/remote_state.html.md @@ -33,7 +33,7 @@ The following arguments are supported: * `backend` - (Required) The remote backend to use. * `environment` - (Optional) The Terraform environment to use. * `config` - (Optional) The configuration of the remote backend. - * Remote state config docs can be found [here](/docs/backends/types/atlas.html) + * Remote state config docs can be found [here](/docs/backends/types/terraform-enterprise.html) ## Attributes Reference From 91d5e75afa0c1156c6cea0e92b0f42d7c3aae90b Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 7 Apr 2017 11:36:49 -0400 Subject: [PATCH 12/14] Remove more references to Atlas --- d/remote_state.html.md | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/d/remote_state.html.md b/d/remote_state.html.md index c54fdb014c..cec5d919be 100644 --- a/d/remote_state.html.md +++ b/d/remote_state.html.md @@ -6,23 +6,23 @@ description: |- Accesses state meta data from a remote backend. --- -# remote\_state +# remote_state Retrieves state meta data from a remote backend ## Example Usage -``` +```hcl data "terraform_remote_state" "vpc" { - backend = "atlas" - config { - name = "hashicorp/vpc-prod" - } + backend = "atlas" + config { + name = "hashicorp/vpc-prod" + } } resource "aws_instance" "foo" { - # ... - subnet_id = "${data.terraform_remote_state.vpc.subnet_id}" + # ... + subnet_id = "${data.terraform_remote_state.vpc.subnet_id}" } ``` @@ -47,11 +47,14 @@ on the `terraform_remote_state` resource. ## Root Outputs Only -Only the root level outputs from the remote state are accessible. Outputs from modules within the state cannot be accessed. If you want a module output to be accessible via a remote state, you must thread the output through to a root output. +Only the root level outputs from the remote state are accessible. Outputs from +modules within the state cannot be accessed. If you want a module output to be +accessible via a remote state, you must thread the output through to a root +output. An example is shown below: -``` +```hcl module "app" { source = "..." } @@ -61,4 +64,6 @@ output "app_value" { } ``` -In this example, the output `value` from the "app" module is available as "app_value". If this root level output hadn't been created, then a remote state resource wouldn't be able to access the `value` output on the module. +In this example, the output `value` from the "app" module is available as +"app_value". If this root level output hadn't been created, then a remote state +resource wouldn't be able to access the `value` output on the module. From 2cbd548d556bab9af1f3d3680650cfd912f3fa5f Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 7 Apr 2017 16:56:35 -0700 Subject: [PATCH 13/14] website: additional syntax highlighting for "terraform" provider docs --- index.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html.markdown b/index.html.markdown index 3fca182572..f0b7784a0d 100644 --- a/index.html.markdown +++ b/index.html.markdown @@ -15,7 +15,7 @@ Use the navigation to the left to read about the available data sources. ## Example Usage -``` +```hcl # Shared infrastructure state stored in Atlas data "terraform_remote_state" "vpc" { backend = "atlas" From c907a1657a38dfb0ea46893a5864fd77ce66cd57 Mon Sep 17 00:00:00 2001 From: Jake Champlin Date: Fri, 9 Jun 2017 11:34:17 -0400 Subject: [PATCH 14/14] Transfer terraform provider website --- {d => website/docs/d}/remote_state.html.md | 0 index.html.markdown => website/docs/index.html.markdown | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {d => website/docs/d}/remote_state.html.md (100%) rename index.html.markdown => website/docs/index.html.markdown (100%) diff --git a/d/remote_state.html.md b/website/docs/d/remote_state.html.md similarity index 100% rename from d/remote_state.html.md rename to website/docs/d/remote_state.html.md diff --git a/index.html.markdown b/website/docs/index.html.markdown similarity index 100% rename from index.html.markdown rename to website/docs/index.html.markdown