diff --git a/reconcile/gql_definitions/terraform_resources/terraform_resources_namespaces.gql b/reconcile/gql_definitions/terraform_resources/terraform_resources_namespaces.gql index 768af7ae5e..ace9ae6486 100644 --- a/reconcile/gql_definitions/terraform_resources/terraform_resources_namespaces.gql +++ b/reconcile/gql_definitions/terraform_resources/terraform_resources_namespaces.gql @@ -49,6 +49,7 @@ query TerraformResourcesNamespaces { loss_impact } managed_by_erv2 + delete } ... on NamespaceTerraformResourceS3_v1 { region diff --git a/reconcile/gql_definitions/terraform_resources/terraform_resources_namespaces.py b/reconcile/gql_definitions/terraform_resources/terraform_resources_namespaces.py index ba828a5fde..592b6930f6 100644 --- a/reconcile/gql_definitions/terraform_resources/terraform_resources_namespaces.py +++ b/reconcile/gql_definitions/terraform_resources/terraform_resources_namespaces.py @@ -106,6 +106,7 @@ loss_impact } managed_by_erv2 + delete } ... on NamespaceTerraformResourceS3_v1 { region @@ -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): diff --git a/reconcile/utils/external_resource_spec.py b/reconcile/utils/external_resource_spec.py index 3c3fb2d373..b3f4e9623f 100644 --- a/reconcile/utils/external_resource_spec.py +++ b/reconcile/utils/external_resource_spec.py @@ -86,7 +86,7 @@ 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: {} @@ -94,7 +94,7 @@ class ExternalResourceSpec: @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: diff --git a/reconcile/utils/terrascript_aws_client.py b/reconcile/utils/terrascript_aws_client.py index 048782c674..a3f777878a 100644 --- a/reconcile/utils/terrascript_aws_client.py +++ b/reconcile/utils/terrascript_aws_client.py @@ -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)