-
Notifications
You must be signed in to change notification settings - Fork 469
feat(lib): add the remove
function to TerraformResource
#3849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
xphir
wants to merge
2
commits into
hashicorp:main
Choose a base branch
from
xphir:xphir/removed-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remove
function to TerraformResource
remove
function to TerraformResource
12b42d4
to
bea7a71
Compare
xphir
commented
Apr 13, 2025
@@ -393,6 +446,12 @@ export class TerraformResource | |||
[this.terraformResourceType]: [this.friendlyUniqueId], | |||
} | |||
: undefined, | |||
// TODO: its was unclear to me if how removed should interact with `toMetadata` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking to get some clarification here how removed
should work with toMetadata()
Adds the `remove` function to the `TerraformResource` that enables support for the underlying terraform `removed` block (context: https://developer.hashicorp.com/terraform/language/resources/syntax#removing-resources). Includes rendering support and unit tests.
c73f399
to
da8d864
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds support within the
TerraformResource
for the removed blockRelated issue
Fixes #3638
Description
Key Changes
_removed
private field onTerraformResource
to track removed state.toTerraform
,toHclTerraform
, andtoMetadata
to support the removed block when applicable.remove(...)
method to define removed resources, including optional lifecycle and provisioner support.RemovedBlockLocalExecProvisioner
interface, as JSII does not support theOmit
type againstLocalExecProvisioner
, to make the API clearer and reduce developer confusion.remove()
in combination withimportFrom
or anymoveXX()
methods, since these operations are mutually exclusive in Terraform’s configuration model.remove
functionality (1.7) and the
provisionerblock (
1.9`)renderRemoved
Rationale
_removed
field aligns with the patterns used for import and move, making the codebase more consistent and easier to reason about.removed
blocks improves the developer experience by avoiding misuse of thewhen
property and surfacing clearer validation (as opposed to a value check and throw).toTerraform()
would silently ignore conflicting operations.Checklist