Change a single attribute inside a Terraform resource's nested block
Recipe ID
org.openrewrite.terraform.ChangeResourceNestedBlockAttributeArtifact
org.openrewrite.recipe:rewrite-terraformChange 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.
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.6Options
| Name | Type | Description |
|---|---|---|
resourceTyperequired | String | A Terraform resource type, without the quotes. e.g. aws_db_parameter_group |
resourceNamePattern | String | A regular expression matched against the resource's local name (the second label). If omitted, all resources of resourceType are considered.e.g. rds_.* |
resourceAttrMatchers | List | A 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.* |
blockTyperequired | String | The type of nested block to update (e.g. parameter, tag, setting).e.g. parameter |
keyMatchers | List | A 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 |
attributeNamerequired | String | The attribute inside the nested block whose value should change. e.g. value |
newValuerequired | String | The 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