From becfb069180d27713d399781cb70f7134c754e87 Mon Sep 17 00:00:00 2001 From: trujillo-adam Date: Fri, 3 May 2024 15:35:54 -0700 Subject: [PATCH 1/3] added reference page for block --- website/data/language-nav-data.json | 4 ++ website/docs/language/moved.mdx | 63 +++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 website/docs/language/moved.mdx diff --git a/website/data/language-nav-data.json b/website/data/language-nav-data.json index 6fadb9d28d..895afcc264 100644 --- a/website/data/language-nav-data.json +++ b/website/data/language-nav-data.json @@ -217,6 +217,10 @@ } ] }, + { + "title": "moved block", + "path": "moved" + }, { "title": "Checks", "path": "checks" }, { "title": "Import", diff --git a/website/docs/language/moved.mdx b/website/docs/language/moved.mdx new file mode 100644 index 0000000000..64dd91d119 --- /dev/null +++ b/website/docs/language/moved.mdx @@ -0,0 +1,63 @@ +--- +page_title: moved block configuration reference +description: Learn about the `moved` block that you can specify in Terraform configurations. The `moved` block programmatically changes the location of resource. +--- + +# `moved` block configuration reference + +This topic provides reference information for the `moved` block. + +## Introduction + +The `moved` block programmatically changes the address of a resource. Refer to [Refactoring](/terraform/language/modules/develop/refactoring) for details about how to use the `moved` block in your Terraform configurations. + +## Configuration model + +The following list outlines field hierarchy, language-specific data types, and requirements in the `moved` block. + +- [`moved`](#moved): map + - [`from`](#moved): string + - [`to`](#moved): string + +## Complete configuration + +When every field is defined, a `moved` block has the following form: + +```hcl + +moved = { + from = + to = +} +``` + +## Specification + +This section provides details about the fields you can configure in the `moved` block. + +### `moved` + +Map that specifies addresses for the resource. The following table describes the fields you can set in the `moved` block. + +| Field | Description | Type | Required | +| --- | --- | --- | --- | +| `from` | Specifies the previous address of the resource addresses using a syntax that allows Terraform to select modules, resources, and resources inside child modules. | string | required | +| `to` | Sepcifies the current address of the resource using a syntax that allows Terraform to select modules, resources, and resources inside child modules. | string | required | + +Before creating a new plan for the resource specified in the `to` field, Terraform checks the state for an existing object at the address specified in the `from` field. Terraform renames existing objects to the string specified in the `to` field then creates a plan. The plan directs Terraform to provision the resource specified in the `from` field as the resource specified in the `to` field. As a result, Terraform does not destroy the resource during the Terraform run. + +## Example + +The following example moves and AWS instance from address `aws_instance.a` to `aws_instance.b`: + +```hcl +moved { + from = aws_instance.a + to = aws_instance.b +} +``` + + + + + From d56ed454841b3e3c0883f5f453078ea9f99e5507 Mon Sep 17 00:00:00 2001 From: trujillo-adam Date: Fri, 3 May 2024 16:12:01 -0700 Subject: [PATCH 2/3] capitalized Moved and removed backticks --- website/data/language-nav-data.json | 2 +- website/docs/language/moved.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/website/data/language-nav-data.json b/website/data/language-nav-data.json index 895afcc264..bee6f0b01a 100644 --- a/website/data/language-nav-data.json +++ b/website/data/language-nav-data.json @@ -218,7 +218,7 @@ ] }, { - "title": "moved block", + "title": "Moved block", "path": "moved" }, { "title": "Checks", "path": "checks" }, diff --git a/website/docs/language/moved.mdx b/website/docs/language/moved.mdx index 64dd91d119..cb47c147ea 100644 --- a/website/docs/language/moved.mdx +++ b/website/docs/language/moved.mdx @@ -3,7 +3,7 @@ page_title: moved block configuration reference description: Learn about the `moved` block that you can specify in Terraform configurations. The `moved` block programmatically changes the location of resource. --- -# `moved` block configuration reference +# Moved block configuration reference This topic provides reference information for the `moved` block. From e3d2923c1fc2135d56136e1df5a110ddf5fcad58 Mon Sep 17 00:00:00 2001 From: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> Date: Mon, 6 May 2024 15:35:01 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Rose M Koron <32436232+rkoron007@users.noreply.github.com> --- website/docs/language/moved.mdx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/website/docs/language/moved.mdx b/website/docs/language/moved.mdx index cb47c147ea..57989c9de4 100644 --- a/website/docs/language/moved.mdx +++ b/website/docs/language/moved.mdx @@ -1,6 +1,6 @@ --- page_title: moved block configuration reference -description: Learn about the `moved` block that you can specify in Terraform configurations. The `moved` block programmatically changes the location of resource. +description: Learn about the `moved` block that you can specify in Terraform configurations. The `moved` block programmatically changes the location of a resource. --- # Moved block configuration reference @@ -24,7 +24,6 @@ The following list outlines field hierarchy, language-specific data types, and r When every field is defined, a `moved` block has the following form: ```hcl - moved = { from = to = @@ -41,14 +40,14 @@ Map that specifies addresses for the resource. The following table describes the | Field | Description | Type | Required | | --- | --- | --- | --- | -| `from` | Specifies the previous address of the resource addresses using a syntax that allows Terraform to select modules, resources, and resources inside child modules. | string | required | -| `to` | Sepcifies the current address of the resource using a syntax that allows Terraform to select modules, resources, and resources inside child modules. | string | required | +| `from` | Specifies a resource's previous address. The syntax allows Terraform to select modules, resources, and resources inside child modules. | string | required | +| `to` | Specifies the new address to relocate the resource to. The syntax allows Terraform to select modules, resources, and resources inside child modules. | string | required | -Before creating a new plan for the resource specified in the `to` field, Terraform checks the state for an existing object at the address specified in the `from` field. Terraform renames existing objects to the string specified in the `to` field then creates a plan. The plan directs Terraform to provision the resource specified in the `from` field as the resource specified in the `to` field. As a result, Terraform does not destroy the resource during the Terraform run. +Before creating a new plan for the resource specified in the `to` field, Terraform checks the state for an existing object at the address specified in the `from` field. Terraform renames existing objects to the string specified in the `to` field and then creates a plan. The plan directs Terraform to provision the resource specified in the `from` field as the resource specified in the `to` field. As a result, Terraform does not destroy the resource during the Terraform run. ## Example -The following example moves and AWS instance from address `aws_instance.a` to `aws_instance.b`: +The following example moves an AWS instance from address `aws_instance.a` to `aws_instance.b`: ```hcl moved {