← All recipes
Moderne licensed

Change a single attribute inside a Terraform resource's nested block

Recipe IDorg.openrewrite.terraform.ChangeResourceNestedBlockAttribute
Artifactorg.openrewrite.recipe:rewrite-terraform

Change the value of an attribute inside a specific instance of a nested block on a Terraform resource (e.g. set value = "0" on the parameter { name = "local_infile" } block of an aws_db_parameter_group). Use keyMatchers to identify a single instance among repeatable blocks.

Single recipeProprietary

Usage

You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.terraform.ChangeResourceNestedBlockAttribute --recipe-option "resourceType=aws_db_parameter_group" --recipe-option "blockType=parameter" --recipe-option "attributeName=value" --recipe-option "newValue=0"

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite.recipe:rewrite-terraform:3.14.6

Options

NameTypeDescription
resourceTyperequiredStringA Terraform resource type, without the quotes.
e.g. aws_db_parameter_group
resourceNamePatternStringA regular expression matched against the resource's local name (the second label). If omitted, all resources of resourceType are considered.
e.g. rds_.*
resourceAttrMatchersListA list of attr=valueRegex entries. The resource is considered a match only if every entry matches an attribute on the resource (AND semantics).
e.g. family=mysql.*|mariadb.*
blockTyperequiredStringThe type of nested block to update (e.g. parameter, tag, setting).
e.g. parameter
keyMatchersListA list of attr=valueRegex entries identifying the specific nested block instance to update. If omitted, every block of the given blockType is updated.
e.g. name=local_infile
attributeNamerequiredStringThe attribute inside the nested block whose value should change.
e.g. value
newValuerequiredStringThe new value to set. For quoted string attributes, provide the value without quotes.
e.g. 0

Data tables

Structured output this recipe can produce.

  • Source files that had resultsSource files that were modified by the recipe run.org.openrewrite.table.SourcesFileResults
  • Source files that had search resultsSearch results that were found during the recipe run.org.openrewrite.table.SearchResults
  • Source files that errored on a recipeThe details of all errors produced by a recipe run.org.openrewrite.table.SourcesFileErrors
  • Recipe performanceStatistics used in analyzing the performance of recipes.org.openrewrite.table.RecipeRunStats