Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .changelog/44754.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_odb_network: Add `delete_associated_resources` attribute to enable practitioner to delete associated oci resource.
```
74 changes: 44 additions & 30 deletions internal/service/odb/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
Expand Down Expand Up @@ -188,6 +190,15 @@ func (r *resourceNetwork) Schema(ctx context.Context, req resource.SchemaRequest
Computed: true,
Description: "The URL of the OCI VCN for the ODB network.",
},
"delete_associated_resources": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
PlanModifiers: []planmodifier.Bool{
boolplanmodifier.UseStateForUnknown(),
},
Description: "If set to true deletes associated OCI resources. Default false.",
},
"percent_progress": schema.Float32Attribute{
Computed: true,
Description: "The amount of progress made on the current operation on the ODB network, expressed as a percentage.",
Expand Down Expand Up @@ -474,12 +485,14 @@ func (r *resourceNetwork) Delete(ctx context.Context, req resource.DeleteRequest
return
}

deleteAssociatedResources := false
input := odb.DeleteOdbNetworkInput{
OdbNetworkId: state.OdbNetworkId.ValueStringPointer(),
DeleteAssociatedResources: &deleteAssociatedResources,
OdbNetworkId: state.OdbNetworkId.ValueStringPointer(),
}

input.DeleteAssociatedResources = aws.Bool(false)
if !state.DeleteAssociatedResources.IsNull() || !state.DeleteAssociatedResources.IsUnknown() {
input.DeleteAssociatedResources = state.DeleteAssociatedResources.ValueBoolPointer()
}
_, err := conn.DeleteOdbNetwork(ctx, &input)

if err != nil {
Expand Down Expand Up @@ -651,33 +664,34 @@ func FindOracleDBNetworkResourceByID(ctx context.Context, conn *odb.Client, id s

type odbNetworkResourceModel struct {
framework.WithRegionModel
DisplayName types.String `tfsdk:"display_name"`
AvailabilityZone types.String `tfsdk:"availability_zone"`
AvailabilityZoneId types.String `tfsdk:"availability_zone_id"`
ClientSubnetCidr types.String `tfsdk:"client_subnet_cidr"`
BackupSubnetCidr types.String `tfsdk:"backup_subnet_cidr"`
CustomDomainName types.String `tfsdk:"custom_domain_name"`
DefaultDnsPrefix types.String `tfsdk:"default_dns_prefix"`
S3Access fwtypes.StringEnum[odbtypes.Access] `tfsdk:"s3_access" autoflex:",noflatten"`
ZeroEtlAccess fwtypes.StringEnum[odbtypes.Access] `tfsdk:"zero_etl_access" autoflex:",noflatten"`
S3PolicyDocument types.String `tfsdk:"s3_policy_document" autoflex:",noflatten"`
OdbNetworkId types.String `tfsdk:"id"`
PeeredCidrs fwtypes.SetValueOf[types.String] `tfsdk:"peered_cidrs"`
OciDnsForwardingConfigs fwtypes.ListNestedObjectValueOf[odbNwkOciDnsForwardingConfigResourceModel] `tfsdk:"oci_dns_forwarding_configs"`
OciNetworkAnchorId types.String `tfsdk:"oci_network_anchor_id"`
OciNetworkAnchorUrl types.String `tfsdk:"oci_network_anchor_url"`
OciResourceAnchorName types.String `tfsdk:"oci_resource_anchor_name"`
OciVcnId types.String `tfsdk:"oci_vcn_id"`
OciVcnUrl types.String `tfsdk:"oci_vcn_url"`
OdbNetworkArn types.String `tfsdk:"arn"`
PercentProgress types.Float32 `tfsdk:"percent_progress"`
Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"`
StatusReason types.String `tfsdk:"status_reason"`
Timeouts timeouts.Value `tfsdk:"timeouts"`
ManagedServices fwtypes.ListNestedObjectValueOf[odbNetworkManagedServicesResourceModel] `tfsdk:"managed_services"`
CreatedAt timetypes.RFC3339 `tfsdk:"created_at"`
Tags tftags.Map `tfsdk:"tags"`
TagsAll tftags.Map `tfsdk:"tags_all"`
DisplayName types.String `tfsdk:"display_name"`
AvailabilityZone types.String `tfsdk:"availability_zone"`
AvailabilityZoneId types.String `tfsdk:"availability_zone_id"`
ClientSubnetCidr types.String `tfsdk:"client_subnet_cidr"`
BackupSubnetCidr types.String `tfsdk:"backup_subnet_cidr"`
CustomDomainName types.String `tfsdk:"custom_domain_name"`
DefaultDnsPrefix types.String `tfsdk:"default_dns_prefix"`
S3Access fwtypes.StringEnum[odbtypes.Access] `tfsdk:"s3_access" autoflex:",noflatten"`
ZeroEtlAccess fwtypes.StringEnum[odbtypes.Access] `tfsdk:"zero_etl_access" autoflex:",noflatten"`
S3PolicyDocument types.String `tfsdk:"s3_policy_document" autoflex:",noflatten"`
OdbNetworkId types.String `tfsdk:"id"`
PeeredCidrs fwtypes.SetValueOf[types.String] `tfsdk:"peered_cidrs"`
OciDnsForwardingConfigs fwtypes.ListNestedObjectValueOf[odbNwkOciDnsForwardingConfigResourceModel] `tfsdk:"oci_dns_forwarding_configs"`
OciNetworkAnchorId types.String `tfsdk:"oci_network_anchor_id"`
OciNetworkAnchorUrl types.String `tfsdk:"oci_network_anchor_url"`
OciResourceAnchorName types.String `tfsdk:"oci_resource_anchor_name"`
OciVcnId types.String `tfsdk:"oci_vcn_id"`
OciVcnUrl types.String `tfsdk:"oci_vcn_url"`
OdbNetworkArn types.String `tfsdk:"arn"`
PercentProgress types.Float32 `tfsdk:"percent_progress"`
Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"`
StatusReason types.String `tfsdk:"status_reason"`
Timeouts timeouts.Value `tfsdk:"timeouts"`
ManagedServices fwtypes.ListNestedObjectValueOf[odbNetworkManagedServicesResourceModel] `tfsdk:"managed_services"`
CreatedAt timetypes.RFC3339 `tfsdk:"created_at"`
DeleteAssociatedResources types.Bool `tfsdk:"delete_associated_resources"`
Tags tftags.Map `tfsdk:"tags"`
TagsAll tftags.Map `tfsdk:"tags_all"`
}

type odbNwkOciDnsForwardingConfigResourceModel struct {
Expand Down
Loading
Loading