generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
Describe the feature
Add support for the -replace flag (and -refresh=false) to the ExecuteTerraformCommand tool for both plan and apply operations.
Use Case
The -replace flag is essential for forcing replacement of specific resources when troubleshooting or dealing with:
- Tainted resources that need recreation
- Resources with external configuration drift
- Testing disaster recovery procedures
- Forcing recreation of resources without manual
terraform taint
Example scenarios:
# Force replace a specific EC2 instance
terraform plan -replace="aws_instance.web_server"
# Plan with multiple replacements
terraform plan -replace="aws_instance.app" -replace="aws_instance.worker"
# Apply with replacement (after reviewing plan)
terraform apply -replace="aws_instance.web_server"Similarly, -refresh=false is useful to skip the refresh phase when you know the state is current and want faster planning.
Proposed Solution
Add optional parameters to the ExecuteTerraformCommand tool:
replace_targets: list of resource addresses to force replacementrefresh: boolean flag to control state refresh (default: true)
Example API usage:
await execute_terraform_command(
command="plan",
working_directory="./infrastructure",
replace_targets=["aws_instance.web_server", "aws_db_instance.main"],
refresh=False
)Other Information
This complements issue #2013 which requests -target support. Together, these options provide more granular control over Terraform operations via MCP.
Terraform documentation:
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
To triage