Skip to content
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

[terraform-resources] support RDS delete #4723

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ query TerraformResourcesNamespaces {
loss_impact
}
managed_by_erv2
delete
}
... on NamespaceTerraformResourceS3_v1 {
region
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
loss_impact
}
managed_by_erv2
delete
}
... on NamespaceTerraformResourceS3_v1 {
region
Expand Down Expand Up @@ -568,6 +569,7 @@ class NamespaceTerraformResourceRDSV1(NamespaceTerraformResourceAWSV1):
event_notifications: Optional[list[AWSRDSEventNotificationV1]] = Field(..., alias="event_notifications")
data_classification: Optional[AWSRDSDataClassificationV1] = Field(..., alias="data_classification")
managed_by_erv2: Optional[bool] = Field(..., alias="managed_by_erv2")
delete: Optional[bool] = Field(..., alias="delete")


class AWSS3EventNotificationV1(ConfiguredBaseModel):
Expand Down
4 changes: 2 additions & 2 deletions reconcile/utils/external_resource_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ class ExternalResourceSpec:
resource: MutableMapping[str, Any]
namespace: Mapping[str, Any]
secret: Mapping[str, str] = field(init=False, default_factory=lambda: {})
# Metadata is used for processing data that shuold not be included in the secret data
# Metadata is used for processing data that should not be included in the secret data
# e.g: ERV2 adds a updated_at attribute that acts as optimistic lock.
metadata: MutableMapping[str, Any] = field(
init=False, compare=False, repr=False, hash=False, default_factory=lambda: {}
)

@property
def marked_to_delete(self) -> bool:
return self.metadata.get("delete") or False
return self.metadata.get("delete") or self.resource.get("delete") or False

@property
def provider(self) -> str:
Expand Down
2 changes: 2 additions & 0 deletions reconcile/utils/terrascript_aws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,8 @@ def populate_tf_resources(self, spec, ocm_map=None):
raise UnknownProviderError(provider)

def populate_tf_resource_rds(self, spec):
if spec.marked_to_delete:
return
account = spec.provisioner_name
identifier = spec.identifier
values = self.init_values(spec)
Expand Down