diff --git a/.ci/.semgrep-service-name0.yml b/.ci/.semgrep-service-name0.yml index 87d0ffadc241..505867179cd5 100644 --- a/.ci/.semgrep-service-name0.yml +++ b/.ci/.semgrep-service-name0.yml @@ -4376,18 +4376,3 @@ rules: - focus-metavariable: $NAME - pattern-not: func $NAME($T *testing.T) severity: WARNING - - id: connect-in-test-name - languages: - - go - message: Include "Connect" in test name - paths: - include: - - internal/service/connect/*_test.go - patterns: - - pattern: func $NAME( ... ) - - metavariable-pattern: - metavariable: $NAME - patterns: - - pattern-not-regex: "^TestAccConnect" - - pattern-regex: ^TestAcc.* - severity: WARNING diff --git a/.ci/.semgrep-service-name1.yml b/.ci/.semgrep-service-name1.yml index 26778435636f..9667e2aac131 100644 --- a/.ci/.semgrep-service-name1.yml +++ b/.ci/.semgrep-service-name1.yml @@ -1,5 +1,20 @@ # Generated by internal/generate/servicesemgrep/main.go; DO NOT EDIT. rules: + - id: connect-in-test-name + languages: + - go + message: Include "Connect" in test name + paths: + include: + - internal/service/connect/*_test.go + patterns: + - pattern: func $NAME( ... ) + - metavariable-pattern: + metavariable: $NAME + patterns: + - pattern-not-regex: "^TestAccConnect" + - pattern-regex: ^TestAcc.* + severity: WARNING - id: connect-in-const-name languages: - go @@ -4365,21 +4380,3 @@ rules: patterns: - pattern-regex: "(?i)Invoicing" severity: WARNING - - id: iot-in-func-name - languages: - - go - message: Do not use "IoT" in func name inside iot package - paths: - include: - - internal/service/iot - exclude: - - internal/service/iot/list_pages_gen.go - patterns: - - pattern: func $NAME( ... ) - - metavariable-pattern: - metavariable: $NAME - patterns: - - pattern-regex: "(?i)IoT" - - focus-metavariable: $NAME - - pattern-not: func $NAME($T *testing.T) - severity: WARNING diff --git a/.ci/.semgrep-service-name2.yml b/.ci/.semgrep-service-name2.yml index 177631291711..7b145a586f94 100644 --- a/.ci/.semgrep-service-name2.yml +++ b/.ci/.semgrep-service-name2.yml @@ -1,5 +1,23 @@ # Generated by internal/generate/servicesemgrep/main.go; DO NOT EDIT. rules: + - id: iot-in-func-name + languages: + - go + message: Do not use "IoT" in func name inside iot package + paths: + include: + - internal/service/iot + exclude: + - internal/service/iot/list_pages_gen.go + patterns: + - pattern: func $NAME( ... ) + - metavariable-pattern: + metavariable: $NAME + patterns: + - pattern-regex: "(?i)IoT" + - focus-metavariable: $NAME + - pattern-not: func $NAME($T *testing.T) + severity: WARNING - id: iot-in-test-name languages: - go @@ -3003,67 +3021,6 @@ rules: patterns: - pattern-regex: "(?i)ObservabilityAccessManager" severity: WARNING - - id: odb-in-func-name - languages: - - go - message: Do not use "ODB" in func name inside odb package - paths: - include: - - internal/service/odb - exclude: - - internal/service/odb/list_pages_gen.go - patterns: - - pattern: func $NAME( ... ) - - metavariable-pattern: - metavariable: $NAME - patterns: - - pattern-regex: "(?i)ODB" - - focus-metavariable: $NAME - - pattern-not: func $NAME($T *testing.T) - severity: WARNING - - id: odb-in-test-name - languages: - - go - message: Include "ODB" in test name - paths: - include: - - internal/service/odb/*_test.go - patterns: - - pattern: func $NAME( ... ) - - metavariable-pattern: - metavariable: $NAME - patterns: - - pattern-not-regex: "^TestAccODB" - - pattern-regex: ^TestAcc.* - severity: WARNING - - id: odb-in-const-name - languages: - - go - message: Do not use "ODB" in const name inside odb package - paths: - include: - - internal/service/odb - patterns: - - pattern: const $NAME = ... - - metavariable-pattern: - metavariable: $NAME - patterns: - - pattern-regex: "(?i)ODB" - severity: WARNING - - id: odb-in-var-name - languages: - - go - message: Do not use "ODB" in var name inside odb package - paths: - include: - - internal/service/odb - patterns: - - pattern: var $NAME = ... - - metavariable-pattern: - metavariable: $NAME - patterns: - - pattern-regex: "(?i)ODB" - severity: WARNING - id: opensearch-in-func-name languages: - go @@ -4399,3 +4356,17 @@ rules: patterns: - pattern-regex: "(?i)RDS" severity: WARNING + - id: rds-in-var-name + languages: + - go + message: Do not use "RDS" in var name inside rds package + paths: + include: + - internal/service/rds + patterns: + - pattern: var $NAME = ... + - metavariable-pattern: + metavariable: $NAME + patterns: + - pattern-regex: "(?i)RDS" + severity: WARNING diff --git a/.ci/.semgrep-service-name3.yml b/.ci/.semgrep-service-name3.yml index 5818938d1f26..bdca7386db66 100644 --- a/.ci/.semgrep-service-name3.yml +++ b/.ci/.semgrep-service-name3.yml @@ -1,19 +1,5 @@ # Generated by internal/generate/servicesemgrep/main.go; DO NOT EDIT. rules: - - id: rds-in-var-name - languages: - - go - message: Do not use "RDS" in var name inside rds package - paths: - include: - - internal/service/rds - patterns: - - pattern: var $NAME = ... - - metavariable-pattern: - metavariable: $NAME - patterns: - - pattern-regex: "(?i)RDS" - severity: WARNING - id: recyclebin-in-func-name languages: - go diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index a1bbf64f59b7..5e07c149b293 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -505,8 +505,6 @@ service/notificationscontacts: - '((\*|-)\s*`?|(data|resource)\s+"?)aws_notificationscontacts_' service/oam: - '((\*|-)\s*`?|(data|resource)\s+"?)aws_oam_' -service/odb: - - '((\*|-)\s*`?|(data|resource)\s+"?)aws_odb_' service/opensearch: - '((\*|-)\s*`?|(data|resource)\s+"?)aws_opensearch_' service/opensearchserverless: diff --git a/.github/labeler-pr-triage.yml b/.github/labeler-pr-triage.yml index 2d07161612a7..7d87c0503313 100644 --- a/.github/labeler-pr-triage.yml +++ b/.github/labeler-pr-triage.yml @@ -1602,12 +1602,6 @@ service/oam: - any-glob-to-any-file: - 'internal/service/oam/**/*' - 'website/**/oam_*' -service/odb: - - any: - - changed-files: - - any-glob-to-any-file: - - 'internal/service/odb/**/*' - - 'website/**/odb_*' service/opensearch: - any: - changed-files: diff --git a/.teamcity/components/generated/services_all.kt b/.teamcity/components/generated/services_all.kt index d8b76d8b3ed2..af54a68fba64 100644 --- a/.teamcity/components/generated/services_all.kt +++ b/.teamcity/components/generated/services_all.kt @@ -168,7 +168,6 @@ val services = mapOf( "notifications" to ServiceSpec("User Notifications"), "notificationscontacts" to ServiceSpec("User Notifications Contacts"), "oam" to ServiceSpec("CloudWatch Observability Access Manager"), - "odb" to ServiceSpec("Oracle Database@AWS"), "opensearch" to ServiceSpec("OpenSearch", vpcLock = true), "opensearchserverless" to ServiceSpec("OpenSearch Serverless"), "organizations" to ServiceSpec("Organizations"), diff --git a/infrastructure/repository/labels-service.tf b/infrastructure/repository/labels-service.tf index 862c8410b218..cd13188084d7 100644 --- a/infrastructure/repository/labels-service.tf +++ b/infrastructure/repository/labels-service.tf @@ -240,7 +240,6 @@ variable "service_labels" { "notifications", "notificationscontacts", "oam", - "odb", "opensearch", "opensearchserverless", "opsworks", diff --git a/internal/conns/awsclient_gen.go b/internal/conns/awsclient_gen.go index ca7e5101e520..4c14e3c15a83 100644 --- a/internal/conns/awsclient_gen.go +++ b/internal/conns/awsclient_gen.go @@ -171,7 +171,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/notifications" "github.com/aws/aws-sdk-go-v2/service/notificationscontacts" "github.com/aws/aws-sdk-go-v2/service/oam" - "github.com/aws/aws-sdk-go-v2/service/odb" "github.com/aws/aws-sdk-go-v2/service/opensearch" "github.com/aws/aws-sdk-go-v2/service/opensearchserverless" "github.com/aws/aws-sdk-go-v2/service/organizations" @@ -923,10 +922,6 @@ func (c *AWSClient) NotificationsContactsClient(ctx context.Context) *notificati return errs.Must(client[*notificationscontacts.Client](ctx, c, names.NotificationsContacts, make(map[string]any))) } -func (c *AWSClient) ODBClient(ctx context.Context) *odb.Client { - return errs.Must(client[*odb.Client](ctx, c, names.ODB, make(map[string]any))) -} - func (c *AWSClient) ObservabilityAccessManagerClient(ctx context.Context) *oam.Client { return errs.Must(client[*oam.Client](ctx, c, names.ObservabilityAccessManager, make(map[string]any))) } diff --git a/internal/provider/framework/provider_gen.go b/internal/provider/framework/provider_gen.go index 60149e451f1c..b0c5d9c5af7d 100644 --- a/internal/provider/framework/provider_gen.go +++ b/internal/provider/framework/provider_gen.go @@ -1354,13 +1354,6 @@ func endpointsBlock() schema.SetNestedBlock { Description: "Use this to override the default service endpoint URL", }, - // odb - - "odb": schema.StringAttribute{ - Optional: true, - Description: "Use this to override the default service endpoint URL", - }, - // opensearch "opensearch": schema.StringAttribute{ diff --git a/internal/provider/sdkv2/provider_gen.go b/internal/provider/sdkv2/provider_gen.go index 0c12b2c3382b..b4e5810e444c 100644 --- a/internal/provider/sdkv2/provider_gen.go +++ b/internal/provider/sdkv2/provider_gen.go @@ -1565,14 +1565,6 @@ func endpointsSchema() *schema.Schema { Description: "Use this to override the default service endpoint URL", }, - // odb - - "odb": { - Type: schema.TypeString, - Optional: true, - Description: "Use this to override the default service endpoint URL", - }, - // opensearch "opensearch": { diff --git a/internal/provider/sdkv2/service_packages_gen.go b/internal/provider/sdkv2/service_packages_gen.go index 08818e211ccf..fa6119d49328 100644 --- a/internal/provider/sdkv2/service_packages_gen.go +++ b/internal/provider/sdkv2/service_packages_gen.go @@ -175,7 +175,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/service/notifications" "github.com/hashicorp/terraform-provider-aws/internal/service/notificationscontacts" "github.com/hashicorp/terraform-provider-aws/internal/service/oam" - "github.com/hashicorp/terraform-provider-aws/internal/service/odb" "github.com/hashicorp/terraform-provider-aws/internal/service/opensearch" "github.com/hashicorp/terraform-provider-aws/internal/service/opensearchserverless" "github.com/hashicorp/terraform-provider-aws/internal/service/organizations" @@ -431,7 +430,6 @@ func servicePackages(ctx context.Context) []conns.ServicePackage { notifications.ServicePackage(ctx), notificationscontacts.ServicePackage(ctx), oam.ServicePackage(ctx), - odb.ServicePackage(ctx), opensearch.ServicePackage(ctx), opensearchserverless.ServicePackage(ctx), organizations.ServicePackage(ctx), diff --git a/internal/service/odb/cloud_autonomous_vm_cluster.go b/internal/service/odb/cloud_autonomous_vm_cluster.go deleted file mode 100644 index 97fee679bdc9..000000000000 --- a/internal/service/odb/cloud_autonomous_vm_cluster.go +++ /dev/null @@ -1,866 +0,0 @@ -// Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "errors" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/float64planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/int32planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" - "github.com/hashicorp/terraform-provider-aws/internal/enum" - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" - "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/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - "github.com/hashicorp/terraform-provider-aws/internal/errs/fwdiag" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/sweep" - sweepfw "github.com/hashicorp/terraform-provider-aws/internal/sweep/framework" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for resource registration to the Provider. DO NOT EDIT. -// @FrameworkResource("aws_odb_cloud_autonomous_vm_cluster", name="Cloud Autonomous Vm Cluster") -// @Tags(identifierAttribute="arn") -func newResourceCloudAutonomousVmCluster(_ context.Context) (resource.ResourceWithConfigure, error) { - r := &resourceCloudAutonomousVmCluster{} - r.SetDefaultCreateTimeout(24 * time.Hour) - r.SetDefaultUpdateTimeout(24 * time.Hour) - r.SetDefaultDeleteTimeout(24 * time.Hour) - - return r, nil -} - -const ( - ResNameCloudAutonomousVmCluster = "Cloud Autonomous Vm Cluster" - NotAvailableValues = "NOT_AVAILABLE" -) - -var ResourceCloudAutonomousVMCluster = newResourceCloudAutonomousVmCluster - -type resourceCloudAutonomousVmCluster struct { - framework.ResourceWithModel[cloudAutonomousVmClusterResourceModel] - framework.WithTimeouts -} - -func (r *resourceCloudAutonomousVmCluster) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - status := fwtypes.StringEnumType[odbtypes.ResourceStatus]() - licenseModel := fwtypes.StringEnumType[odbtypes.LicenseModel]() - computeModel := fwtypes.StringEnumType[odbtypes.ComputeModel]() - stringLengthBetween1And255Validator := []validator.String{ - stringvalidator.LengthBetween(1, 255), - } - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - names.AttrARN: framework.ARNAttributeComputedOnly(), - names.AttrID: framework.IDAttribute(), - "cloud_exadata_infrastructure_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "Exadata infrastructure id. Changing this will force terraform to create new resource.", - }, - "autonomous_data_storage_percentage": schema.Float32Attribute{ - Computed: true, - Description: "The progress of the current operation on the Autonomous VM cluster, as a percentage.", - }, - "autonomous_data_storage_size_in_tbs": schema.Float64Attribute{ - Required: true, - PlanModifiers: []planmodifier.Float64{ - float64planmodifier.RequiresReplace(), - }, - Description: "The data storage size allocated for Autonomous Databases in the Autonomous VM cluster, in TB. Changing this will force terraform to create new resource.", - }, - "available_autonomous_data_storage_size_in_tbs": schema.Float64Attribute{ - Computed: true, - Description: "The available data storage space for Autonomous Databases in the Autonomous VM cluster, in TB.", - }, - "available_container_databases": schema.Int32Attribute{ - Computed: true, - Description: "The number of Autonomous CDBs that you can create with the currently available storage.", - }, - "available_cpus": schema.Float32Attribute{ - Computed: true, - Description: "The number of CPU cores available for allocation to Autonomous Databases", - }, - "compute_model": schema.StringAttribute{ - CustomType: computeModel, - Computed: true, - Description: "The compute model of the Autonomous VM cluster: ECPU or OCPU.", - }, - "cpu_core_count": schema.Int32Attribute{ - Computed: true, - Description: "The total number of CPU cores in the Autonomous VM cluster.", - }, - "cpu_core_count_per_node": schema.Int32Attribute{ - Required: true, - PlanModifiers: []planmodifier.Int32{ - int32planmodifier.RequiresReplace(), - }, - Description: "The number of CPU cores enabled per node in the Autonomous VM cluster.", - }, - "cpu_percentage": schema.Float32Attribute{ - Computed: true, - Description: "The percentage of total CPU cores currently in use in the Autonomous VM cluster.", - }, - "created_at": schema.StringAttribute{ - Computed: true, - Description: "The date and time when the Autonomous VM cluster was created.", - }, - "data_storage_size_in_gbs": schema.Float64Attribute{ - Computed: true, - Description: "The total data storage allocated to the Autonomous VM cluster, in GB.", - }, - "data_storage_size_in_tbs": schema.Float64Attribute{ - Computed: true, - Description: "The total data storage allocated to the Autonomous VM cluster, in TB.", - }, - "odb_node_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: " The local node storage allocated to the Autonomous VM cluster, in gigabytes (GB)", - }, - "db_servers": schema.SetAttribute{ - Required: true, - CustomType: fwtypes.SetOfStringType, - ElementType: types.StringType, - PlanModifiers: []planmodifier.Set{ - setplanmodifier.RequiresReplace(), - }, - Description: "The database servers in the Autonomous VM cluster. Changing this will force terraform to create new resource.", - }, - "description": schema.StringAttribute{ - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - stringplanmodifier.UseStateForUnknown(), - }, - Description: "The description of the Autonomous VM cluster.", - }, - "display_name": schema.StringAttribute{ - Required: true, - Validators: stringLengthBetween1And255Validator, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "The display name of the Autonomous VM cluster. Changing this will force terraform to create new resource.", - }, - "domain": schema.StringAttribute{ - Computed: true, - Description: "The domain name of the Autonomous VM cluster.", - }, - "exadata_storage_in_tbs_lowest_scaled_value": schema.Float64Attribute{ - Computed: true, - Description: "The minimum value to which you can scale down the Exadata storage, in TB.", - }, - "hostname": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - Description: "The hostname of the Autonomous VM cluster.", - }, - "is_mtls_enabled_vm_cluster": schema.BoolAttribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.RequiresReplace(), - boolplanmodifier.UseStateForUnknown(), - }, - Description: "Indicates whether mutual TLS (mTLS) authentication is enabled for the Autonomous VM cluster. Changing this will force terraform to create new resource. ", - }, - "license_model": schema.StringAttribute{ - CustomType: licenseModel, - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - stringplanmodifier.UseStateForUnknown(), - }, - Description: "The license model for the Autonomous VM cluster. Valid values are LICENSE_INCLUDED or BRING_YOUR_OWN_LICENSE . Changing this will force terraform to create new resource.", - }, - "max_acds_lowest_scaled_value": schema.Int32Attribute{ - Computed: true, - Description: "The minimum value to which you can scale down the maximum number of Autonomous CDBs.", - }, - "memory_per_oracle_compute_unit_in_gbs": schema.Int32Attribute{ - Required: true, - PlanModifiers: []planmodifier.Int32{ - int32planmodifier.RequiresReplace(), - }, - Description: "The amount of memory allocated per Oracle Compute Unit, in GB. Changing this will force terraform to create new resource.", - }, - "memory_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The total amount of memory allocated to the Autonomous VM cluster, in gigabytes(GB).", - }, - "node_count": schema.Int32Attribute{ - Computed: true, - Description: "The number of database server nodes in the Autonomous VM cluster.", - }, - "non_provisionable_autonomous_container_databases": schema.Int32Attribute{ - Computed: true, - Description: "The number of Autonomous CDBs that can't be provisioned because of resource constraints.", - }, - "oci_resource_anchor_name": schema.StringAttribute{ - Computed: true, - Description: "The name of the OCI resource anchor associated with this Autonomous VM cluster.", - }, - "oci_url": schema.StringAttribute{ - Computed: true, - Description: "The URL for accessing the OCI console page for this Autonomous VM cluster.", - }, - "ocid": schema.StringAttribute{ - Computed: true, - Description: "The Oracle Cloud Identifier (OCID) of the Autonomous VM cluster.", - }, - "odb_network_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "The unique identifier of the ODB network associated with this Autonomous VM Cluster. Changing this will force terraform to create new resource.", - }, - "percent_progress": schema.Float32Attribute{ - Computed: true, - Description: `The progress of the current operation on the Autonomous VM cluster, as a percentage.`, - }, - "provisionable_autonomous_container_databases": schema.Int32Attribute{ - Computed: true, - Description: "The number of Autonomous CDBs that can be provisioned in the Autonomous VM cluster.", - }, - "provisioned_autonomous_container_databases": schema.Int32Attribute{ - Computed: true, - Description: "The number of Autonomous CDBs currently provisioned in the Autonomous VM cluster.", - }, - "provisioned_cpus": schema.Float32Attribute{ - Computed: true, - Description: "The number of CPUs provisioned in the Autonomous VM cluster.", - }, - "reclaimable_cpus": schema.Float32Attribute{ - Computed: true, - Description: "The number of CPU cores that can be reclaimed from terminated or scaled-down Autonomous Databases.", - }, - "reserved_cpus": schema.Float32Attribute{ - Computed: true, - Description: "The number of CPU cores reserved for system operations and redundancy.", - }, - "scan_listener_port_non_tls": schema.Int32Attribute{ - Required: true, - PlanModifiers: []planmodifier.Int32{ - int32planmodifier.RequiresReplace(), - }, - Description: "The SCAN listener port for non-TLS (TCP) protocol. The default is 1521. Changing this will force terraform to create new resource.", - }, - "scan_listener_port_tls": schema.Int32Attribute{ - Required: true, - PlanModifiers: []planmodifier.Int32{ - int32planmodifier.RequiresReplace(), - }, - Description: "The SCAN listener port for TLS (TCP) protocol. The default is 2484. Changing this will force terraform to create new resource.", - }, - "shape": schema.StringAttribute{ - Computed: true, - Description: "The shape of the Exadata infrastructure for the Autonomous VM cluster.", - }, - "status": schema.StringAttribute{ - CustomType: status, - Computed: true, - Description: "The status of the Autonomous VM cluster. Possible values include CREATING, AVAILABLE , UPDATING , DELETING , DELETED , FAILED ", - }, - "status_reason": schema.StringAttribute{ - Computed: true, - Description: "Additional information about the current status of the Autonomous VM cluster.", - }, - "time_zone": schema.StringAttribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - stringplanmodifier.UseStateForUnknown(), - }, - Description: "The time zone of the Autonomous VM cluster. Changing this will force terraform to create new resource.", - }, - "total_container_databases": schema.Int32Attribute{ - Required: true, - PlanModifiers: []planmodifier.Int32{ - int32planmodifier.RequiresReplace(), - }, - Description: "The total number of Autonomous Container Databases that can be created with the allocated local storage. Changing this will force terraform to create new resource.", - }, - "time_ords_certificate_expires": schema.StringAttribute{ - Computed: true, - }, - "time_database_ssl_certificate_expires": schema.StringAttribute{ - Computed: true, - Description: "The expiration date and time of the database SSL certificate.", - }, - "maintenance_window": schema.ObjectAttribute{ - Required: true, - CustomType: fwtypes.NewObjectTypeOf[cloudAutonomousVmClusterMaintenanceWindowResourceModel](ctx), - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), - }, - Description: "The maintenance window of the Autonomous VM cluster.", - AttributeTypes: map[string]attr.Type{ - "days_of_week": types.SetType{ - ElemType: fwtypes.StringEnumType[odbtypes.DayOfWeekName](), - }, - "hours_of_day": types.SetType{ - ElemType: types.Int32Type, - }, - "lead_time_in_weeks": types.Int32Type, - "months": types.SetType{ - ElemType: fwtypes.StringEnumType[odbtypes.MonthName](), - }, - "preference": fwtypes.StringEnumType[odbtypes.PreferenceType](), - "weeks_of_month": types.SetType{ - ElemType: types.Int32Type, - }, - }, - }, - names.AttrTags: tftags.TagsAttribute(), - names.AttrTagsAll: tftags.TagsAttributeComputedOnly(), - }, - Blocks: map[string]schema.Block{ - names.AttrTimeouts: timeouts.Block(ctx, timeouts.Opts{ - Create: true, - Update: true, - Delete: true, - }), - }, - } -} - -func (r *resourceCloudAutonomousVmCluster) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - conn := r.Meta().ODBClient(ctx) - - var plan cloudAutonomousVmClusterResourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.CreateCloudAutonomousVmClusterInput{ - ClientToken: aws.String(id.UniqueId()), - Tags: getTagsIn(ctx), - MaintenanceWindow: r.expandMaintenanceWindow(ctx, plan.MaintenanceWindow), - } - resp.Diagnostics.Append(flex.Expand(ctx, plan, &input)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := conn.CreateCloudAutonomousVmCluster(ctx, &input) - if err != nil { - - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameCloudAutonomousVmCluster, plan.DisplayName.ValueString(), err), - err.Error(), - ) - return - } - if out == nil || out.CloudAutonomousVmClusterId == nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameCloudAutonomousVmCluster, plan.DisplayName.ValueString(), nil), - errors.New("empty output").Error(), - ) - return - } - - createTimeout := r.CreateTimeout(ctx, plan.Timeouts) - createdAVMC, err := waitCloudAutonomousVmClusterCreated(ctx, conn, *out.CloudAutonomousVmClusterId, createTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForCreation, ResNameCloudAutonomousVmCluster, plan.DisplayName.ValueString(), err), - err.Error(), - ) - return - } - plan.CreatedAt = types.StringValue(createdAVMC.CreatedAt.Format(time.RFC3339)) - - if createdAVMC.TimeDatabaseSslCertificateExpires != nil { - plan.TimeDatabaseSslCertificateExpires = types.StringValue(createdAVMC.TimeDatabaseSslCertificateExpires.Format(time.RFC3339)) - } else { - plan.TimeDatabaseSslCertificateExpires = types.StringValue(NotAvailableValues) - } - - if createdAVMC.TimeOrdsCertificateExpires != nil { - plan.TimeOrdsCertificateExpires = types.StringValue(createdAVMC.TimeOrdsCertificateExpires.Format(time.RFC3339)) - } else { - plan.TimeOrdsCertificateExpires = types.StringValue(NotAvailableValues) - } - - if createdAVMC.MaintenanceWindow != nil { - plan.MaintenanceWindow = r.flattenMaintenanceWindow(ctx, createdAVMC.MaintenanceWindow) - } - resp.Diagnostics.Append(flex.Flatten(ctx, createdAVMC, &plan, - flex.WithIgnoredFieldNamesAppend("TimeOrdsCertificateExpires"), - flex.WithIgnoredFieldNamesAppend("TimeDatabaseSslCertificateExpires"))...) - - resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) -} - -func (r *resourceCloudAutonomousVmCluster) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - - conn := r.Meta().ODBClient(ctx) - - var state cloudAutonomousVmClusterResourceModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := FindCloudAutonomousVmClusterByID(ctx, conn, state.CloudAutonomousVmClusterId.ValueString()) - - if tfresource.NotFound(err) { - resp.Diagnostics.Append(fwdiag.NewResourceNotFoundWarningDiagnostic(err)) - resp.State.RemoveResource(ctx) - return - } - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, ResNameCloudAutonomousVmCluster, state.DisplayName.ValueString(), err), - err.Error(), - ) - return - } - - state.CreatedAt = types.StringValue(out.CreatedAt.Format(time.RFC3339)) - if out.TimeOrdsCertificateExpires != nil { - state.TimeOrdsCertificateExpires = types.StringValue(out.TimeOrdsCertificateExpires.Format(time.RFC3339)) - } else { - state.TimeOrdsCertificateExpires = types.StringValue(NotAvailableValues) - } - if out.TimeDatabaseSslCertificateExpires != nil { - state.TimeDatabaseSslCertificateExpires = types.StringValue(out.TimeDatabaseSslCertificateExpires.Format(time.RFC3339)) - } else { - state.TimeDatabaseSslCertificateExpires = types.StringValue(NotAvailableValues) - } - state.MaintenanceWindow = r.flattenMaintenanceWindow(ctx, out.MaintenanceWindow) - - resp.Diagnostics.Append(flex.Flatten(ctx, out, &state, - flex.WithIgnoredFieldNamesAppend("TimeOrdsCertificateExpires"), - flex.WithIgnoredFieldNamesAppend("TimeDatabaseSslCertificateExpires"))...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) -} - -func (r *resourceCloudAutonomousVmCluster) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - - var plan, state cloudAutonomousVmClusterResourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - conn := r.Meta().ODBClient(ctx) - - updateTimeout := r.UpdateTimeout(ctx, plan.Timeouts) - updatedAVMC, err := waitCloudAutonomousVmClusterUpdated(ctx, conn, state.CloudAutonomousVmClusterId.ValueString(), updateTimeout) - - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameCloudAutonomousVmCluster, state.CloudAutonomousVmClusterId.String(), err), - err.Error(), - ) - return - } - plan.CreatedAt = types.StringValue(updatedAVMC.CreatedAt.Format(time.RFC3339)) - - if updatedAVMC.TimeDatabaseSslCertificateExpires != nil { - plan.TimeDatabaseSslCertificateExpires = types.StringValue(updatedAVMC.TimeDatabaseSslCertificateExpires.Format(time.RFC3339)) - } else { - plan.TimeDatabaseSslCertificateExpires = types.StringValue(NotAvailableValues) - } - - if updatedAVMC.TimeOrdsCertificateExpires != nil { - plan.TimeOrdsCertificateExpires = types.StringValue(updatedAVMC.TimeOrdsCertificateExpires.Format(time.RFC3339)) - } else { - plan.TimeOrdsCertificateExpires = types.StringValue(NotAvailableValues) - } - plan.MaintenanceWindow = r.flattenMaintenanceWindow(ctx, updatedAVMC.MaintenanceWindow) - resp.Diagnostics.Append(flex.Flatten(ctx, updatedAVMC, &plan, - flex.WithIgnoredFieldNamesAppend("TimeOrdsCertificateExpires"), - flex.WithIgnoredFieldNamesAppend("TimeDatabaseSslCertificateExpires"))...) - - if resp.Diagnostics.HasError() { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) -} - -func (r *resourceCloudAutonomousVmCluster) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - - conn := r.Meta().ODBClient(ctx) - - var state cloudAutonomousVmClusterResourceModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.DeleteCloudAutonomousVmClusterInput{ - CloudAutonomousVmClusterId: state.CloudAutonomousVmClusterId.ValueStringPointer(), - } - - _, err := conn.DeleteCloudAutonomousVmCluster(ctx, &input) - - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return - } - - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionDeleting, ResNameCloudAutonomousVmCluster, state.CloudAutonomousVmClusterId.ValueString(), err), - err.Error(), - ) - return - } - deleteTimeout := r.DeleteTimeout(ctx, state.Timeouts) - _, err = waitCloudAutonomousVmClusterDeleted(ctx, conn, state.CloudAutonomousVmClusterId.ValueString(), deleteTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForDeletion, ResNameCloudAutonomousVmCluster, state.CloudAutonomousVmClusterId.ValueString(), err), - err.Error(), - ) - return - } -} - -func (r *resourceCloudAutonomousVmCluster) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resource.ImportStatePassthroughID(ctx, path.Root(names.AttrID), req, resp) -} - -func waitCloudAutonomousVmClusterCreated(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.CloudAutonomousVmCluster, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusProvisioning), - Target: enum.Slice(odbtypes.ResourceStatusAvailable, odbtypes.ResourceStatusFailed), - Refresh: statusCloudAutonomousVmCluster(ctx, conn, id), - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.CloudAutonomousVmCluster); ok { - return out, err - } - - return nil, err -} - -func waitCloudAutonomousVmClusterUpdated(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.CloudAutonomousVmCluster, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusUpdating), - Target: enum.Slice(odbtypes.ResourceStatusAvailable, odbtypes.ResourceStatusFailed), - Refresh: statusCloudAutonomousVmCluster(ctx, conn, id), - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.CloudAutonomousVmCluster); ok { - return out, err - } - - return nil, err -} - -func waitCloudAutonomousVmClusterDeleted(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.CloudAutonomousVmCluster, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusTerminating), - Target: []string{}, - Refresh: statusCloudAutonomousVmCluster(ctx, conn, id), - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.CloudAutonomousVmCluster); ok { - return out, err - } - - return nil, err -} - -func statusCloudAutonomousVmCluster(ctx context.Context, conn *odb.Client, id string) retry.StateRefreshFunc { - return func() (any, string, error) { - out, err := FindCloudAutonomousVmClusterByID(ctx, conn, id) - if tfresource.NotFound(err) { - return nil, "", nil - } - - if err != nil { - return nil, "", err - } - - return out, string(out.Status), nil - } -} - -func FindCloudAutonomousVmClusterByID(ctx context.Context, conn *odb.Client, id string) (*odbtypes.CloudAutonomousVmCluster, error) { - input := odb.GetCloudAutonomousVmClusterInput{ - CloudAutonomousVmClusterId: aws.String(id), - } - out, err := conn.GetCloudAutonomousVmCluster(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - return nil, err - } - - if out == nil || out.CloudAutonomousVmCluster == nil { - return nil, tfresource.NewEmptyResultError(&input) - } - - return out.CloudAutonomousVmCluster, nil -} - -// TIP: ==== SWEEPERS ==== -// When acceptance testing resources, interrupted or failed tests may -// leave behind orphaned resources in an account. To facilitate cleaning -// up lingering resources, each resource implementation should include -// a corresponding "sweeper" function. -// -// The sweeper function lists all resources of a given type and sets the -// appropriate identifers required to delete the resource via the Delete -// method implemented above. -// -// Once the sweeper function is implemented, register it in sweeper.go -// as follows: -// -// awsv2.Register("aws_odb_cloud_autonomous_vm_cluster", sweepCloudAutonomousVmClusters) -// -// See more: -// https://hashicorp.github.io/terraform-provider-aws/running-and-writing-acceptance-tests/#acceptance-test-sweepers -func sweepCloudAutonomousVmClusters(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) { - input := odb.ListCloudAutonomousVmClustersInput{} - conn := client.ODBClient(ctx) - var sweepResources []sweep.Sweepable - - pages := odb.NewListCloudAutonomousVmClustersPaginator(conn, &input) - for pages.HasMorePages() { - page, err := pages.NextPage(ctx) - if err != nil { - return nil, err - } - - for _, v := range page.CloudAutonomousVmClusters { - sweepResources = append(sweepResources, sweepfw.NewSweepResource(newResourceCloudAutonomousVmCluster, client, - sweepfw.NewAttribute(names.AttrID, aws.ToString(v.CloudAutonomousVmClusterId))), - ) - } - } - - return sweepResources, nil -} - -func (r *resourceCloudAutonomousVmCluster) expandMaintenanceWindow(ctx context.Context, avmcMaintenanceWindowFwTypesObj fwtypes.ObjectValueOf[cloudAutonomousVmClusterMaintenanceWindowResourceModel]) *odbtypes.MaintenanceWindow { - var avmcMaintenanceWindowResource cloudAutonomousVmClusterMaintenanceWindowResourceModel - - avmcMaintenanceWindowFwTypesObj.As(ctx, &avmcMaintenanceWindowResource, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - }) - - var daysOfWeekNames []odbtypes.DayOfWeekName - avmcMaintenanceWindowResource.DaysOfWeek.ElementsAs(ctx, &daysOfWeekNames, false) - daysOfWeek := make([]odbtypes.DayOfWeek, 0, len(daysOfWeekNames)) - - for _, dayOfWeek := range daysOfWeekNames { - daysOfWeek = append(daysOfWeek, odbtypes.DayOfWeek{ - Name: dayOfWeek, - }) - } - - var hoursOfTheDay []int32 - avmcMaintenanceWindowResource.HoursOfDay.ElementsAs(ctx, &hoursOfTheDay, false) - - var monthNames []odbtypes.MonthName - avmcMaintenanceWindowResource.Months.ElementsAs(ctx, &monthNames, false) - months := make([]odbtypes.Month, 0, len(monthNames)) - for _, month := range monthNames { - months = append(months, odbtypes.Month{ - Name: month, - }) - } - - var weeksOfMonth []int32 - avmcMaintenanceWindowResource.WeeksOfMonth.ElementsAs(ctx, &weeksOfMonth, false) - - odbTypeMW := odbtypes.MaintenanceWindow{ - DaysOfWeek: daysOfWeek, - HoursOfDay: hoursOfTheDay, - LeadTimeInWeeks: avmcMaintenanceWindowResource.LeadTimeInWeeks.ValueInt32Pointer(), - Months: months, - Preference: avmcMaintenanceWindowResource.Preference.ValueEnum(), - WeeksOfMonth: weeksOfMonth, - } - if len(odbTypeMW.DaysOfWeek) == 0 { - odbTypeMW.DaysOfWeek = nil - } - if len(odbTypeMW.HoursOfDay) == 0 { - odbTypeMW.HoursOfDay = nil - } - if len(odbTypeMW.Months) == 0 { - odbTypeMW.Months = nil - } - if len(odbTypeMW.WeeksOfMonth) == 0 { - odbTypeMW.WeeksOfMonth = nil - } - if *odbTypeMW.LeadTimeInWeeks == 0 { - odbTypeMW.LeadTimeInWeeks = nil - } - return &odbTypeMW -} - -func (r *resourceCloudAutonomousVmCluster) flattenMaintenanceWindow(ctx context.Context, avmcMW *odbtypes.MaintenanceWindow) fwtypes.ObjectValueOf[cloudAutonomousVmClusterMaintenanceWindowResourceModel] { - //days of week - daysOfWeek := make([]attr.Value, 0, len(avmcMW.DaysOfWeek)) - for _, dayOfWeek := range avmcMW.DaysOfWeek { - dayOfWeekStringValue := fwtypes.StringEnumValue(dayOfWeek.Name).StringValue - daysOfWeek = append(daysOfWeek, dayOfWeekStringValue) - } - setValueOfDaysOfWeek, _ := basetypes.NewSetValue(types.StringType, daysOfWeek) - daysOfWeekRead := fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.DayOfWeekName]]{ - SetValue: setValueOfDaysOfWeek, - } - //hours of the day - hoursOfTheDay := make([]attr.Value, 0, len(avmcMW.HoursOfDay)) - for _, hourOfTheDay := range avmcMW.HoursOfDay { - daysOfWeekInt32Value := types.Int32Value(hourOfTheDay) - hoursOfTheDay = append(hoursOfTheDay, daysOfWeekInt32Value) - } - setValuesOfHoursOfTheDay, _ := basetypes.NewSetValue(types.Int32Type, hoursOfTheDay) - hoursOfTheDayRead := fwtypes.SetValueOf[types.Int32]{ - SetValue: setValuesOfHoursOfTheDay, - } - //monts - months := make([]attr.Value, 0, len(avmcMW.Months)) - for _, month := range avmcMW.Months { - monthStringValue := fwtypes.StringEnumValue(month.Name).StringValue - months = append(months, monthStringValue) - } - setValuesOfMonth, _ := basetypes.NewSetValue(types.StringType, months) - monthsRead := fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.MonthName]]{ - SetValue: setValuesOfMonth, - } - //weeks of month - weeksOfMonth := make([]attr.Value, 0, len(avmcMW.WeeksOfMonth)) - for _, weekOfMonth := range avmcMW.WeeksOfMonth { - weeksOfMonthInt32Value := types.Int32Value(weekOfMonth) - weeksOfMonth = append(weeksOfMonth, weeksOfMonthInt32Value) - } - setValuesOfWeekOfMonth, _ := basetypes.NewSetValue(types.Int32Type, weeksOfMonth) - weeksOfMonthRead := fwtypes.SetValueOf[types.Int32]{ - SetValue: setValuesOfWeekOfMonth, - } - - computedMW := cloudAutonomousVmClusterMaintenanceWindowResourceModel{ - DaysOfWeek: daysOfWeekRead, - HoursOfDay: hoursOfTheDayRead, - LeadTimeInWeeks: types.Int32PointerValue(avmcMW.LeadTimeInWeeks), - Months: monthsRead, - Preference: fwtypes.StringEnumValue(avmcMW.Preference), - WeeksOfMonth: weeksOfMonthRead, - } - if avmcMW.LeadTimeInWeeks == nil { - computedMW.LeadTimeInWeeks = types.Int32Value(0) - } - result, _ := fwtypes.NewObjectValueOf[cloudAutonomousVmClusterMaintenanceWindowResourceModel](ctx, &computedMW) - return result -} - -type cloudAutonomousVmClusterResourceModel struct { - framework.WithRegionModel - CloudAutonomousVmClusterArn types.String `tfsdk:"arn"` - CloudAutonomousVmClusterId types.String `tfsdk:"id"` - CloudExadataInfrastructureId types.String `tfsdk:"cloud_exadata_infrastructure_id"` - AutonomousDataStoragePercentage types.Float32 `tfsdk:"autonomous_data_storage_percentage"` - AutonomousDataStorageSizeInTBs types.Float64 `tfsdk:"autonomous_data_storage_size_in_tbs"` - AvailableAutonomousDataStorageSizeInTBs types.Float64 `tfsdk:"available_autonomous_data_storage_size_in_tbs"` - AvailableContainerDatabases types.Int32 `tfsdk:"available_container_databases"` - AvailableCpus types.Float32 `tfsdk:"available_cpus"` - ComputeModel fwtypes.StringEnum[odbtypes.ComputeModel] `tfsdk:"compute_model"` - CpuCoreCount types.Int32 `tfsdk:"cpu_core_count"` - CpuCoreCountPerNode types.Int32 `tfsdk:"cpu_core_count_per_node"` - CpuPercentage types.Float32 `tfsdk:"cpu_percentage"` - CreatedAt types.String `tfsdk:"created_at" autoflex:",noflatten"` - DataStorageSizeInGBs types.Float64 `tfsdk:"data_storage_size_in_gbs"` - DataStorageSizeInTBs types.Float64 `tfsdk:"data_storage_size_in_tbs"` - DbNodeStorageSizeInGBs types.Int32 `tfsdk:"odb_node_storage_size_in_gbs"` - DbServers fwtypes.SetValueOf[types.String] `tfsdk:"db_servers"` - Description types.String `tfsdk:"description"` - DisplayName types.String `tfsdk:"display_name"` - Domain types.String `tfsdk:"domain"` - ExadataStorageInTBsLowestScaledValue types.Float64 `tfsdk:"exadata_storage_in_tbs_lowest_scaled_value"` - Hostname types.String `tfsdk:"hostname"` - IsMtlsEnabledVmCluster types.Bool `tfsdk:"is_mtls_enabled_vm_cluster"` - LicenseModel fwtypes.StringEnum[odbtypes.LicenseModel] `tfsdk:"license_model"` - MaxAcdsLowestScaledValue types.Int32 `tfsdk:"max_acds_lowest_scaled_value"` - MemoryPerOracleComputeUnitInGBs types.Int32 `tfsdk:"memory_per_oracle_compute_unit_in_gbs"` - MemorySizeInGBs types.Int32 `tfsdk:"memory_size_in_gbs"` - NodeCount types.Int32 `tfsdk:"node_count"` - NonProvisionableAutonomousContainerDatabases types.Int32 `tfsdk:"non_provisionable_autonomous_container_databases"` - OciResourceAnchorName types.String `tfsdk:"oci_resource_anchor_name"` - OciUrl types.String `tfsdk:"oci_url"` - Ocid types.String `tfsdk:"ocid"` - OdbNetworkId types.String `tfsdk:"odb_network_id"` - PercentProgress types.Float32 `tfsdk:"percent_progress"` - ProvisionableAutonomousContainerDatabases types.Int32 `tfsdk:"provisionable_autonomous_container_databases"` - ProvisionedAutonomousContainerDatabases types.Int32 `tfsdk:"provisioned_autonomous_container_databases"` - ProvisionedCpus types.Float32 `tfsdk:"provisioned_cpus"` - ReclaimableCpus types.Float32 `tfsdk:"reclaimable_cpus"` - ReservedCpus types.Float32 `tfsdk:"reserved_cpus"` - ScanListenerPortNonTls types.Int32 `tfsdk:"scan_listener_port_non_tls"` - ScanListenerPortTls types.Int32 `tfsdk:"scan_listener_port_tls"` - Shape types.String `tfsdk:"shape"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - TimeZone types.String `tfsdk:"time_zone"` - TotalContainerDatabases types.Int32 `tfsdk:"total_container_databases"` - Timeouts timeouts.Value `tfsdk:"timeouts"` - Tags tftags.Map `tfsdk:"tags"` - TagsAll tftags.Map `tfsdk:"tags_all"` - TimeOrdsCertificateExpires types.String `tfsdk:"time_ords_certificate_expires"` - TimeDatabaseSslCertificateExpires types.String `tfsdk:"time_database_ssl_certificate_expires"` - MaintenanceWindow fwtypes.ObjectValueOf[cloudAutonomousVmClusterMaintenanceWindowResourceModel] `tfsdk:"maintenance_window" autoflex:"-"` -} - -type cloudAutonomousVmClusterMaintenanceWindowResourceModel struct { - DaysOfWeek fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.DayOfWeekName]] `tfsdk:"days_of_week"` - HoursOfDay fwtypes.SetValueOf[types.Int32] `tfsdk:"hours_of_day"` - LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"` - Months fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.MonthName]] `tfsdk:"months"` - Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"` - WeeksOfMonth fwtypes.SetValueOf[types.Int32] `tfsdk:"weeks_of_month"` -} diff --git a/internal/service/odb/cloud_autonomous_vm_cluster_data_source.go b/internal/service/odb/cloud_autonomous_vm_cluster_data_source.go deleted file mode 100644 index ce561fff9d4d..000000000000 --- a/internal/service/odb/cloud_autonomous_vm_cluster_data_source.go +++ /dev/null @@ -1,433 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "time" - - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_cloud_autonomous_vm_cluster", name="Cloud Autonomous Vm Cluster") -func newDataSourceCloudAutonomousVmCluster(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceCloudAutonomousVmCluster{}, nil -} - -const ( - DSNameCloudAutonomousVmCluster = "Cloud Autonomous Vm Cluster Data Source" -) - -type dataSourceCloudAutonomousVmCluster struct { - framework.DataSourceWithModel[cloudAutonomousVmClusterDataSourceModel] -} - -func (d *dataSourceCloudAutonomousVmCluster) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - status := fwtypes.StringEnumType[odbtypes.ResourceStatus]() - licenseModel := fwtypes.StringEnumType[odbtypes.LicenseModel]() - computeModel := fwtypes.StringEnumType[odbtypes.ComputeModel]() - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - names.AttrARN: framework.ARNAttributeComputedOnly(), - - names.AttrID: schema.StringAttribute{ - Required: true, - Description: "Unique ID of the Autonomous VM cluster.", - }, - "cloud_exadata_infrastructure_id": schema.StringAttribute{ - Computed: true, - Description: "Cloud exadata infrastructure id associated with this cloud autonomous VM cluster.", - }, - "autonomous_data_storage_percentage": schema.Float32Attribute{ - Computed: true, - Description: "The percentage of data storage currently in use for Autonomous Databases in the Autonomous VM cluster.", - }, - "autonomous_data_storage_size_in_tbs": schema.Float64Attribute{ - Computed: true, - Description: "The data storage size allocated for Autonomous Databases in the Autonomous VM cluster, in TB.", - }, - "available_autonomous_data_storage_size_in_tbs": schema.Float64Attribute{ - Computed: true, - Description: "The available data storage space for Autonomous Databases in the Autonomous VM cluster, in TB.", - }, - "available_container_databases": schema.Int32Attribute{ - Computed: true, - Description: "The number of Autonomous CDBs that you can create with the currently available storage.", - }, - "available_cpus": schema.Float32Attribute{ - Computed: true, - Description: "The number of CPU cores available for allocation to Autonomous Databases.", - }, - "compute_model": schema.StringAttribute{ - CustomType: computeModel, - Computed: true, - Description: " The compute model of the Autonomous VM cluster: ECPU or OCPU.", - }, - "cpu_core_count": schema.Int32Attribute{ - Computed: true, - Description: "The total number of CPU cores in the Autonomous VM cluster.", - }, - "cpu_core_count_per_node": schema.Int32Attribute{ - Computed: true, - Description: "The number of CPU cores enabled per node in the Autonomous VM cluster.", - }, - "cpu_percentage": schema.Float32Attribute{ - Computed: true, - Description: "he percentage of total CPU cores currently in use in the Autonomous VM cluster.", - }, - "created_at": schema.StringAttribute{ - Computed: true, - Description: "The date and time when the Autonomous VM cluster was created.", - }, - "data_storage_size_in_gbs": schema.Float64Attribute{ - Computed: true, - Description: "The total data storage allocated to the Autonomous VM cluster, in GB.", - }, - "data_storage_size_in_tbs": schema.Float64Attribute{ - Computed: true, - Description: "The total data storage allocated to the Autonomous VM cluster, in TB.", - }, - "odb_node_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The local node storage allocated to the Autonomous VM cluster, in gigabytes (GB).", - }, - "db_servers": schema.SetAttribute{ - Computed: true, - CustomType: fwtypes.SetOfStringType, - ElementType: types.StringType, - Description: "The list of database servers associated with the Autonomous VM cluster.", - }, - "description": schema.StringAttribute{ - Computed: true, - Description: "The user-provided description of the Autonomous VM cluster.", - }, - "display_name": schema.StringAttribute{ - Computed: true, - Description: "The display name of the Autonomous VM cluster.", - }, - "domain": schema.StringAttribute{ - Computed: true, - Description: "The domain name of the Autonomous VM cluster.", - }, - "exadata_storage_in_tbs_lowest_scaled_value": schema.Float64Attribute{ - Computed: true, - Description: "The minimum value to which you can scale down the Exadata storage, in TB.", - }, - "hostname": schema.StringAttribute{ - Computed: true, - Description: "The hostname of the Autonomous VM cluster.", - }, - "is_mtls_enabled_vm_cluster": schema.BoolAttribute{ - Computed: true, - Description: " Indicates whether mutual TLS (mTLS) authentication is enabled for the Autonomous VM cluster.", - }, - "license_model": schema.StringAttribute{ - CustomType: licenseModel, - Computed: true, - Description: "The Oracle license model that applies to the Autonomous VM cluster. Valid values are LICENSE_INCLUDED or BRING_YOUR_OWN_LICENSE .", - }, - "max_acds_lowest_scaled_value": schema.Int32Attribute{ - Computed: true, - Description: "The minimum value to which you can scale down the maximum number of Autonomous CDBs.", - }, - "memory_per_oracle_compute_unit_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The amount of memory allocated per Oracle Compute Unit, in GB.", - }, - "memory_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The total amount of memory allocated to the Autonomous VM cluster, in gigabytes (GB).", - }, - "node_count": schema.Int32Attribute{ - Computed: true, - Description: "The number of database server nodes in the Autonomous VM cluster.", - }, - "non_provisionable_autonomous_container_databases": schema.Int32Attribute{ - Computed: true, - Description: "The number of Autonomous CDBs that can't be provisioned because of resource constraints.", - }, - "oci_resource_anchor_name": schema.StringAttribute{ - Computed: true, - Description: "The name of the OCI resource anchor associated with this Autonomous VM cluster.", - }, - "oci_url": schema.StringAttribute{ - Computed: true, - Description: "The URL for accessing the OCI console page for this Autonomous VM cluster.", - }, - "ocid": schema.StringAttribute{ - Computed: true, - Description: "The Oracle Cloud Identifier (OCID) of the Autonomous VM cluster.", - }, - "odb_network_id": schema.StringAttribute{ - Computed: true, - Description: "The unique identifier of the ODB network associated with this Autonomous VM cluster.", - }, - "percent_progress": schema.Float32Attribute{ - Computed: true, - Description: "The progress of the current operation on the Autonomous VM cluster, as a percentage.", - }, - "provisionable_autonomous_container_databases": schema.Int32Attribute{ - Computed: true, - Description: "The number of Autonomous CDBs that can be provisioned in the Autonomous VM cluster.", - }, - "provisioned_autonomous_container_databases": schema.Int32Attribute{ - Computed: true, - Description: "The number of Autonomous CDBs currently provisioned in the Autonomous VM cluster.", - }, - "provisioned_cpus": schema.Float32Attribute{ - Computed: true, - Description: "The number of CPU cores currently provisioned in the Autonomous VM cluster.", - }, - "reclaimable_cpus": schema.Float32Attribute{ - Computed: true, - Description: "The number of CPU cores that can be reclaimed from terminated or scaled-down Autonomous Databases.", - }, - "reserved_cpus": schema.Float32Attribute{ - Computed: true, - Description: "The number of CPU cores reserved for system operations and redundancy.", - }, - "scan_listener_port_non_tls": schema.Int32Attribute{ - Computed: true, - Description: "The SCAN listener port for non-TLS (TCP) protocol. The default is 1521.", - }, - "scan_listener_port_tls": schema.Int32Attribute{ - Computed: true, - Description: "The SCAN listener port for TLS (TCP) protocol. The default is 2484.", - }, - "shape": schema.StringAttribute{ - Computed: true, - Description: "The shape of the Exadata infrastructure for the Autonomous VM cluster.", - }, - "status": schema.StringAttribute{ - CustomType: status, - Computed: true, - Description: "The status of the Autonomous VM cluster.", - }, - "status_reason": schema.StringAttribute{ - Computed: true, - Description: "Additional information about the current status of the Autonomous VM cluster.", - }, - "time_database_ssl_certificate_expires": schema.StringAttribute{ - Computed: true, - Description: "The expiration date and time of the database SSL certificate.", - }, - "time_ords_certificate_expires": schema.StringAttribute{ - Computed: true, - Description: "The expiration date and time of the Oracle REST Data Services (ORDS)certificate .", - }, - "time_zone": schema.StringAttribute{ - Computed: true, - Description: "The time zone of the Autonomous VM cluster.", - }, - "total_container_databases": schema.Int32Attribute{ - Computed: true, - }, - names.AttrTags: tftags.TagsAttributeComputedOnly(), - "maintenance_window": schema.ObjectAttribute{ - Computed: true, - CustomType: fwtypes.NewObjectTypeOf[cloudAutonomousVmClusterMaintenanceWindowDataSourceModel](ctx), - Description: "The maintenance window for the Autonomous VM cluster.", - AttributeTypes: map[string]attr.Type{ - "days_of_week": types.SetType{ - ElemType: fwtypes.StringEnumType[odbtypes.DayOfWeekName](), - }, - "hours_of_day": types.SetType{ - ElemType: types.Int32Type, - }, - "lead_time_in_weeks": types.Int32Type, - "months": types.SetType{ - ElemType: fwtypes.StringEnumType[odbtypes.MonthName](), - }, - "preference": fwtypes.StringEnumType[odbtypes.PreferenceType](), - "weeks_of_month": types.SetType{ - ElemType: types.Int32Type, - }, - }, - }, - }, - } -} - -func (d *dataSourceCloudAutonomousVmCluster) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - - var data cloudAutonomousVmClusterDataSourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - input := odb.GetCloudAutonomousVmClusterInput{ - CloudAutonomousVmClusterId: data.CloudAutonomousVmClusterId.ValueStringPointer(), - } - - out, err := conn.GetCloudAutonomousVmCluster(ctx, &input) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameCloudAutonomousVmCluster, data.CloudAutonomousVmClusterId.ValueString(), err), - err.Error(), - ) - return - } - data.CreatedAt = types.StringValue(out.CloudAutonomousVmCluster.CreatedAt.Format(time.RFC3339)) - if out.CloudAutonomousVmCluster.TimeOrdsCertificateExpires != nil { - data.TimeOrdsCertificateExpires = types.StringValue(out.CloudAutonomousVmCluster.TimeOrdsCertificateExpires.Format(time.RFC3339)) - } else { - data.TimeOrdsCertificateExpires = types.StringValue(NotAvailableValues) - } - if out.CloudAutonomousVmCluster.TimeDatabaseSslCertificateExpires != nil { - data.TimeDatabaseSslCertificateExpires = types.StringValue(out.CloudAutonomousVmCluster.TimeDatabaseSslCertificateExpires.Format(time.RFC3339)) - } else { - data.TimeDatabaseSslCertificateExpires = types.StringValue(NotAvailableValues) - } - tagsRead, err := listTags(ctx, conn, *out.CloudAutonomousVmCluster.CloudAutonomousVmClusterArn) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameCloudAutonomousVmCluster, data.CloudAutonomousVmClusterId.ValueString(), err), - err.Error(), - ) - return - } - if tagsRead != nil { - data.Tags = tftags.FlattenStringValueMap(ctx, tagsRead.Map()) - } - - data.MaintenanceWindow = d.flattenMaintenanceWindow(ctx, out.CloudAutonomousVmCluster.MaintenanceWindow) - - resp.Diagnostics.Append(flex.Flatten(ctx, out.CloudAutonomousVmCluster, &data)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (d *dataSourceCloudAutonomousVmCluster) flattenMaintenanceWindow(ctx context.Context, avmcMW *odbtypes.MaintenanceWindow) fwtypes.ObjectValueOf[cloudAutonomousVmClusterMaintenanceWindowDataSourceModel] { - //days of week - daysOfWeek := make([]attr.Value, 0, len(avmcMW.DaysOfWeek)) - for _, dayOfWeek := range avmcMW.DaysOfWeek { - dayOfWeekStringValue := fwtypes.StringEnumValue(dayOfWeek.Name).StringValue - daysOfWeek = append(daysOfWeek, dayOfWeekStringValue) - } - setValueOfDaysOfWeek, _ := basetypes.NewSetValue(types.StringType, daysOfWeek) - daysOfWeekRead := fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.DayOfWeekName]]{ - SetValue: setValueOfDaysOfWeek, - } - //hours of the day - hoursOfTheDay := make([]attr.Value, 0, len(avmcMW.HoursOfDay)) - for _, hourOfTheDay := range avmcMW.HoursOfDay { - daysOfWeekInt32Value := types.Int32Value(hourOfTheDay) - hoursOfTheDay = append(hoursOfTheDay, daysOfWeekInt32Value) - } - setValuesOfHoursOfTheDay, _ := basetypes.NewSetValue(types.Int32Type, hoursOfTheDay) - hoursOfTheDayRead := fwtypes.SetValueOf[types.Int32]{ - SetValue: setValuesOfHoursOfTheDay, - } - //monts - months := make([]attr.Value, 0, len(avmcMW.Months)) - for _, month := range avmcMW.Months { - monthStringValue := fwtypes.StringEnumValue(month.Name).StringValue - months = append(months, monthStringValue) - } - setValuesOfMonth, _ := basetypes.NewSetValue(types.StringType, months) - monthsRead := fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.MonthName]]{ - SetValue: setValuesOfMonth, - } - //weeks of month - weeksOfMonth := make([]attr.Value, 0, len(avmcMW.WeeksOfMonth)) - for _, weekOfMonth := range avmcMW.WeeksOfMonth { - weeksOfMonthInt32Value := types.Int32Value(weekOfMonth) - weeksOfMonth = append(weeksOfMonth, weeksOfMonthInt32Value) - } - setValuesOfWeekOfMonth, _ := basetypes.NewSetValue(types.Int32Type, weeksOfMonth) - weeksOfMonthRead := fwtypes.SetValueOf[types.Int32]{ - SetValue: setValuesOfWeekOfMonth, - } - - computedMW := cloudAutonomousVmClusterMaintenanceWindowDataSourceModel{ - DaysOfWeek: daysOfWeekRead, - HoursOfDay: hoursOfTheDayRead, - LeadTimeInWeeks: types.Int32PointerValue(avmcMW.LeadTimeInWeeks), - Months: monthsRead, - Preference: fwtypes.StringEnumValue(avmcMW.Preference), - WeeksOfMonth: weeksOfMonthRead, - } - result, _ := fwtypes.NewObjectValueOf[cloudAutonomousVmClusterMaintenanceWindowDataSourceModel](ctx, &computedMW) - return result -} - -type cloudAutonomousVmClusterDataSourceModel struct { - framework.WithRegionModel - CloudAutonomousVmClusterArn types.String `tfsdk:"arn"` - CloudAutonomousVmClusterId types.String `tfsdk:"id"` - CloudExadataInfrastructureId types.String `tfsdk:"cloud_exadata_infrastructure_id"` - AutonomousDataStoragePercentage types.Float32 `tfsdk:"autonomous_data_storage_percentage"` - AutonomousDataStorageSizeInTBs types.Float64 `tfsdk:"autonomous_data_storage_size_in_tbs"` - AvailableAutonomousDataStorageSizeInTBs types.Float64 `tfsdk:"available_autonomous_data_storage_size_in_tbs"` - AvailableContainerDatabases types.Int32 `tfsdk:"available_container_databases"` - AvailableCpus types.Float32 `tfsdk:"available_cpus"` - ComputeModel fwtypes.StringEnum[odbtypes.ComputeModel] `tfsdk:"compute_model"` - CpuCoreCount types.Int32 `tfsdk:"cpu_core_count"` - CpuCoreCountPerNode types.Int32 `tfsdk:"cpu_core_count_per_node"` - CpuPercentage types.Float32 `tfsdk:"cpu_percentage"` - CreatedAt types.String `tfsdk:"created_at" autoflex:",noflatten"` - DataStorageSizeInGBs types.Float64 `tfsdk:"data_storage_size_in_gbs"` - DataStorageSizeInTBs types.Float64 `tfsdk:"data_storage_size_in_tbs"` - DbNodeStorageSizeInGBs types.Int32 `tfsdk:"odb_node_storage_size_in_gbs"` - DbServers fwtypes.SetValueOf[types.String] `tfsdk:"db_servers"` - Description types.String `tfsdk:"description"` - DisplayName types.String `tfsdk:"display_name"` - Domain types.String `tfsdk:"domain"` - ExadataStorageInTBsLowestScaledValue types.Float64 `tfsdk:"exadata_storage_in_tbs_lowest_scaled_value"` - Hostname types.String `tfsdk:"hostname"` - IsMtlsEnabledVmCluster types.Bool `tfsdk:"is_mtls_enabled_vm_cluster"` - LicenseModel fwtypes.StringEnum[odbtypes.LicenseModel] `tfsdk:"license_model"` - MaxAcdsLowestScaledValue types.Int32 `tfsdk:"max_acds_lowest_scaled_value"` - MemoryPerOracleComputeUnitInGBs types.Int32 `tfsdk:"memory_per_oracle_compute_unit_in_gbs"` - MemorySizeInGBs types.Int32 `tfsdk:"memory_size_in_gbs"` - NodeCount types.Int32 `tfsdk:"node_count"` - NonProvisionableAutonomousContainerDatabases types.Int32 `tfsdk:"non_provisionable_autonomous_container_databases"` - OciResourceAnchorName types.String `tfsdk:"oci_resource_anchor_name"` - OciUrl types.String `tfsdk:"oci_url"` - Ocid types.String `tfsdk:"ocid"` - OdbNetworkId types.String `tfsdk:"odb_network_id"` - PercentProgress types.Float32 `tfsdk:"percent_progress"` - ProvisionableAutonomousContainerDatabases types.Int32 `tfsdk:"provisionable_autonomous_container_databases"` - ProvisionedAutonomousContainerDatabases types.Int32 `tfsdk:"provisioned_autonomous_container_databases"` - ProvisionedCpus types.Float32 `tfsdk:"provisioned_cpus"` - ReclaimableCpus types.Float32 `tfsdk:"reclaimable_cpus"` - ReservedCpus types.Float32 `tfsdk:"reserved_cpus"` - ScanListenerPortNonTls types.Int32 `tfsdk:"scan_listener_port_non_tls"` - ScanListenerPortTls types.Int32 `tfsdk:"scan_listener_port_tls"` - Shape types.String `tfsdk:"shape"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - TimeDatabaseSslCertificateExpires types.String `tfsdk:"time_database_ssl_certificate_expires" autoflex:",noflatten"` - TimeOrdsCertificateExpires types.String `tfsdk:"time_ords_certificate_expires" autoflex:",noflatten"` - TimeZone types.String `tfsdk:"time_zone"` - TotalContainerDatabases types.Int32 `tfsdk:"total_container_databases"` - MaintenanceWindow fwtypes.ObjectValueOf[cloudAutonomousVmClusterMaintenanceWindowDataSourceModel] `tfsdk:"maintenance_window" autoflex:",noflatten"` - Tags tftags.Map `tfsdk:"tags"` -} -type cloudAutonomousVmClusterMaintenanceWindowDataSourceModel struct { - DaysOfWeek fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.DayOfWeekName]] `tfsdk:"days_of_week"` - HoursOfDay fwtypes.SetValueOf[types.Int32] `tfsdk:"hours_of_day"` - LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"` - Months fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.MonthName]] `tfsdk:"months"` - Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"` - WeeksOfMonth fwtypes.SetValueOf[types.Int32] `tfsdk:"weeks_of_month"` -} diff --git a/internal/service/odb/cloud_autonomous_vm_cluster_data_source_test.go b/internal/service/odb/cloud_autonomous_vm_cluster_data_source_test.go deleted file mode 100644 index 8061ab284f3f..000000000000 --- a/internal/service/odb/cloud_autonomous_vm_cluster_data_source_test.go +++ /dev/null @@ -1,242 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/names" -) - -type autonomousVMClusterDSTest struct { - exaInfraDisplayNamePrefix string - odbNetDisplayNamePrefix string - autonomousVmClusterDisplayNamePrefix string -} - -var autonomousVMClusterDSTestEntity = autonomousVMClusterDSTest{ - exaInfraDisplayNamePrefix: "Ofake-exa", - odbNetDisplayNamePrefix: "odb-net", - autonomousVmClusterDisplayNamePrefix: "Ofake-avmc", -} - -func TestAccODBCloudAutonomousVmClusterDataSource_basic(t *testing.T) { - ctx := acctest.Context(t) - - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - var avmc1 odbtypes.CloudAutonomousVmCluster - dataSourceName := "data.aws_odb_cloud_autonomous_vm_cluster.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - autonomousVMClusterDSTestEntity.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: autonomousVMClusterDSTestEntity.testAccCheckCloudAutonomousVmClusterDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: autonomousVMClusterDSTestEntity.avmcBasic(), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "display_name", *avmc1.DisplayName), - ), - }, - }, - }) -} -func (autonomousVMClusterDSTest) checkCloudAutonomousVmClusterExists(ctx context.Context, name string, cloudAutonomousVMCluster *odbtypes.CloudAutonomousVmCluster) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudAutonomousVmCluster, name, errors.New("not found")) - } - - if rs.Primary.ID == "" { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudAutonomousVmCluster, name, errors.New("not set")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - resp, err := autonomousVMClusterDSTestEntity.findAVMC(ctx, conn, rs.Primary.ID) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudAutonomousVmCluster, rs.Primary.ID, err) - } - - *cloudAutonomousVMCluster = *resp - - return nil - } -} - -func (autonomousVMClusterDSTest) findAVMC(ctx context.Context, conn *odb.Client, id string) (*odbtypes.CloudAutonomousVmCluster, error) { - input := odb.GetCloudAutonomousVmClusterInput{ - CloudAutonomousVmClusterId: aws.String(id), - } - out, err := conn.GetCloudAutonomousVmCluster(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - return nil, err - } - - if out == nil || out.CloudAutonomousVmCluster == nil { - return nil, tfresource.NewEmptyResultError(&input) - } - - return out.CloudAutonomousVmCluster, nil -} - -func (autonomousVMClusterDSTest) testAccCheckCloudAutonomousVmClusterDestroy(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_cloud_autonomous_vm_cluster" { - continue - } - - _, err := tfodb.FindCloudAutonomousVmClusterByID(ctx, conn, rs.Primary.ID) - if tfresource.NotFound(err) { - return nil - } - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudAutonomousVmCluster, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudAutonomousVmCluster, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} -func (autonomousVMClusterDSTest) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListCloudAutonomousVmClustersInput{} - - _, err := conn.ListCloudAutonomousVmClusters(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} - -func (autonomousVMClusterDSTest) avmcBasic() string { - - exaInfraDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.exaInfraDisplayNamePrefix) - odbNetworkDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.odbNetDisplayNamePrefix) - avmcDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.autonomousVmClusterDisplayNamePrefix) - - exaInfraRes := autonomousVMClusterDSTestEntity.exaInfra(exaInfraDisplayName) - odbNetRes := autonomousVMClusterDSTestEntity.odbNet(odbNetworkDisplayName) - res := fmt.Sprintf(` -%s - -%s - -data "aws_odb_db_servers_list" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id -} - -resource "aws_odb_cloud_autonomous_vm_cluster" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id - odb_network_id =aws_odb_network.test.id - display_name = %[3]q - autonomous_data_storage_size_in_tbs = 5 - memory_per_oracle_compute_unit_in_gbs = 2 - total_container_databases = 1 - cpu_core_count_per_node = 40 - license_model = "LICENSE_INCLUDED" - db_servers = [ for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id] - scan_listener_port_tls = 8561 - scan_listener_port_non_tls = 1024 - maintenance_window = { - preference = "NO_PREFERENCE" - days_of_week = [] - hours_of_day = [] - months = [] - weeks_of_month =[] - lead_time_in_weeks = 0 - } - -} - - -data "aws_odb_cloud_autonomous_vm_cluster" "test" { - id = aws_odb_cloud_autonomous_vm_cluster.test.id - -} -`, exaInfraRes, odbNetRes, avmcDisplayName) - - return res -} - -func (autonomousVMClusterDSTest) odbNet(odbNetName string) string { - networkRes := fmt.Sprintf(` - - -resource "aws_odb_network" "test" { - display_name = %[1]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" -} - -`, odbNetName) - return networkRes -} - -func (autonomousVMClusterDSTest) exaInfra(exaInfraName string) string { - exaInfraRes := fmt.Sprintf(` - - -resource "aws_odb_cloud_exadata_infrastructure" "test" { - display_name = %[1]q - shape = "Exadata.X9M" - storage_count = 3 - compute_count = 2 - availability_zone_id = "use1-az6" - customer_contacts_to_send_to_oci = ["abc@example.com"] -maintenance_window = { - custom_action_timeout_in_mins = 16 - days_of_week = [] - hours_of_day = [] - is_custom_action_timeout_enabled = true - lead_time_in_weeks = 0 - months = [] - patching_mode = "ROLLING" - preference = "NO_PREFERENCE" - weeks_of_month =[] - } -} - -`, exaInfraName) - return exaInfraRes -} diff --git a/internal/service/odb/cloud_autonomous_vm_cluster_test.go b/internal/service/odb/cloud_autonomous_vm_cluster_test.go deleted file mode 100644 index b46517573f90..000000000000 --- a/internal/service/odb/cloud_autonomous_vm_cluster_test.go +++ /dev/null @@ -1,519 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "strings" - "testing" - - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - - "github.com/hashicorp/terraform-provider-aws/names" - - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" -) - -type autonomousVMClusterResourceTest struct { - exaInfraDisplayNamePrefix string - odbNetDisplayNamePrefix string - autonomousVmClusterDisplayNamePrefix string -} - -var autonomousVMClusterResourceTestEntity = autonomousVMClusterResourceTest{ - exaInfraDisplayNamePrefix: "Ofake-exa", - odbNetDisplayNamePrefix: "odb-net", - autonomousVmClusterDisplayNamePrefix: "Ofake-avmc", -} - -func TestAccODBCloudAutonomousVmClusterCreationBasic(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudAVMC odbtypes.CloudAutonomousVmCluster - - resourceName := "aws_odb_cloud_autonomous_vm_cluster.test" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - autonomousVMClusterResourceTestEntity.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: autonomousVMClusterResourceTestEntity.testAccCheckCloudAutonomousVmClusterDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: autonomousVMClusterResourceTestEntity.avmcBasic(), - Check: resource.ComposeAggregateTestCheckFunc( - autonomousVMClusterResourceTestEntity.checkCloudAutonomousVmClusterExists(ctx, resourceName, &cloudAVMC), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBCloudAutonomousVmClusterCreationWithAllParams(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudAVMC odbtypes.CloudAutonomousVmCluster - - resourceName := "aws_odb_cloud_autonomous_vm_cluster.test" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //acctest.PreCheckPartitionHasService(t, names.ODBServiceID) - autonomousVMClusterResourceTestEntity.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: autonomousVMClusterResourceTestEntity.testAccCheckCloudAutonomousVmClusterDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: autonomousVMClusterResourceTestEntity.avmcAllParamsConfig(), - Check: resource.ComposeAggregateTestCheckFunc( - autonomousVMClusterResourceTestEntity.checkCloudAutonomousVmClusterExists(ctx, resourceName, &cloudAVMC), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBCloudAutonomousVmClusterTagging(t *testing.T) { - fmt.Println("Update tags test") - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var avmc1, avmc2 odbtypes.CloudAutonomousVmCluster - resourceName := "aws_odb_cloud_autonomous_vm_cluster.test" - withoutTag, withTag := autonomousVMClusterResourceTestEntity.avmcNoTagWithTag() - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - autonomousVMClusterResourceTestEntity.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: autonomousVMClusterResourceTestEntity.testAccCheckCloudAutonomousVmClusterDestroy(ctx), - - Steps: []resource.TestStep{ - { - Config: withoutTag, - - Check: resource.ComposeAggregateTestCheckFunc( - autonomousVMClusterResourceTestEntity.checkCloudAutonomousVmClusterExists(ctx, resourceName, &avmc1), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - { - Config: withTag, - Check: resource.ComposeAggregateTestCheckFunc( - autonomousVMClusterResourceTestEntity.checkCloudAutonomousVmClusterExists(ctx, resourceName, &avmc2), - resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), - resource.TestCheckResourceAttr(resourceName, "tags.env", "dev"), - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - if strings.Compare(*(avmc1.CloudAutonomousVmClusterId), *(avmc2.CloudAutonomousVmClusterId)) != 0 { - return errors.New("shouldn't create a new autonomous vm cluster") - } - return nil - }), - ), - }, - }, - }) -} - -func TestAccODBCloudAutonomousVmCluster_disappears(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - var cloudautonomousvmcluster odbtypes.CloudAutonomousVmCluster - resourceName := "aws_odb_cloud_autonomous_vm_cluster.test" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - autonomousVMClusterResourceTestEntity.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: autonomousVMClusterResourceTestEntity.testAccCheckCloudAutonomousVmClusterDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: autonomousVMClusterResourceTestEntity.avmcBasic(), - Check: resource.ComposeAggregateTestCheckFunc( - autonomousVMClusterResourceTestEntity.checkCloudAutonomousVmClusterExists(ctx, resourceName, &cloudautonomousvmcluster), - acctest.CheckFrameworkResourceDisappears(ctx, acctest.Provider, tfodb.ResourceCloudAutonomousVMCluster, resourceName), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func (autonomousVMClusterResourceTest) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListCloudAutonomousVmClustersInput{} - - _, err := conn.ListCloudAutonomousVmClusters(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} -func (autonomousVMClusterResourceTest) testAccCheckCloudAutonomousVmClusterDestroy(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_cloud_autonomous_vm_cluster" { - continue - } - - _, err := autonomousVMClusterResourceTestEntity.findAVMC(ctx, conn, rs.Primary.ID) - if tfresource.NotFound(err) { - return nil - } - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudAutonomousVmCluster, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudAutonomousVmCluster, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} - -func (autonomousVMClusterResourceTest) checkCloudAutonomousVmClusterExists(ctx context.Context, name string, cloudAutonomousVMCluster *odbtypes.CloudAutonomousVmCluster) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudAutonomousVmCluster, name, errors.New("not found")) - } - - if rs.Primary.ID == "" { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudAutonomousVmCluster, name, errors.New("not set")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - fmt.Println("") - resp, err := autonomousVMClusterResourceTestEntity.findAVMC(ctx, conn, rs.Primary.ID) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudAutonomousVmCluster, rs.Primary.ID, err) - } - - *cloudAutonomousVMCluster = *resp - - return nil - } -} - -func (autonomousVMClusterResourceTest) findAVMC(ctx context.Context, conn *odb.Client, id string) (*odbtypes.CloudAutonomousVmCluster, error) { - input := odb.GetCloudAutonomousVmClusterInput{ - CloudAutonomousVmClusterId: aws.String(id), - } - out, err := conn.GetCloudAutonomousVmCluster(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - return nil, err - } - - if out == nil || out.CloudAutonomousVmCluster == nil { - return nil, tfresource.NewEmptyResultError(&input) - } - - return out.CloudAutonomousVmCluster, nil -} - -func (autonomousVMClusterResourceTest) avmcBasic() string { - - exaInfraDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.exaInfraDisplayNamePrefix) - odbNetworkDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.odbNetDisplayNamePrefix) - avmcDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.autonomousVmClusterDisplayNamePrefix) - - exaInfraRes := autonomousVMClusterDSTestEntity.exaInfra(exaInfraDisplayName) - odbNetRes := autonomousVMClusterDSTestEntity.odbNet(odbNetworkDisplayName) - res := fmt.Sprintf(` -%s - -%s - -data "aws_odb_db_servers_list" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id -} - -resource "aws_odb_cloud_autonomous_vm_cluster" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id - odb_network_id =aws_odb_network.test.id - display_name = %[3]q - autonomous_data_storage_size_in_tbs = 5 - memory_per_oracle_compute_unit_in_gbs = 2 - total_container_databases = 1 - cpu_core_count_per_node = 40 - license_model = "LICENSE_INCLUDED" - db_servers = [ for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id] - scan_listener_port_tls = 8561 - scan_listener_port_non_tls = 1024 - maintenance_window = { - preference = "NO_PREFERENCE" - days_of_week = [] - hours_of_day = [] - months = [] - weeks_of_month =[] - lead_time_in_weeks = 0 - } - -} - -`, exaInfraRes, odbNetRes, avmcDisplayName) - - return res -} - -func (autonomousVMClusterResourceTest) avmcNoTagWithTag() (string, string) { - exaInfraDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.exaInfraDisplayNamePrefix) - odbNetworkDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.odbNetDisplayNamePrefix) - avmcDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.autonomousVmClusterDisplayNamePrefix) - - exaInfraRes := autonomousVMClusterDSTestEntity.exaInfra(exaInfraDisplayName) - odbNetRes := autonomousVMClusterDSTestEntity.odbNet(odbNetworkDisplayName) - noTag := fmt.Sprintf(` -%s - -%s - -data "aws_odb_db_servers_list" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id -} - -resource "aws_odb_cloud_autonomous_vm_cluster" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id - odb_network_id =aws_odb_network.test.id - display_name = %[3]q - autonomous_data_storage_size_in_tbs = 5 - memory_per_oracle_compute_unit_in_gbs = 2 - total_container_databases = 1 - cpu_core_count_per_node = 40 - license_model = "LICENSE_INCLUDED" - db_servers = [ for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id] - scan_listener_port_tls = 8561 - scan_listener_port_non_tls = 1024 - maintenance_window = { - preference = "NO_PREFERENCE" - days_of_week = [] - hours_of_day = [] - months = [] - weeks_of_month =[] - lead_time_in_weeks = 0 - } - -} - -`, exaInfraRes, odbNetRes, avmcDisplayName) - withTag := fmt.Sprintf(` -%s - -%s - -data "aws_odb_db_servers_list" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id -} - -resource "aws_odb_cloud_autonomous_vm_cluster" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id - odb_network_id =aws_odb_network.test.id - display_name = %[3]q - autonomous_data_storage_size_in_tbs = 5 - memory_per_oracle_compute_unit_in_gbs = 2 - total_container_databases = 1 - cpu_core_count_per_node = 40 - license_model = "LICENSE_INCLUDED" - db_servers = [ for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id] - scan_listener_port_tls = 8561 - scan_listener_port_non_tls = 1024 - maintenance_window = { - preference = "NO_PREFERENCE" - days_of_week = [] - hours_of_day = [] - months = [] - weeks_of_month =[] - lead_time_in_weeks = 0 - } - tags = { - "env"= "dev" - } - -} - -`, exaInfraRes, odbNetRes, avmcDisplayName) - - return noTag, withTag -} - -func (autonomousVMClusterResourceTest) avmcAllParamsConfig() string { - - exaInfraDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.exaInfraDisplayNamePrefix) - odbNetworkDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.odbNetDisplayNamePrefix) - avmcDisplayName := sdkacctest.RandomWithPrefix(autonomousVMClusterDSTestEntity.autonomousVmClusterDisplayNamePrefix) - - exaInfraRes := autonomousVMClusterDSTestEntity.exaInfra(exaInfraDisplayName) - odbNetRes := autonomousVMClusterDSTestEntity.odbNet(odbNetworkDisplayName) - res := fmt.Sprintf(` -%s - -%s - -data "aws_odb_db_servers_list" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id -} - -resource "aws_odb_cloud_autonomous_vm_cluster" "test" { - description = "my first avmc" - time_zone = "UTC" - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id - odb_network_id =aws_odb_network.test.id - display_name = %[3]q - autonomous_data_storage_size_in_tbs = 5 - memory_per_oracle_compute_unit_in_gbs = 2 - total_container_databases = 1 - cpu_core_count_per_node = 40 - license_model = "LICENSE_INCLUDED" - db_servers = [ for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id] - scan_listener_port_tls = 8561 - scan_listener_port_non_tls = 1024 - maintenance_window = { - preference = "CUSTOM_PREFERENCE" - days_of_week = ["MONDAY", "TUESDAY"] - hours_of_day = [4,16] - months = ["FEBRUARY","MAY","AUGUST","NOVEMBER"] - weeks_of_month =[2,4] - lead_time_in_weeks = 3 - } - tags = { - "env"= "dev" - } - -} - -`, exaInfraRes, odbNetRes, avmcDisplayName) - - return res -} - -func (autonomousVMClusterResourceTest) odbNet(odbNetName string) string { - networkRes := fmt.Sprintf(` - - -resource "aws_odb_network" "test" { - display_name = %[1]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" -} - -`, odbNetName) - return networkRes -} - -func (autonomousVMClusterResourceTest) avmcWithMandatoryParamsWithTag(exaInfra, odbNetwork, avmcDisplayName string) string { - res := fmt.Sprintf(` -%s - -%s - -resource "aws_odb_cloud_autonomous_vm_cluster" "test" { - display_name = %[1]q - cloud_exadata_infrastructure_id = "exa_ky7jabi90t" - odb_network_id = "odbnet_fjey4b8oth" - autonomous_data_storage_size_in_tbs = 5 - memory_per_oracle_compute_unit_in_gbs = 2 - total_container_databases = 1 - cpu_core_count_per_node = 4 - tags = { - "env"= "dev" - } - -} -`, exaInfra, odbNetwork, avmcDisplayName) - - return res -} - -func (autonomousVMClusterResourceTest) exaInfra(exaDisplayName string) string { - resource := fmt.Sprintf(` -resource "aws_odb_cloud_exadata_infrastructure" "test" { - display_name = "%[1]s" - shape = "Exadata.X9M" - storage_count = 3 - compute_count = 2 - availability_zone_id = "use1-az6" - customer_contacts_to_send_to_oci = ["abc@example.com"] - -} -`, exaDisplayName) - - return resource -} -func (autonomousVMClusterResourceTest) odbNetwork(odbNetDisplayName string) string { - return fmt.Sprintf(` - resource "aws_odb_network" "test" { - display_name = %[1]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" - } -`, odbNetDisplayName) - -} diff --git a/internal/service/odb/cloud_autonomous_vm_clusters_list_data_source.go b/internal/service/odb/cloud_autonomous_vm_clusters_list_data_source.go deleted file mode 100644 index 0e30a6b667a7..000000000000 --- a/internal/service/odb/cloud_autonomous_vm_clusters_list_data_source.go +++ /dev/null @@ -1,92 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "github.com/hashicorp/terraform-plugin-framework/attr" - - "github.com/aws/aws-sdk-go-v2/service/odb" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_cloud_autonomous_vm_clusters_list", name="Cloud Autonomous Vm Clusters List") -func newDataSourceCloudAutonomousVmClustersList(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceCloudAutonomousVmClustersList{}, nil -} - -const ( - DSNameCloudAutonomousVmClustersList = "Cloud Autonomous Vm Clusters List Data Source" -) - -type dataSourceCloudAutonomousVmClustersList struct { - framework.DataSourceWithModel[cloudAutonomousVmClusterListModel] -} - -func (d *dataSourceCloudAutonomousVmClustersList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "cloud_autonomous_vm_clusters": schema.ListAttribute{ - Computed: true, - Description: "List of Cloud Autonomous VM Clusters (OCID, ID, ARN, OCI URL, Display Name)", - CustomType: fwtypes.NewListNestedObjectTypeOf[cloudAutonomousVmClusterSummary](ctx), - ElementType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "arn": types.StringType, - "id": types.StringType, - "oci_url": types.StringType, - "ocid": types.StringType, - "display_name": types.StringType, - }, - }, - }, - }, - } -} - -// Data sources only have a read method. -func (d *dataSourceCloudAutonomousVmClustersList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - - var data cloudExadataInfrastructuresListDataSourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := conn.ListCloudAutonomousVmClusters(ctx, &odb.ListCloudAutonomousVmClustersInput{}) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameCloudAutonomousVmClustersList, "", err), - err.Error(), - ) - return - } - resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...) - if resp.Diagnostics.HasError() { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type cloudAutonomousVmClusterListModel struct { - framework.WithRegionModel - CloudAutonomousVmClusters fwtypes.ListNestedObjectValueOf[cloudAutonomousVmClusterSummary] `tfsdk:"cloud_autonomous_vm_clusters"` -} - -type cloudAutonomousVmClusterSummary struct { - CloudExadataInfrastructureArn types.String `tfsdk:"arn"` - CloudAutonomousVmClusterId types.String `tfsdk:"id"` - OciUrl types.String `tfsdk:"oci_url"` - Ocid types.String `tfsdk:"ocid"` - DisplayName types.String `tfsdk:"display_name"` -} diff --git a/internal/service/odb/cloud_autonomous_vm_clusters_list_data_source_test.go b/internal/service/odb/cloud_autonomous_vm_clusters_list_data_source_test.go deleted file mode 100644 index 8ee9395f9557..000000000000 --- a/internal/service/odb/cloud_autonomous_vm_clusters_list_data_source_test.go +++ /dev/null @@ -1,101 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "strconv" - - "testing" - - "github.com/aws/aws-sdk-go-v2/service/odb" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/names" -) - -type listAVMCListDSTest struct { -} - -func TestAccListAutonomousVmClusterDataSource(t *testing.T) { - ctx := acctest.Context(t) - var avmcListTest = listAVMCListDSTest{} - var output odb.ListCloudAutonomousVmClustersOutput - - dataSourceName := "data.aws_odb_cloud_autonomous_vm_clusters_list.test" - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - avmcListTest.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - Steps: []resource.TestStep{ - { - Config: avmcListTest.basic(), - Check: resource.ComposeAggregateTestCheckFunc( - - resource.ComposeTestCheckFunc(func(s *terraform.State) error { - avmcListTest.count(ctx, dataSourceName, &output) - resource.TestCheckResourceAttr(dataSourceName, "cloud_autonomous_vm_clusters.#", strconv.Itoa(len(output.CloudAutonomousVmClusters))) - return nil - }, - ), - ), - }, - }, - }) -} - -func (listAVMCListDSTest) basic() string { - config := fmt.Sprintf(` - - -data "aws_odb_cloud_autonomous_vm_clusters_list" "test" { - -} -`) - return config -} - -func (listAVMCListDSTest) count(ctx context.Context, name string, list *odb.ListCloudAutonomousVmClustersOutput) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, name, errors.New("not found")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - resp, err := conn.ListCloudAutonomousVmClusters(ctx, &odb.ListCloudAutonomousVmClustersInput{}) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, rs.Primary.ID, err) - } - - list.CloudAutonomousVmClusters = resp.CloudAutonomousVmClusters - - return nil - } -} -func (listAVMCListDSTest) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListCloudAutonomousVmClustersInput{} - - _, err := conn.ListCloudAutonomousVmClusters(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} diff --git a/internal/service/odb/cloud_exadata_infrastructure.go b/internal/service/odb/cloud_exadata_infrastructure.go deleted file mode 100644 index 805aab905033..000000000000 --- a/internal/service/odb/cloud_exadata_infrastructure.go +++ /dev/null @@ -1,895 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "errors" - "fmt" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/int32planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/hashicorp/terraform-provider-aws/internal/enum" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" - - "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/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - "github.com/hashicorp/terraform-provider-aws/internal/errs/fwdiag" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/sweep" - sweepfw "github.com/hashicorp/terraform-provider-aws/internal/sweep/framework" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for resource registration to the Provider. DO NOT EDIT. -// @FrameworkResource("aws_odb_cloud_exadata_infrastructure", name="Cloud Exadata Infrastructure") -// @Tags(identifierAttribute="arn") -func newResourceCloudExadataInfrastructure(_ context.Context) (resource.ResourceWithConfigure, error) { - r := &resourceCloudExadataInfrastructure{} - - r.SetDefaultCreateTimeout(24 * time.Hour) - r.SetDefaultUpdateTimeout(24 * time.Hour) - r.SetDefaultDeleteTimeout(24 * time.Hour) - - return r, nil -} - -const ( - ResNameCloudExadataInfrastructure = "Cloud Exadata Infrastructure" - ExaInfraStorageServerTypeNotAvailable = "Storage_Server_Type_NA" - ExaInfraDBServerTypeNotAvailable = "DB_Server_Type_NA" -) - -var ResourceCloudExadataInfrastructure = newResourceCloudExadataInfrastructure - -type resourceCloudExadataInfrastructure struct { - framework.ResourceWithModel[cloudExadataInfrastructureResourceModel] - framework.WithTimeouts -} - -// For more about schema options, visit -// https://developer.hashicorp.com/terraform/plugin/framework/handling-data/schemas?page=schemas -func (r *resourceCloudExadataInfrastructure) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - statusType := fwtypes.StringEnumType[odbtypes.ResourceStatus]() - computeModelType := fwtypes.StringEnumType[odbtypes.ComputeModel]() - - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "activated_storage_count": schema.Int32Attribute{ - Computed: true, - Description: "The number of storage servers requested for the Exadata infrastructure", - }, - "additional_storage_count": schema.Int32Attribute{ - Computed: true, - Description: " The number of storage servers requested for the Exadata infrastructure", - }, - "database_server_type": schema.StringAttribute{ - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "The database server model type of the Exadata infrastructure. For the list of valid model names, use the ListDbSystemShapes operation", - }, - "database_server_type_computed": schema.StringAttribute{ - Computed: true, - Description: "The database server model type of the Exadata infrastructure. For the list of valid model names, use the ListDbSystemShapes operation", - }, - "storage_server_type": schema.StringAttribute{ - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "The storage server model type of the Exadata infrastructure. For the list of valid model names, use the ListDbSystemShapes operation", - }, - "storage_server_type_computed": schema.StringAttribute{ - Computed: true, - Description: "The storage server model type of the Exadata infrastructure. For the list of valid model names, use the ListDbSystemShapes operation", - }, - names.AttrARN: framework.ARNAttributeComputedOnly(), - names.AttrID: framework.IDAttribute(), - "available_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The amount of available storage, in gigabytes (GB), for the Exadata infrastructure", - }, - "availability_zone": schema.StringAttribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - stringplanmodifier.UseStateForUnknown(), - }, - Description: "The name of the Availability Zone (AZ) where the Exadata infrastructure is located. Changing this will force terraform to create new resource", - }, - "availability_zone_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - stringplanmodifier.UseStateForUnknown(), - }, - Description: " The AZ ID of the AZ where the Exadata infrastructure is located. Changing this will force terraform to create new resource", - }, - "compute_count": schema.Int32Attribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.Int32{ - int32planmodifier.RequiresReplace(), - int32planmodifier.UseStateForUnknown(), - }, - Description: " The number of compute instances that the Exadata infrastructure is located", - }, - "cpu_count": schema.Int32Attribute{ - Computed: true, - Description: "The total number of CPU cores that are allocated to the Exadata infrastructure", - }, - "customer_contacts_to_send_to_oci": schema.SetAttribute{ - ElementType: types.StringType, - CustomType: fwtypes.SetOfStringType, - Optional: true, - PlanModifiers: []planmodifier.Set{ - setplanmodifier.RequiresReplace(), - setplanmodifier.UseStateForUnknown(), - }, - Description: "The email addresses of contacts to receive notification from Oracle about maintenance updates for the Exadata infrastructure. Changing this will force terraform to create new resource", - }, - "data_storage_size_in_tbs": schema.Float64Attribute{ - Computed: true, - Description: "The size of the Exadata infrastructure's data disk group, in terabytes (TB)", - }, - "db_node_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The size of the Exadata infrastructure's local node storage, in gigabytes (GB)", - }, - "db_server_version": schema.StringAttribute{ - Computed: true, - Description: "The software version of the database servers (dom0) in the Exadata infrastructure", - }, - "display_name": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "The user-friendly name for the Exadata infrastructure. Changing this will force terraform to create a new resource", - }, - "last_maintenance_run_id": schema.StringAttribute{ - Computed: true, - Description: "The Oracle Cloud Identifier (OCID) of the last maintenance run for the Exadata infrastructure", - }, - "max_cpu_count": schema.Int32Attribute{ - Computed: true, - Description: "The total number of CPU cores available on the Exadata infrastructure", - }, - "max_data_storage_in_tbs": schema.Float64Attribute{ - Computed: true, - Description: "The total amount of data disk group storage, in terabytes (TB), that's available on the Exadata infrastructure", - }, - "max_db_node_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The total amount of local node storage, in gigabytes (GB), that's available on the Exadata infrastructure", - }, - "max_memory_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The total amount of memory in gigabytes (GB) available on the Exadata infrastructure", - }, - "memory_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The amount of memory, in gigabytes (GB), that's allocated on the Exadata infrastructure", - }, - "monthly_db_server_version": schema.StringAttribute{ - Computed: true, - Description: "The monthly software version of the database servers in the Exadata infrastructure", - }, - "monthly_storage_server_version": schema.StringAttribute{ - Computed: true, - Description: "The monthly software version of the storage servers installed on the Exadata infrastructure", - }, - "next_maintenance_run_id": schema.StringAttribute{ - Computed: true, - Description: "The OCID of the next maintenance run for the Exadata infrastructure", - }, - "ocid": schema.StringAttribute{ - Computed: true, - Description: "The OCID of the Exadata infrastructure", - }, - "oci_resource_anchor_name": schema.StringAttribute{ - Computed: true, - Description: "The name of the OCI resource anchor for the Exadata infrastructure", - }, - "oci_url": schema.StringAttribute{ - Computed: true, - Description: "The HTTPS link to the Exadata infrastructure in OCI", - }, - "percent_progress": schema.Float64Attribute{ - Computed: true, - Description: "The amount of progress made on the current operation on the Exadata infrastructure, expressed as a percentage", - }, - "shape": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "The model name of the Exadata infrastructure. Changing this will force terraform to create new resource", - }, - "status": schema.StringAttribute{ - CustomType: statusType, - Computed: true, - Description: "The current status of the Exadata infrastructure", - }, - "status_reason": schema.StringAttribute{ - Computed: true, - Description: "Additional information about the status of the Exadata infrastructure", - }, - "storage_count": schema.Int32Attribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.Int32{ - int32planmodifier.RequiresReplace(), - int32planmodifier.UseStateForUnknown(), - }, - Description: "TThe number of storage servers that are activated for the Exadata infrastructure", - }, - "storage_server_version": schema.StringAttribute{ - Computed: true, - Description: "The software version of the storage servers on the Exadata infrastructure.", - }, - names.AttrTags: tftags.TagsAttribute(), - names.AttrTagsAll: tftags.TagsAttributeComputedOnly(), - "total_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - }, - "created_at": schema.StringAttribute{ - Computed: true, - Description: "The time when the Exadata infrastructure was created", - }, - "compute_model": schema.StringAttribute{ - CustomType: computeModelType, - Computed: true, - Description: fmt.Sprint("The OCI model compute model used when you create or clone an\n " + - " instance: ECPU or OCPU. An ECPU is an abstracted measure of\n " + - "compute resources. ECPUs are based on the number of cores\n " + - "elastically allocated from a pool of compute and storage servers.\n " + - " An OCPU is a legacy physical measure of compute resources. OCPUs\n " + - "are based on the physical core of a processor with\n " + - " hyper-threading enabled."), - }, - "maintenance_window": schema.ObjectAttribute{ - Required: true, - CustomType: fwtypes.NewObjectTypeOf[cloudExadataInfraMaintenanceWindowResourceModel](ctx), - Description: " The scheduling details for the maintenance window. Patching and system updates take place during the maintenance window ", - AttributeTypes: map[string]attr.Type{ - "custom_action_timeout_in_mins": types.Int32Type, - "days_of_week": types.SetType{ - ElemType: fwtypes.StringEnumType[odbtypes.DayOfWeekName](), - }, - "hours_of_day": types.SetType{ - ElemType: types.Int32Type, - }, - "is_custom_action_timeout_enabled": types.BoolType, - "lead_time_in_weeks": types.Int32Type, - "months": types.SetType{ - ElemType: fwtypes.StringEnumType[odbtypes.MonthName](), - }, - "patching_mode": fwtypes.StringEnumType[odbtypes.PatchingModeType](), - "preference": fwtypes.StringEnumType[odbtypes.PreferenceType](), - "weeks_of_month": types.SetType{ - ElemType: types.Int32Type, - }, - }, - }, - }, - Blocks: map[string]schema.Block{ - names.AttrTimeouts: timeouts.Block(ctx, timeouts.Opts{ - Create: true, - Update: true, - Delete: true, - }), - }, - } -} - -func (r *resourceCloudExadataInfrastructure) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - conn := r.Meta().ODBClient(ctx) - - var plan cloudExadataInfrastructureResourceModel - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.CreateCloudExadataInfrastructureInput{ - Tags: getTagsIn(ctx), - MaintenanceWindow: r.expandMaintenanceWindow(ctx, plan.MaintenanceWindow), - } - - if !plan.CustomerContactsToSendToOCI.IsNull() && !plan.CustomerContactsToSendToOCI.IsUnknown() { - input.CustomerContactsToSendToOCI = r.expandCustomerContacts(ctx, plan.CustomerContactsToSendToOCI) - } - - resp.Diagnostics.Append(flex.Expand(ctx, plan, &input)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := conn.CreateCloudExadataInfrastructure(ctx, &input) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameCloudExadataInfrastructure, plan.DisplayName.ValueString(), err), - err.Error(), - ) - return - } - if out == nil || out.CloudExadataInfrastructureId == nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameCloudExadataInfrastructure, plan.DisplayName.ValueString(), nil), - errors.New("empty output").Error(), - ) - return - } - - createTimeout := r.CreateTimeout(ctx, plan.Timeouts) - createdExaInfra, err := waitCloudExadataInfrastructureCreated(ctx, conn, *out.CloudExadataInfrastructureId, createTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForCreation, ResNameCloudExadataInfrastructure, plan.DisplayName.ValueString(), err), - err.Error(), - ) - return - } - - plan.CustomerContactsToSendToOCI = r.flattenCustomerContacts(createdExaInfra.CustomerContactsToSendToOCI) - plan.MaintenanceWindow = r.flattenMaintenanceWindow(ctx, createdExaInfra.MaintenanceWindow) - - plan.CreatedAt = types.StringValue(createdExaInfra.CreatedAt.Format(time.RFC3339)) - - if createdExaInfra.DatabaseServerType == nil { - plan.DatabaseServerTypeComputed = types.StringValue(ExaInfraDBServerTypeNotAvailable) - } else { - plan.DatabaseServerType = types.StringValue(*createdExaInfra.DatabaseServerType) - plan.DatabaseServerTypeComputed = types.StringValue(*createdExaInfra.DatabaseServerType) - } - if createdExaInfra.StorageServerType == nil { - plan.StorageServerTypeComputed = types.StringValue(ExaInfraStorageServerTypeNotAvailable) - } else { - plan.StorageServerType = types.StringValue(*createdExaInfra.StorageServerType) - plan.StorageServerTypeComputed = types.StringValue(*createdExaInfra.StorageServerType) - } - resp.Diagnostics.Append(flex.Flatten(ctx, createdExaInfra, &plan)...) - - if resp.Diagnostics.HasError() { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) -} - -func (r *resourceCloudExadataInfrastructure) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - conn := r.Meta().ODBClient(ctx) - var state cloudExadataInfrastructureResourceModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := FindOdbExadataInfraResourceByID(ctx, conn, state.CloudExadataInfrastructureId.ValueString()) - if tfresource.NotFound(err) { - resp.Diagnostics.Append(fwdiag.NewResourceNotFoundWarningDiagnostic(err)) - resp.State.RemoveResource(ctx) - return - } - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, ResNameCloudExadataInfrastructure, state.CloudExadataInfrastructureId.String(), err), - err.Error(), - ) - return - } - - state.CustomerContactsToSendToOCI = r.flattenCustomerContacts(out.CustomerContactsToSendToOCI) - state.CreatedAt = types.StringValue(out.CreatedAt.Format(time.RFC3339)) - - state.MaintenanceWindow = r.flattenMaintenanceWindow(ctx, out.MaintenanceWindow) - - if out.DatabaseServerType == nil { - state.DatabaseServerTypeComputed = types.StringValue(ExaInfraDBServerTypeNotAvailable) - } else { - state.DatabaseServerType = types.StringValue(*out.DatabaseServerType) - state.DatabaseServerTypeComputed = types.StringValue(*out.DatabaseServerType) - } - if out.StorageServerType == nil { - state.StorageServerTypeComputed = types.StringValue(ExaInfraStorageServerTypeNotAvailable) - } else { - state.StorageServerType = types.StringValue(*out.StorageServerType) - state.StorageServerTypeComputed = types.StringValue(*out.StorageServerType) - } - resp.Diagnostics.Append(flex.Flatten(ctx, out, &state)...) - - if resp.Diagnostics.HasError() { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) -} - -func (r *resourceCloudExadataInfrastructure) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - - var plan, state cloudExadataInfrastructureResourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - conn := r.Meta().ODBClient(ctx) - - if !state.MaintenanceWindow.Equal(plan.MaintenanceWindow) { - - //we need to call update maintenance window - - updatedMW := odb.UpdateCloudExadataInfrastructureInput{ - CloudExadataInfrastructureId: plan.CloudExadataInfrastructureId.ValueStringPointer(), - MaintenanceWindow: r.expandMaintenanceWindow(ctx, plan.MaintenanceWindow), - } - - out, err := conn.UpdateCloudExadataInfrastructure(ctx, &updatedMW) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionUpdating, ResNameCloudExadataInfrastructure, state.CloudExadataInfrastructureId.ValueString(), err), - err.Error(), - ) - return - } - if out == nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionUpdating, ResNameCloudExadataInfrastructure, state.CloudExadataInfrastructureId.ValueString(), err), - err.Error(), - ) - return - } - - } - - updateTimeout := r.UpdateTimeout(ctx, plan.Timeouts) - updatedExaInfra, err := waitCloudExadataInfrastructureUpdated(ctx, conn, state.CloudExadataInfrastructureId.ValueString(), updateTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameCloudExadataInfrastructure, state.CloudExadataInfrastructureId.ValueString(), err), - err.Error(), - ) - return - } - plan.CustomerContactsToSendToOCI = r.flattenCustomerContacts(updatedExaInfra.CustomerContactsToSendToOCI) - plan.CreatedAt = types.StringValue(updatedExaInfra.CreatedAt.Format(time.RFC3339)) - plan.MaintenanceWindow = r.flattenMaintenanceWindow(ctx, updatedExaInfra.MaintenanceWindow) - if updatedExaInfra.DatabaseServerType == nil { - plan.DatabaseServerTypeComputed = types.StringValue(ExaInfraDBServerTypeNotAvailable) - } else { - plan.DatabaseServerType = types.StringValue(*updatedExaInfra.DatabaseServerType) - plan.DatabaseServerTypeComputed = types.StringValue(*updatedExaInfra.DatabaseServerType) - } - if updatedExaInfra.StorageServerType == nil { - plan.StorageServerTypeComputed = types.StringValue(ExaInfraStorageServerTypeNotAvailable) - } else { - plan.StorageServerType = types.StringValue(*updatedExaInfra.StorageServerType) - plan.StorageServerTypeComputed = types.StringValue(*updatedExaInfra.StorageServerType) - } - - resp.Diagnostics.Append(flex.Flatten(ctx, updatedExaInfra, &plan)...) - - resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) - -} - -func (r *resourceCloudExadataInfrastructure) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - conn := r.Meta().ODBClient(ctx) - - var state cloudExadataInfrastructureResourceModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.DeleteCloudExadataInfrastructureInput{ - CloudExadataInfrastructureId: state.CloudExadataInfrastructureId.ValueStringPointer(), - } - - _, err := conn.DeleteCloudExadataInfrastructure(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return - } - - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionDeleting, ResNameCloudExadataInfrastructure, state.CloudExadataInfrastructureId.String(), err), - err.Error(), - ) - return - } - - deleteTimeout := r.DeleteTimeout(ctx, state.Timeouts) - _, err = waitCloudExadataInfrastructureDeleted(ctx, conn, state.CloudExadataInfrastructureId.ValueString(), deleteTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForDeletion, ResNameCloudExadataInfrastructure, state.CloudExadataInfrastructureId.String(), err), - err.Error(), - ) - return - } -} - -func (r *resourceCloudExadataInfrastructure) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) -} - -func waitCloudExadataInfrastructureCreated(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.CloudExadataInfrastructure, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusProvisioning), - Target: enum.Slice(odbtypes.ResourceStatusAvailable, odbtypes.ResourceStatusFailed), - Refresh: statusCloudExadataInfrastructure(ctx, conn, id), - PollInterval: 1 * time.Minute, - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.CloudExadataInfrastructure); ok { - return out, err - } - return nil, err -} - -func waitCloudExadataInfrastructureUpdated(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.CloudExadataInfrastructure, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusUpdating), - Target: enum.Slice(odbtypes.ResourceStatusAvailable, odbtypes.ResourceStatusFailed), - Refresh: statusCloudExadataInfrastructure(ctx, conn, id), - PollInterval: 1 * time.Minute, - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.CloudExadataInfrastructure); ok { - return out, err - } - - return nil, err -} - -func waitCloudExadataInfrastructureDeleted(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.CloudExadataInfrastructure, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusTerminating), - Target: []string{}, - Refresh: statusCloudExadataInfrastructure(ctx, conn, id), - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.CloudExadataInfrastructure); ok { - return out, err - } - - return nil, err -} - -func statusCloudExadataInfrastructure(ctx context.Context, conn *odb.Client, id string) retry.StateRefreshFunc { - return func() (any, string, error) { - out, err := FindOdbExadataInfraResourceByID(ctx, conn, id) - if tfresource.NotFound(err) { - return nil, "", nil - } - - if err != nil { - return nil, "", err - } - - return out, string(out.Status), nil - } -} -func (r *resourceCloudExadataInfrastructure) expandCustomerContacts(ctx context.Context, contactsList fwtypes.SetValueOf[types.String]) []odbtypes.CustomerContact { - if contactsList.IsNull() || contactsList.IsUnknown() { - return nil - } - - var contacts []types.String - - contactsList.ElementsAs(ctx, &contacts, false) - - result := make([]odbtypes.CustomerContact, 0, len(contacts)) - for _, element := range contacts { - result = append(result, odbtypes.CustomerContact{ - Email: element.ValueStringPointer(), - }) - } - - return result -} - -func (r *resourceCloudExadataInfrastructure) flattenCustomerContacts(contacts []odbtypes.CustomerContact) fwtypes.SetValueOf[types.String] { - if len(contacts) == 0 { - return fwtypes.SetValueOf[types.String]{ - SetValue: basetypes.NewSetNull(types.StringType), - } - } - - elements := make([]attr.Value, 0, len(contacts)) - for _, contact := range contacts { - if contact.Email != nil { - stringValue := types.StringValue(*contact.Email) - elements = append(elements, stringValue) - } - } - - list, _ := basetypes.NewSetValue(types.StringType, elements) - - return fwtypes.SetValueOf[types.String]{ - SetValue: list, - } -} - -func FindOdbExadataInfraResourceByID(ctx context.Context, conn *odb.Client, id string) (*odbtypes.CloudExadataInfrastructure, error) { - input := odb.GetCloudExadataInfrastructureInput{ - CloudExadataInfrastructureId: aws.String(id), - } - - out, err := conn.GetCloudExadataInfrastructure(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - - return nil, err - } - - if out == nil || out.CloudExadataInfrastructure == nil { - return nil, tfresource.NewEmptyResultError(&input) - } - - return out.CloudExadataInfrastructure, nil -} -func (r *resourceCloudExadataInfrastructure) expandMaintenanceWindow(ctx context.Context, exaInfraMWResourceObj fwtypes.ObjectValueOf[cloudExadataInfraMaintenanceWindowResourceModel]) *odbtypes.MaintenanceWindow { - - var exaInfraMWResource cloudExadataInfraMaintenanceWindowResourceModel - - exaInfraMWResourceObj.As(ctx, &exaInfraMWResource, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - }) - - var daysOfWeekNames []odbtypes.DayOfWeekName - exaInfraMWResource.DaysOfWeek.ElementsAs(ctx, &daysOfWeekNames, false) - daysOfWeek := make([]odbtypes.DayOfWeek, 0, len(daysOfWeekNames)) - - for _, dayOfWeek := range daysOfWeekNames { - daysOfWeek = append(daysOfWeek, odbtypes.DayOfWeek{ - Name: dayOfWeek, - }) - } - - var hoursOfTheDay []int32 - exaInfraMWResource.HoursOfDay.ElementsAs(ctx, &hoursOfTheDay, false) - - var monthNames []odbtypes.MonthName - exaInfraMWResource.Months.ElementsAs(ctx, &monthNames, false) - months := make([]odbtypes.Month, 0, len(monthNames)) - for _, month := range monthNames { - months = append(months, odbtypes.Month{ - Name: month, - }) - } - - var weeksOfMonth []int32 - exaInfraMWResource.WeeksOfMonth.ElementsAs(ctx, &weeksOfMonth, false) - odbTypeMW := odbtypes.MaintenanceWindow{ - CustomActionTimeoutInMins: exaInfraMWResource.CustomActionTimeoutInMins.ValueInt32Pointer(), - DaysOfWeek: daysOfWeek, - HoursOfDay: hoursOfTheDay, - IsCustomActionTimeoutEnabled: exaInfraMWResource.IsCustomActionTimeoutEnabled.ValueBoolPointer(), - LeadTimeInWeeks: exaInfraMWResource.LeadTimeInWeeks.ValueInt32Pointer(), - Months: months, - PatchingMode: exaInfraMWResource.PatchingMode.ValueEnum(), - Preference: exaInfraMWResource.Preference.ValueEnum(), - WeeksOfMonth: weeksOfMonth, - } - - if len(odbTypeMW.DaysOfWeek) == 0 { - odbTypeMW.DaysOfWeek = nil - } - if len(odbTypeMW.HoursOfDay) == 0 { - odbTypeMW.HoursOfDay = nil - } - if len(odbTypeMW.WeeksOfMonth) == 0 { - odbTypeMW.WeeksOfMonth = nil - } - if len(odbTypeMW.Months) == 0 { - odbTypeMW.Months = nil - } - if *odbTypeMW.LeadTimeInWeeks == 0 { - odbTypeMW.LeadTimeInWeeks = nil - } - - return &odbTypeMW -} - -func (r *resourceCloudExadataInfrastructure) flattenMaintenanceWindow(ctx context.Context, obdExaInfraMW *odbtypes.MaintenanceWindow) fwtypes.ObjectValueOf[cloudExadataInfraMaintenanceWindowResourceModel] { - //days of week - daysOfWeek := make([]attr.Value, 0, len(obdExaInfraMW.DaysOfWeek)) - for _, dayOfWeek := range obdExaInfraMW.DaysOfWeek { - dayOfWeekStringValue := fwtypes.StringEnumValue(dayOfWeek.Name).StringValue - daysOfWeek = append(daysOfWeek, dayOfWeekStringValue) - } - setValueOfDaysOfWeek, _ := basetypes.NewSetValue(types.StringType, daysOfWeek) - daysOfWeekRead := fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.DayOfWeekName]]{ - SetValue: setValueOfDaysOfWeek, - } - //hours of the day - hoursOfTheDay := make([]attr.Value, 0, len(obdExaInfraMW.HoursOfDay)) - for _, hourOfTheDay := range obdExaInfraMW.HoursOfDay { - daysOfWeekInt32Value := types.Int32Value(hourOfTheDay) - hoursOfTheDay = append(hoursOfTheDay, daysOfWeekInt32Value) - } - setValuesOfHoursOfTheDay, _ := basetypes.NewSetValue(types.Int32Type, hoursOfTheDay) - hoursOfTheDayRead := fwtypes.SetValueOf[types.Int64]{ - SetValue: setValuesOfHoursOfTheDay, - } - //months - months := make([]attr.Value, 0, len(obdExaInfraMW.Months)) - for _, month := range obdExaInfraMW.Months { - monthStringValue := fwtypes.StringEnumValue(month.Name).StringValue - months = append(months, monthStringValue) - } - setValuesOfMonth, _ := basetypes.NewSetValue(types.StringType, months) - monthsRead := fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.MonthName]]{ - SetValue: setValuesOfMonth, - } - //weeks of month - weeksOfMonth := make([]attr.Value, 0, len(obdExaInfraMW.WeeksOfMonth)) - for _, weekOfMonth := range obdExaInfraMW.WeeksOfMonth { - weeksOfMonthInt32Value := types.Int32Value(weekOfMonth) - weeksOfMonth = append(weeksOfMonth, weeksOfMonthInt32Value) - } - setValuesOfWeekOfMonth, _ := basetypes.NewSetValue(types.Int32Type, weeksOfMonth) - weeksOfMonthRead := fwtypes.SetValueOf[types.Int64]{ - SetValue: setValuesOfWeekOfMonth, - } - - flattenMW := cloudExadataInfraMaintenanceWindowResourceModel{ - CustomActionTimeoutInMins: types.Int32PointerValue(obdExaInfraMW.CustomActionTimeoutInMins), - DaysOfWeek: daysOfWeekRead, - HoursOfDay: hoursOfTheDayRead, - IsCustomActionTimeoutEnabled: types.BoolPointerValue(obdExaInfraMW.IsCustomActionTimeoutEnabled), - LeadTimeInWeeks: types.Int32PointerValue(obdExaInfraMW.LeadTimeInWeeks), - Months: monthsRead, - PatchingMode: fwtypes.StringEnumValue(obdExaInfraMW.PatchingMode), - Preference: fwtypes.StringEnumValue(obdExaInfraMW.Preference), - WeeksOfMonth: weeksOfMonthRead, - } - if obdExaInfraMW.LeadTimeInWeeks == nil { - flattenMW.LeadTimeInWeeks = types.Int32Value(0) - } - if obdExaInfraMW.CustomActionTimeoutInMins == nil { - flattenMW.CustomActionTimeoutInMins = types.Int32Value(0) - } - if obdExaInfraMW.IsCustomActionTimeoutEnabled == nil { - flattenMW.IsCustomActionTimeoutEnabled = types.BoolValue(false) - } - - result, _ := fwtypes.NewObjectValueOf[cloudExadataInfraMaintenanceWindowResourceModel](ctx, &flattenMW) - return result -} - -// See more: -// https://developer.hashicorp.com/terraform/plugin/framework/handling-data/accessing-values -type cloudExadataInfrastructureResourceModel struct { - framework.WithRegionModel - ActivatedStorageCount types.Int32 `tfsdk:"activated_storage_count"` - AdditionalStorageCount types.Int32 `tfsdk:"additional_storage_count"` - DatabaseServerType types.String `tfsdk:"database_server_type" autoflex:"-"` - DatabaseServerTypeComputed types.String `tfsdk:"database_server_type_computed" autoflex:"-"` - StorageServerType types.String `tfsdk:"storage_server_type" autoflex:"-"` - StorageServerTypeComputed types.String `tfsdk:"storage_server_type_computed" autoflex:"-"` - AvailabilityZone types.String `tfsdk:"availability_zone"` - AvailabilityZoneId types.String `tfsdk:"availability_zone_id"` - AvailableStorageSizeInGBs types.Int32 `tfsdk:"available_storage_size_in_gbs"` - CloudExadataInfrastructureArn types.String `tfsdk:"arn"` - CloudExadataInfrastructureId types.String `tfsdk:"id"` - ComputeCount types.Int32 `tfsdk:"compute_count"` - CpuCount types.Int32 `tfsdk:"cpu_count"` - CustomerContactsToSendToOCI fwtypes.SetValueOf[types.String] `tfsdk:"customer_contacts_to_send_to_oci" autoflex:"-"` - DataStorageSizeInTBs types.Float64 `tfsdk:"data_storage_size_in_tbs"` - DbNodeStorageSizeInGBs types.Int32 `tfsdk:"db_node_storage_size_in_gbs"` - DbServerVersion types.String `tfsdk:"db_server_version"` - DisplayName types.String `tfsdk:"display_name"` - LastMaintenanceRunId types.String `tfsdk:"last_maintenance_run_id"` - MaxCpuCount types.Int32 `tfsdk:"max_cpu_count"` - MaxDataStorageInTBs types.Float64 `tfsdk:"max_data_storage_in_tbs"` - MaxDbNodeStorageSizeInGBs types.Int32 `tfsdk:"max_db_node_storage_size_in_gbs"` - MaxMemoryInGBs types.Int32 `tfsdk:"max_memory_in_gbs"` - MemorySizeInGBs types.Int32 `tfsdk:"memory_size_in_gbs"` - MonthlyDbServerVersion types.String `tfsdk:"monthly_db_server_version"` - MonthlyStorageServerVersion types.String `tfsdk:"monthly_storage_server_version"` - NextMaintenanceRunId types.String `tfsdk:"next_maintenance_run_id"` - Ocid types.String `tfsdk:"ocid"` - OciResourceAnchorName types.String `tfsdk:"oci_resource_anchor_name"` - OciUrl types.String `tfsdk:"oci_url"` - PercentProgress types.Float64 `tfsdk:"percent_progress"` - Shape types.String `tfsdk:"shape"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - StorageCount types.Int32 `tfsdk:"storage_count"` - StorageServerVersion types.String `tfsdk:"storage_server_version"` - TotalStorageSizeInGBs types.Int32 `tfsdk:"total_storage_size_in_gbs"` - Timeouts timeouts.Value `tfsdk:"timeouts"` - CreatedAt types.String `tfsdk:"created_at" autoflex:",noflatten"` - ComputeModel fwtypes.StringEnum[odbtypes.ComputeModel] `tfsdk:"compute_model"` - MaintenanceWindow fwtypes.ObjectValueOf[cloudExadataInfraMaintenanceWindowResourceModel] `tfsdk:"maintenance_window" autoflex:"-"` - Tags tftags.Map `tfsdk:"tags"` - TagsAll tftags.Map `tfsdk:"tags_all"` -} - -type cloudExadataInfraMaintenanceWindowResourceModel struct { - CustomActionTimeoutInMins types.Int32 `tfsdk:"custom_action_timeout_in_mins"` - DaysOfWeek fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.DayOfWeekName]] `tfsdk:"days_of_week"` - HoursOfDay fwtypes.SetValueOf[types.Int64] `tfsdk:"hours_of_day"` - IsCustomActionTimeoutEnabled types.Bool `tfsdk:"is_custom_action_timeout_enabled"` - LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"` - Months fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.MonthName]] `tfsdk:"months"` - PatchingMode fwtypes.StringEnum[odbtypes.PatchingModeType] `tfsdk:"patching_mode"` - Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"` - WeeksOfMonth fwtypes.SetValueOf[types.Int64] `tfsdk:"weeks_of_month"` -} - -// TIP: ==== SWEEPERS ==== -// When acceptance testing resources, interrupted or failed tests may -// leave behind orphaned resources in an account. To facilitate cleaning -// up lingering resources, each resource implementation should include -// a corresponding "sweeper" function. -// -// The sweeper function lists all resources of a given type and sets the -// appropriate identifers required to delete the resource via the Delete -// method implemented above. -// -// Once the sweeper function is implemented, register it in sweep.go -// as follows: -// -// awsv2.Register("aws_odb_cloud_exadata_infrastructure", sweepCloudExadataInfrastructures) -// -// See more: -// https://hashicorp.github.io/terraform-provider-aws/running-and-writing-acceptance-tests/#acceptance-test-sweepers -func sweepCloudExadataInfrastructures(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) { - input := odb.ListCloudExadataInfrastructuresInput{} - conn := client.ODBClient(ctx) - var sweepResources []sweep.Sweepable - - pages := odb.NewListCloudExadataInfrastructuresPaginator(conn, &input) - for pages.HasMorePages() { - page, err := pages.NextPage(ctx) - if err != nil { - return nil, err - } - - for _, v := range page.CloudExadataInfrastructures { - sweepResources = append(sweepResources, sweepfw.NewSweepResource(newResourceCloudExadataInfrastructure, client, - sweepfw.NewAttribute(names.AttrID, aws.ToString(v.CloudExadataInfrastructureId))), - ) - } - } - - return sweepResources, nil -} diff --git a/internal/service/odb/cloud_exadata_infrastructure_data_source.go b/internal/service/odb/cloud_exadata_infrastructure_data_source.go deleted file mode 100644 index 5fb59a3fbf80..000000000000 --- a/internal/service/odb/cloud_exadata_infrastructure_data_source.go +++ /dev/null @@ -1,425 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_cloud_exadata_infrastructure", name="Cloud Exadata Infrastructure") -func newDataSourceCloudExadataInfrastructure(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceCloudExadataInfrastructure{}, nil -} - -const ( - DSNameCloudExadataInfrastructure = "Cloud Exadata Infrastructure Data Source" -) - -type dataSourceCloudExadataInfrastructure struct { - framework.DataSourceWithModel[cloudExadataInfrastructureDataSourceModel] -} - -func (d *dataSourceCloudExadataInfrastructure) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - statusType := fwtypes.StringEnumType[odbtypes.ResourceStatus]() - computeModelType := fwtypes.StringEnumType[odbtypes.ComputeModel]() - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "activated_storage_count": schema.Int32Attribute{ - Computed: true, - Description: "The number of storage servers requested for the Exadata infrastructure.", - }, - "additional_storage_count": schema.Int32Attribute{ - Computed: true, - Description: "The number of storage servers requested for the Exadata infrastructure.", - }, - "available_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The amount of available storage, in gigabytes (GB), for the Exadata infrastructure.", - }, - "availability_zone": schema.StringAttribute{ - Computed: true, - Description: "he name of the Availability Zone (AZ) where the Exadata infrastructure is located.", - }, - "availability_zone_id": schema.StringAttribute{ - Computed: true, - Description: "The AZ ID of the AZ where the Exadata infrastructure is located.", - }, - names.AttrARN: schema.StringAttribute{ - Computed: true, - Description: "The Amazon Resource Name (ARN) for the Exadata infrastructure.", - }, - names.AttrID: schema.StringAttribute{ - Required: true, - Description: "The unique identifier of the Exadata infrastructure.", - }, - "compute_count": schema.Int32Attribute{ - Computed: true, - Description: "The number of database servers for the Exadata infrastructure.", - }, - "cpu_count": schema.Int32Attribute{ - Computed: true, - Description: "The total number of CPU cores that are allocated to the Exadata infrastructure.", - }, - "data_storage_size_in_tbs": schema.Float64Attribute{ - Computed: true, - Description: "The size of the Exadata infrastructure's data disk group, in terabytes (TB).", - }, - "db_node_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The database server model type of the Exadata infrastructure. For the list of\n" + - "valid model names, use the ListDbSystemShapes operation.", - }, - "db_server_version": schema.StringAttribute{ - Computed: true, - Description: "The version of the Exadata infrastructure.", - }, - "display_name": schema.StringAttribute{ - Computed: true, - Description: "The display name of the Exadata infrastructure.", - }, - "last_maintenance_run_id": schema.StringAttribute{ - Computed: true, - Description: "The Oracle Cloud Identifier (OCID) of the last maintenance run for the Exadata infrastructure.", - }, - "max_cpu_count": schema.Int32Attribute{ - Computed: true, - Description: "The total number of CPU cores available on the Exadata infrastructure.", - }, - "max_data_storage_in_tbs": schema.Float64Attribute{ - Computed: true, - Description: "The total amount of data disk group storage, in terabytes (TB), that's available on the Exadata infrastructure.", - }, - "max_db_node_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The total amount of local node storage, in gigabytes (GB), that's available on the Exadata infrastructure.", - }, - "max_memory_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The total amount of memory, in gigabytes (GB), that's available on the Exadata infrastructure.", - }, - "memory_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The amount of memory, in gigabytes (GB), that's allocated on the Exadata infrastructure.", - }, - "monthly_db_server_version": schema.StringAttribute{ - Computed: true, - Description: "The monthly software version of the database servers installed on the Exadata infrastructure.", - }, - "monthly_storage_server_version": schema.StringAttribute{ - Computed: true, - Description: "The monthly software version of the storage servers installed on the Exadata infrastructure.", - }, - "next_maintenance_run_id": schema.StringAttribute{ - Computed: true, - Description: "The OCID of the next maintenance run for the Exadata infrastructure.", - }, - "oci_resource_anchor_name": schema.StringAttribute{ - Computed: true, - Description: "The name of the OCI resource anchor for the Exadata infrastructure.", - }, - "oci_url": schema.StringAttribute{ - Computed: true, - Description: "The HTTPS link to the Exadata infrastructure in OCI.", - }, - "ocid": schema.StringAttribute{ - Computed: true, - Description: "The OCID of the Exadata infrastructure in OCI.", - }, - "percent_progress": schema.Float64Attribute{ - Computed: true, - Description: "The amount of progress made on the current operation on the Exadata infrastructure expressed as a percentage.", - }, - "shape": schema.StringAttribute{ - Computed: true, - Description: "The model name of the Exadata infrastructure.", - }, - "status": schema.StringAttribute{ - CustomType: statusType, - Computed: true, - Description: "The status of the Exadata infrastructure.", - }, - "status_reason": schema.StringAttribute{ - Computed: true, - Description: "Additional information about the status of the Exadata infrastructure.", - }, - "storage_count": schema.Int32Attribute{ - Computed: true, - Description: "he number of storage servers that are activated for the Exadata infrastructure.", - }, - "storage_server_version": schema.StringAttribute{ - Computed: true, - Description: "The software version of the storage servers on the Exadata infrastructure.", - }, - "total_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The total amount of storage, in gigabytes (GB), on the the Exadata infrastructure.", - }, - "compute_model": schema.StringAttribute{ - CustomType: computeModelType, - Computed: true, - Description: "The OCI model compute model used when you create or clone an instance: ECPU or\n" + - "OCPU. An ECPU is an abstracted measure of compute resources. ECPUs are based on\n" + - "the number of cores elastically allocated from a pool of compute and storage\n" + - "servers. An OCPU is a legacy physical measure of compute resources. OCPUs are\n" + - "based on the physical core of a processor with hyper-threading enabled.", - }, - "created_at": schema.StringAttribute{ - Computed: true, - Description: "The time when the Exadata infrastructure was created.", - }, - "database_server_type": schema.StringAttribute{ - Computed: true, - Description: "The database server model type of the Exadata infrastructure. For the list of valid model names, use the ListDbSystemShapes operation.", - }, - "storage_server_type": schema.StringAttribute{ - Computed: true, - Description: "The storage server model type of the Exadata infrastructure. For the list of valid model names, use the ListDbSystemShapes operation.", - }, - names.AttrTags: tftags.TagsAttributeComputedOnly(), - "maintenance_window": schema.ObjectAttribute{ - Computed: true, - CustomType: fwtypes.NewObjectTypeOf[cloudExadataInfraMaintenanceWindowDataSourceModel](ctx), - Description: "The maintenance window for the Exadata infrastructure.", - AttributeTypes: map[string]attr.Type{ - "custom_action_timeout_in_mins": types.Int32Type, - "days_of_week": types.SetType{ - ElemType: fwtypes.StringEnumType[odbtypes.DayOfWeekName](), - }, - "hours_of_day": types.SetType{ - ElemType: types.Int32Type, - }, - "is_custom_action_timeout_enabled": types.BoolType, - "lead_time_in_weeks": types.Int32Type, - "months": types.SetType{ - ElemType: fwtypes.StringEnumType[odbtypes.MonthName](), - }, - "patching_mode": fwtypes.StringEnumType[odbtypes.PatchingModeType](), - "preference": fwtypes.StringEnumType[odbtypes.PreferenceType](), - "weeks_of_month": types.SetType{ - ElemType: types.Int32Type, - }, - }, - }, - }, - Blocks: map[string]schema.Block{ - "customer_contacts_to_send_to_oci": schema.SetNestedBlock{ - Description: "Customer contact emails to send to OCI.", - CustomType: fwtypes.NewSetNestedObjectTypeOf[customerContactDataSourceModel](ctx), - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "email": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - }, - } -} - -func (d *dataSourceCloudExadataInfrastructure) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - conn := d.Meta().ODBClient(ctx) - - var data cloudExadataInfrastructureDataSourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := FindOdbExaDataInfraForDataSourceByID(ctx, conn, data.CloudExadataInfrastructureId.ValueString()) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameCloudExadataInfrastructure, data.CloudExadataInfrastructureId.String(), err), - err.Error(), - ) - return - } - tagsRead, err := listTags(ctx, conn, *out.CloudExadataInfrastructureArn) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameCloudExadataInfrastructure, data.CloudExadataInfrastructureId.String(), err), - err.Error(), - ) - return - } - if tagsRead != nil { - data.Tags = tftags.FlattenStringValueMap(ctx, tagsRead.Map()) - } - data.CreatedAt = types.StringValue(out.CreatedAt.Format(time.RFC3339)) - data.MaintenanceWindow = d.flattenMaintenanceWindow(ctx, out.MaintenanceWindow) - resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func FindOdbExaDataInfraForDataSourceByID(ctx context.Context, conn *odb.Client, id string) (*odbtypes.CloudExadataInfrastructure, error) { - input := odb.GetCloudExadataInfrastructureInput{ - CloudExadataInfrastructureId: aws.String(id), - } - - out, err := conn.GetCloudExadataInfrastructure(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - - return nil, err - } - - if out == nil || out.CloudExadataInfrastructure == nil { - return nil, tfresource.NewEmptyResultError(&input) - } - - return out.CloudExadataInfrastructure, nil -} - -func (d *dataSourceCloudExadataInfrastructure) flattenMaintenanceWindow(ctx context.Context, obdExaInfraMW *odbtypes.MaintenanceWindow) fwtypes.ObjectValueOf[cloudExadataInfraMaintenanceWindowDataSourceModel] { - //days of week - daysOfWeek := make([]attr.Value, 0, len(obdExaInfraMW.DaysOfWeek)) - for _, dayOfWeek := range obdExaInfraMW.DaysOfWeek { - dayOfWeekStringValue := fwtypes.StringEnumValue(dayOfWeek.Name).StringValue - daysOfWeek = append(daysOfWeek, dayOfWeekStringValue) - } - setValueOfDaysOfWeek, _ := basetypes.NewSetValue(types.StringType, daysOfWeek) - daysOfWeekRead := fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.DayOfWeekName]]{ - SetValue: setValueOfDaysOfWeek, - } - //hours of the day - hoursOfTheDay := make([]attr.Value, 0, len(obdExaInfraMW.HoursOfDay)) - for _, hourOfTheDay := range obdExaInfraMW.HoursOfDay { - daysOfWeekInt32Value := types.Int32Value(hourOfTheDay) - hoursOfTheDay = append(hoursOfTheDay, daysOfWeekInt32Value) - } - setValuesOfHoursOfTheDay, _ := basetypes.NewSetValue(types.Int32Type, hoursOfTheDay) - hoursOfTheDayRead := fwtypes.SetValueOf[types.Int64]{ - SetValue: setValuesOfHoursOfTheDay, - } - //months - months := make([]attr.Value, 0, len(obdExaInfraMW.Months)) - for _, month := range obdExaInfraMW.Months { - monthStringValue := fwtypes.StringEnumValue(month.Name).StringValue - months = append(months, monthStringValue) - } - setValuesOfMonth, _ := basetypes.NewSetValue(types.StringType, months) - monthsRead := fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.MonthName]]{ - SetValue: setValuesOfMonth, - } - //weeks of month - weeksOfMonth := make([]attr.Value, 0, len(obdExaInfraMW.WeeksOfMonth)) - for _, weekOfMonth := range obdExaInfraMW.WeeksOfMonth { - weeksOfMonthInt32Value := types.Int32Value(weekOfMonth) - weeksOfMonth = append(weeksOfMonth, weeksOfMonthInt32Value) - } - setValuesOfWeekOfMonth, _ := basetypes.NewSetValue(types.Int32Type, weeksOfMonth) - weeksOfMonthRead := fwtypes.SetValueOf[types.Int64]{ - SetValue: setValuesOfWeekOfMonth, - } - - flattenMW := cloudExadataInfraMaintenanceWindowDataSourceModel{ - CustomActionTimeoutInMins: types.Int32PointerValue(obdExaInfraMW.CustomActionTimeoutInMins), - DaysOfWeek: daysOfWeekRead, - HoursOfDay: hoursOfTheDayRead, - IsCustomActionTimeoutEnabled: types.BoolPointerValue(obdExaInfraMW.IsCustomActionTimeoutEnabled), - LeadTimeInWeeks: types.Int32PointerValue(obdExaInfraMW.LeadTimeInWeeks), - Months: monthsRead, - PatchingMode: fwtypes.StringEnumValue(obdExaInfraMW.PatchingMode), - Preference: fwtypes.StringEnumValue(obdExaInfraMW.Preference), - WeeksOfMonth: weeksOfMonthRead, - } - if obdExaInfraMW.LeadTimeInWeeks == nil { - flattenMW.LeadTimeInWeeks = types.Int32Value(0) - } - if obdExaInfraMW.CustomActionTimeoutInMins == nil { - flattenMW.CustomActionTimeoutInMins = types.Int32Value(0) - } - if obdExaInfraMW.IsCustomActionTimeoutEnabled == nil { - flattenMW.IsCustomActionTimeoutEnabled = types.BoolValue(false) - } - - result, _ := fwtypes.NewObjectValueOf[cloudExadataInfraMaintenanceWindowDataSourceModel](ctx, &flattenMW) - return result -} - -type cloudExadataInfrastructureDataSourceModel struct { - framework.WithRegionModel - ActivatedStorageCount types.Int32 `tfsdk:"activated_storage_count"` - AdditionalStorageCount types.Int32 `tfsdk:"additional_storage_count"` - AvailabilityZone types.String `tfsdk:"availability_zone"` - AvailabilityZoneId types.String `tfsdk:"availability_zone_id"` - AvailableStorageSizeInGBs types.Int32 `tfsdk:"available_storage_size_in_gbs"` - CloudExadataInfrastructureArn types.String `tfsdk:"arn"` - CloudExadataInfrastructureId types.String `tfsdk:"id"` - ComputeCount types.Int32 `tfsdk:"compute_count"` - CpuCount types.Int32 `tfsdk:"cpu_count"` - DataStorageSizeInTBs types.Float64 `tfsdk:"data_storage_size_in_tbs"` - DbNodeStorageSizeInGBs types.Int32 `tfsdk:"db_node_storage_size_in_gbs"` - DbServerVersion types.String `tfsdk:"db_server_version"` - DisplayName types.String `tfsdk:"display_name"` - LastMaintenanceRunId types.String `tfsdk:"last_maintenance_run_id"` - MaxCpuCount types.Int32 `tfsdk:"max_cpu_count"` - MaxDataStorageInTBs types.Float64 `tfsdk:"max_data_storage_in_tbs"` - MaxDbNodeStorageSizeInGBs types.Int32 `tfsdk:"max_db_node_storage_size_in_gbs"` - MaxMemoryInGBs types.Int32 `tfsdk:"max_memory_in_gbs"` - MemorySizeInGBs types.Int32 `tfsdk:"memory_size_in_gbs"` - MonthlyDbServerVersion types.String `tfsdk:"monthly_db_server_version"` - MonthlyStorageServerVersion types.String `tfsdk:"monthly_storage_server_version"` - NextMaintenanceRunId types.String `tfsdk:"next_maintenance_run_id"` - OciResourceAnchorName types.String `tfsdk:"oci_resource_anchor_name"` - OciUrl types.String `tfsdk:"oci_url"` - Ocid types.String `tfsdk:"ocid"` - PercentProgress types.Float64 `tfsdk:"percent_progress"` - Shape types.String `tfsdk:"shape"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - StorageCount types.Int32 `tfsdk:"storage_count"` - StorageServerVersion types.String `tfsdk:"storage_server_version"` - TotalStorageSizeInGBs types.Int32 `tfsdk:"total_storage_size_in_gbs"` - CustomerContactsToSendToOCI fwtypes.SetNestedObjectValueOf[customerContactDataSourceModel] `tfsdk:"customer_contacts_to_send_to_oci"` - ComputeModel fwtypes.StringEnum[odbtypes.ComputeModel] `tfsdk:"compute_model"` - CreatedAt types.String `tfsdk:"created_at" autoflex:",noflatten"` - DatabaseServerType types.String `tfsdk:"database_server_type"` - StorageServerType types.String `tfsdk:"storage_server_type"` - MaintenanceWindow fwtypes.ObjectValueOf[cloudExadataInfraMaintenanceWindowDataSourceModel] `tfsdk:"maintenance_window" autoflex:",noflatten"` - Tags tftags.Map `tfsdk:"tags"` -} - -type cloudExadataInfraMaintenanceWindowDataSourceModel struct { - CustomActionTimeoutInMins types.Int32 `tfsdk:"custom_action_timeout_in_mins"` - DaysOfWeek fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.DayOfWeekName]] `tfsdk:"days_of_week"` - HoursOfDay fwtypes.SetValueOf[types.Int64] `tfsdk:"hours_of_day"` - IsCustomActionTimeoutEnabled types.Bool `tfsdk:"is_custom_action_timeout_enabled"` - LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"` - Months fwtypes.SetValueOf[fwtypes.StringEnum[odbtypes.MonthName]] `tfsdk:"months"` - PatchingMode fwtypes.StringEnum[odbtypes.PatchingModeType] `tfsdk:"patching_mode"` - Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"` - WeeksOfMonth fwtypes.SetValueOf[types.Int64] `tfsdk:"weeks_of_month"` -} -type customerContactDataSourceModel struct { - Email types.String `tfsdk:"email"` -} diff --git a/internal/service/odb/cloud_exadata_infrastructure_data_source_test.go b/internal/service/odb/cloud_exadata_infrastructure_data_source_test.go deleted file mode 100644 index 28f0cb416572..000000000000 --- a/internal/service/odb/cloud_exadata_infrastructure_data_source_test.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package odb_test - -import ( - "context" - "errors" - "fmt" - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "github.com/hashicorp/terraform-provider-aws/names" - "testing" -) - -// Acceptance test access AWS and cost money to run. -func TestAccODBCloudExadataInfrastructureDataSource_basic(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - exaInfraResource := "aws_odb_cloud_exadata_infrastructure.test" - exaInfraDataSource := "data.aws_odb_cloud_exadata_infrastructure.test" - displayNameSuffix := sdkacctest.RandomWithPrefix("tf_") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: testAccCheckCloudExadataInfrastructureDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: basicExaInfraDataSource(displayNameSuffix), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrPair(exaInfraResource, "id", exaInfraDataSource, "id"), - resource.TestCheckResourceAttr(exaInfraDataSource, "shape", "Exadata.X9M"), - resource.TestCheckResourceAttr(exaInfraDataSource, "status", "AVAILABLE"), - resource.TestCheckResourceAttr(exaInfraDataSource, "storage_count", "3"), - resource.TestCheckResourceAttr(exaInfraDataSource, "compute_count", "2"), - ), - }, - }, - }) -} - -func testAccCheckCloudExadataInfrastructureDestroy(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_cloud_exadata_infrastructure" { - continue - } - _, err := tfodb.FindOdbExaDataInfraForDataSourceByID(ctx, conn, rs.Primary.ID) - if tfresource.NotFound(err) { - return nil - } - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudExadataInfrastructure, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudExadataInfrastructure, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} - -func basicExaInfraDataSource(displayNameSuffix string) string { - - testData := fmt.Sprintf(` - - -resource "aws_odb_cloud_exadata_infrastructure" "test" { - display_name = "Ofake_exa_%[1]s" - shape = "Exadata.X9M" - storage_count = 3 - compute_count = 2 - availability_zone_id = "use1-az6" - customer_contacts_to_send_to_oci = ["abc@example.com"] -maintenance_window = { - custom_action_timeout_in_mins = 16 - days_of_week = [] - hours_of_day = [] - is_custom_action_timeout_enabled = true - lead_time_in_weeks = 0 - months = [] - patching_mode = "ROLLING" - preference = "NO_PREFERENCE" - weeks_of_month =[] - } -} - -data "aws_odb_cloud_exadata_infrastructure" "test" { - id = aws_odb_cloud_exadata_infrastructure.test.id -} -`, displayNameSuffix) - return testData -} diff --git a/internal/service/odb/cloud_exadata_infrastructure_test.go b/internal/service/odb/cloud_exadata_infrastructure_test.go deleted file mode 100644 index 4726d9f88372..000000000000 --- a/internal/service/odb/cloud_exadata_infrastructure_test.go +++ /dev/null @@ -1,460 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/create" - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "strings" - "testing" - - "github.com/aws/aws-sdk-go-v2/service/odb" - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Acceptance test access AWS and cost money to run. - -type cloudExaDataInfraResourceTest struct { - displayNamePrefix string -} - -var exaInfraTestResource = cloudExaDataInfraResourceTest{ - displayNamePrefix: "Ofake-exa", -} - -func TestAccODBCloudExadataInfrastructureCreate_basic(t *testing.T) { - ctx := acctest.Context(t) - - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudExaDataInfrastructure odbtypes.CloudExadataInfrastructure - resourceName := "aws_odb_cloud_exadata_infrastructure.test" - rName := sdkacctest.RandomWithPrefix(exaInfraTestResource.displayNamePrefix) - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - exaInfraTestResource.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: exaInfraTestResource.testAccCheckCloudExaDataInfraDestroyed(ctx), - Steps: []resource.TestStep{ - { - Config: exaInfraTestResource.exaDataInfraResourceBasicConfig(rName), - Check: resource.ComposeAggregateTestCheckFunc( - exaInfraTestResource.testAccCheckCloudExadataInfrastructureExists(ctx, resourceName, &cloudExaDataInfrastructure), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} -func TestAccODBCloudExadataInfrastructureCreateWithAllParameters(t *testing.T) { - ctx := acctest.Context(t) - - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudExaDataInfrastructure odbtypes.CloudExadataInfrastructure - resourceName := "aws_odb_cloud_exadata_infrastructure.test" - rName := sdkacctest.RandomWithPrefix(exaInfraTestResource.displayNamePrefix) - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - exaInfraTestResource.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: exaInfraTestResource.testAccCheckCloudExaDataInfraDestroyed(ctx), - Steps: []resource.TestStep{ - { - Config: exaInfraTestResource.exaDataInfraResourceWithAllConfig(rName), - Check: resource.ComposeAggregateTestCheckFunc( - exaInfraTestResource.testAccCheckCloudExadataInfrastructureExists(ctx, resourceName, &cloudExaDataInfrastructure), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBCloudExadataInfrastructureTagging(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudExaDataInfrastructure1 odbtypes.CloudExadataInfrastructure - var cloudExaDataInfrastructure2 odbtypes.CloudExadataInfrastructure - var cloudExaDataInfrastructure3 odbtypes.CloudExadataInfrastructure - resourceName := "aws_odb_cloud_exadata_infrastructure.test" - rName := sdkacctest.RandomWithPrefix(exaInfraTestResource.displayNamePrefix) - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: exaInfraTestResource.testAccCheckCloudExaDataInfraDestroyed(ctx), - Steps: []resource.TestStep{ - { - Config: exaInfraTestResource.exaDataInfraResourceBasicConfig(rName), - Check: resource.ComposeAggregateTestCheckFunc( - exaInfraTestResource.testAccCheckCloudExadataInfrastructureExists(ctx, resourceName, &cloudExaDataInfrastructure1), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - { - Config: exaInfraTestResource.exaDataInfraResourceBasicConfigAddTags(rName), - Check: resource.ComposeAggregateTestCheckFunc( - exaInfraTestResource.testAccCheckCloudExadataInfrastructureExists(ctx, resourceName, &cloudExaDataInfrastructure2), - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - if strings.Compare(*(cloudExaDataInfrastructure1.CloudExadataInfrastructureId), *(cloudExaDataInfrastructure2.CloudExadataInfrastructureId)) != 0 { - return errors.New("Should not create a new cloud exa basicExaInfraDataSource after update") - } - return nil - }), - resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), - resource.TestCheckResourceAttr(resourceName, "tags.env", "dev"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - { - Config: exaInfraTestResource.exaDataInfraResourceBasicConfigRemoveTags(rName), - Check: resource.ComposeAggregateTestCheckFunc( - exaInfraTestResource.testAccCheckCloudExadataInfrastructureExists(ctx, resourceName, &cloudExaDataInfrastructure3), - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - if strings.Compare(*(cloudExaDataInfrastructure1.CloudExadataInfrastructureId), *(cloudExaDataInfrastructure3.CloudExadataInfrastructureId)) != 0 { - return errors.New("Should not create a new cloud exa basicExaInfraDataSource after update") - } - return nil - }), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBCloudExadataUpdateMaintenanceWindow(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudExaDataInfrastructure1 odbtypes.CloudExadataInfrastructure - var cloudExaDataInfrastructure2 odbtypes.CloudExadataInfrastructure - resourceName := "aws_odb_cloud_exadata_infrastructure.test" - rName := sdkacctest.RandomWithPrefix(exaInfraTestResource.displayNamePrefix) - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: exaInfraTestResource.testAccCheckCloudExaDataInfraDestroyed(ctx), - Steps: []resource.TestStep{ - { - Config: exaInfraTestResource.exaDataInfraResourceBasicConfig(rName), - Check: resource.ComposeAggregateTestCheckFunc( - exaInfraTestResource.testAccCheckCloudExadataInfrastructureExists(ctx, resourceName, &cloudExaDataInfrastructure1), - resource.TestCheckResourceAttr(resourceName, "maintenance_window.preference", "NO_PREFERENCE"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - { - Config: exaInfraTestResource.basicWithCustomMaintenanceWindow(rName), - Check: resource.ComposeAggregateTestCheckFunc( - exaInfraTestResource.testAccCheckCloudExadataInfrastructureExists(ctx, resourceName, &cloudExaDataInfrastructure2), - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - if strings.Compare(*(cloudExaDataInfrastructure1.CloudExadataInfrastructureId), *(cloudExaDataInfrastructure2.CloudExadataInfrastructureId)) != 0 { - return errors.New("Should not create a new cloud exa basicExaInfraDataSource after update") - } - return nil - }), - resource.TestCheckResourceAttr(resourceName, "maintenance_window.preference", "CUSTOM_PREFERENCE"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBCloudExadataInfrastructure_disappears(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudExaDataInfrastructure odbtypes.CloudExadataInfrastructure - - rName := sdkacctest.RandomWithPrefix("") - resourceName := "aws_odb_cloud_exadata_infrastructure.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: exaInfraTestResource.testAccCheckCloudExaDataInfraDestroyed(ctx), - Steps: []resource.TestStep{ - { - Config: exaInfraTestResource.exaDataInfraResourceBasicConfig(rName), - Check: resource.ComposeTestCheckFunc( - exaInfraTestResource.testAccCheckCloudExadataInfrastructureExists(ctx, resourceName, &cloudExaDataInfrastructure), - acctest.CheckFrameworkResourceDisappears(ctx, acctest.Provider, tfodb.ResourceCloudExadataInfrastructure, resourceName), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func (cloudExaDataInfraResourceTest) testAccCheckCloudExaDataInfraDestroyed(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_cloud_exadata_infrastructure" { - continue - } - _, err := tfodb.FindOdbExadataInfraResourceByID(ctx, conn, rs.Primary.ID) - if tfresource.NotFound(err) { - return nil - } - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudExadataInfrastructure, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudExadataInfrastructure, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} - -func (cloudExaDataInfraResourceTest) testAccCheckCloudExadataInfrastructureExists(ctx context.Context, name string, cloudExadataInfrastructure *odbtypes.CloudExadataInfrastructure) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudExadataInfrastructure, name, errors.New("not found")) - } - - if rs.Primary.ID == "" { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudExadataInfrastructure, name, errors.New("not set")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - resp, err := tfodb.FindOdbExadataInfraResourceByID(ctx, conn, rs.Primary.ID) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudExadataInfrastructure, rs.Primary.ID, err) - } - - *cloudExadataInfrastructure = *resp - - return nil - } -} - -func (cloudExaDataInfraResourceTest) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListCloudExadataInfrastructuresInput{} - - _, err := conn.ListCloudExadataInfrastructures(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} - -/* - func testAccCheckCloudExadataInfrastructureNotRecreated(before, after *odb.DescribeCloudExadataInfrastructureResponse) resource.TestCheckFunc { - return func(s *terraform.State) error { - if before, after := aws.ToString(before.CloudExadataInfrastructureId), aws.ToString(after.CloudExadataInfrastructureId); before != after { - return create.Error(names.ODB, create.ErrActionCheckingNotRecreated, tfodb.ResNameCloudExadataInfrastructure, aws.ToString(before.CloudExadataInfrastructureId), errors.New("recreated")) - } - - return nil - } - } -*/ -func (cloudExaDataInfraResourceTest) exaDataInfraResourceWithAllConfig(randomId string) string { - exaDataInfra := fmt.Sprintf(` - -resource "aws_odb_cloud_exadata_infrastructure" "test" { - display_name = %[1]q - shape = "Exadata.X11M" - storage_count = 3 - compute_count = 2 - availability_zone_id = "use1-az6" - customer_contacts_to_send_to_oci = ["abc@example.com"] - database_server_type = "X11M" - storage_server_type = "X11M-HC" - maintenance_window = { - custom_action_timeout_in_mins = 16 - days_of_week = ["MONDAY", "TUESDAY"] - hours_of_day = [11,16] - is_custom_action_timeout_enabled = true - lead_time_in_weeks = 3 - months = ["FEBRUARY","MAY","AUGUST","NOVEMBER"] - patching_mode = "ROLLING" - preference = "CUSTOM_PREFERENCE" - weeks_of_month =[2,4] - } - tags = { - "env"= "dev" - } - -} -`, randomId) - //fmt.Println(exaDataInfra) - return exaDataInfra -} -func (cloudExaDataInfraResourceTest) exaDataInfraResourceBasicConfig(displayName string) string { - exaInfra := fmt.Sprintf(` -resource "aws_odb_cloud_exadata_infrastructure" "test" { - display_name = %[1]q - shape = "Exadata.X9M" - storage_count = 3 - compute_count = 2 - availability_zone_id = "use1-az6" - maintenance_window = { - custom_action_timeout_in_mins = 16 - days_of_week = [] - hours_of_day = [] - is_custom_action_timeout_enabled = true - lead_time_in_weeks = 0 - months = [] - patching_mode = "ROLLING" - preference = "NO_PREFERENCE" - weeks_of_month =[] - } -} -`, displayName) - return exaInfra -} -func (cloudExaDataInfraResourceTest) exaDataInfraResourceBasicConfigAddTags(displayName string) string { - exaInfra := fmt.Sprintf(` -resource "aws_odb_cloud_exadata_infrastructure" "test" { - display_name = %[1]q - shape = "Exadata.X9M" - storage_count = 3 - compute_count = 2 - availability_zone_id = "use1-az6" -maintenance_window = { - custom_action_timeout_in_mins = 16 - days_of_week = [] - hours_of_day = [] - is_custom_action_timeout_enabled = true - lead_time_in_weeks = 0 - months = [] - patching_mode = "ROLLING" - preference = "NO_PREFERENCE" - weeks_of_month =[] - } - tags = { - "env"= "dev" - } -} -`, displayName) - return exaInfra -} - -func (cloudExaDataInfraResourceTest) exaDataInfraResourceBasicConfigRemoveTags(displayName string) string { - exaInfra := fmt.Sprintf(` -resource "aws_odb_cloud_exadata_infrastructure" "test" { - display_name = %[1]q - shape = "Exadata.X9M" - storage_count = 3 - compute_count = 2 - availability_zone_id = "use1-az6" -maintenance_window = { - custom_action_timeout_in_mins = 16 - days_of_week = [] - hours_of_day = [] - is_custom_action_timeout_enabled = true - lead_time_in_weeks = 0 - months = [] - patching_mode = "ROLLING" - preference = "NO_PREFERENCE" - weeks_of_month =[] - } -} -`, displayName) - return exaInfra -} -func (cloudExaDataInfraResourceTest) basicWithCustomMaintenanceWindow(displayName string) string { - exaInfra := fmt.Sprintf(` -resource "aws_odb_cloud_exadata_infrastructure" "test" { - display_name = %[1]q - shape = "Exadata.X9M" - storage_count = 3 - compute_count = 2 - availability_zone_id = "use1-az6" - maintenance_window = { - custom_action_timeout_in_mins = 16 - days_of_week = ["MONDAY", "TUESDAY"] - hours_of_day = [11,16] - is_custom_action_timeout_enabled = true - lead_time_in_weeks = 3 - months = ["FEBRUARY","MAY","AUGUST","NOVEMBER"] - patching_mode = "ROLLING" - preference = "CUSTOM_PREFERENCE" - weeks_of_month =[2,4] - } -} -`, displayName) - return exaInfra -} diff --git a/internal/service/odb/cloud_exadata_infrastructures_list_data_source.go b/internal/service/odb/cloud_exadata_infrastructures_list_data_source.go deleted file mode 100644 index 9194f93d62ff..000000000000 --- a/internal/service/odb/cloud_exadata_infrastructures_list_data_source.go +++ /dev/null @@ -1,90 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "github.com/aws/aws-sdk-go-v2/service/odb" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// @FrameworkDataSource("aws_odb_cloud_exadata_infrastructures_list", name="Cloud Exadata Infrastructures List") -func newDataSourceCloudExadataInfrastructuresList(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceCloudExadataInfrastructuresList{}, nil -} - -const ( - DSNameCloudExadataInfrastructuresList = "Cloud Exadata Infrastructures List Data Source" -) - -type dataSourceCloudExadataInfrastructuresList struct { - framework.DataSourceWithModel[cloudExadataInfrastructuresListDataSourceModel] -} - -func (d *dataSourceCloudExadataInfrastructuresList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "cloud_exadata_infrastructures": schema.ListAttribute{ - Computed: true, - Description: "List of Cloud Exadata Infrastructures (OCID, ID, ARN and OCI URL)", - CustomType: fwtypes.NewListNestedObjectTypeOf[cloudExadataInfrastructureDataSourceListSummary](ctx), - ElementType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "arn": types.StringType, - "id": types.StringType, - "oci_url": types.StringType, - "ocid": types.StringType, - }, - }, - }, - }, - } - -} - -func (d *dataSourceCloudExadataInfrastructuresList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - - var data cloudExadataInfrastructuresListDataSourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := conn.ListCloudExadataInfrastructures(ctx, &odb.ListCloudExadataInfrastructuresInput{}) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameCloudExadataInfrastructuresList, "", err), - err.Error(), - ) - return - } - - resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type cloudExadataInfrastructuresListDataSourceModel struct { - framework.WithRegionModel - CloudExadataInfrastructures fwtypes.ListNestedObjectValueOf[cloudExadataInfrastructureDataSourceListSummary] `tfsdk:"cloud_exadata_infrastructures"` -} - -type cloudExadataInfrastructureDataSourceListSummary struct { - CloudExadataInfrastructureArn types.String `tfsdk:"arn"` - CloudExadataInfrastructureId types.String `tfsdk:"id"` - OciUrl types.String `tfsdk:"oci_url"` - Ocid types.String `tfsdk:"ocid"` -} diff --git a/internal/service/odb/cloud_exadata_infrastructures_list_data_source_test.go b/internal/service/odb/cloud_exadata_infrastructures_list_data_source_test.go deleted file mode 100644 index 370d4a07b88c..000000000000 --- a/internal/service/odb/cloud_exadata_infrastructures_list_data_source_test.go +++ /dev/null @@ -1,101 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/create" - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "strconv" - "testing" - - "github.com/aws/aws-sdk-go-v2/service/odb" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - - "github.com/hashicorp/terraform-provider-aws/names" -) - -type listExaInfraTest struct { -} - -func TestAccODBCloudExadataInfrastructuresListDataSource_basic(t *testing.T) { - ctx := acctest.Context(t) - var listExaInfraDSTest = listExaInfraTest{} - var infraList odb.ListCloudExadataInfrastructuresOutput - - dataSourceName := "data.aws_odb_cloud_exadata_infrastructures_list.test" - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - listExaInfraDSTest.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - Steps: []resource.TestStep{ - { - Config: listExaInfraDSTest.basic(), - Check: resource.ComposeAggregateTestCheckFunc( - - resource.ComposeTestCheckFunc(func(s *terraform.State) error { - listExaInfraDSTest.countExaInfrastructures(ctx, dataSourceName, &infraList) - resource.TestCheckResourceAttr(dataSourceName, "cloud_exadata_infrastructures.#", strconv.Itoa(len(infraList.CloudExadataInfrastructures))) - return nil - }, - ), - ), - }, - }, - }) -} - -func (listExaInfraTest) basic() string { - config := fmt.Sprintf(` - - -data "aws_odb_cloud_exadata_infrastructures_list" "test" { - -} -`) - return config -} - -func (listExaInfraTest) countExaInfrastructures(ctx context.Context, name string, listOfInfra *odb.ListCloudExadataInfrastructuresOutput) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, name, errors.New("not found")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - resp, err := conn.ListCloudExadataInfrastructures(ctx, &odb.ListCloudExadataInfrastructuresInput{}) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, rs.Primary.ID, err) - } - - listOfInfra.CloudExadataInfrastructures = resp.CloudExadataInfrastructures - - return nil - } -} -func (listExaInfraTest) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListCloudAutonomousVmClustersInput{} - - _, err := conn.ListCloudAutonomousVmClusters(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} diff --git a/internal/service/odb/cloud_vm_cluster.go b/internal/service/odb/cloud_vm_cluster.go deleted file mode 100644 index f4447a87be25..000000000000 --- a/internal/service/odb/cloud_vm_cluster.go +++ /dev/null @@ -1,670 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "errors" - awstypes "github.com/aws/aws-sdk-go-v2/service/computeoptimizer/types" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" - "strings" - - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/float64planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/int32planmodifier" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" - "github.com/hashicorp/terraform-provider-aws/internal/enum" - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" - "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/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - "github.com/hashicorp/terraform-provider-aws/internal/errs/fwdiag" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/sweep" - sweepfw "github.com/hashicorp/terraform-provider-aws/internal/sweep/framework" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for resource registration to the Provider. DO NOT EDIT. -// @FrameworkResource("aws_odb_cloud_vm_cluster", name="Cloud Vm Cluster") -// @Tags(identifierAttribute="arn") -func newResourceCloudVmCluster(_ context.Context) (resource.ResourceWithConfigure, error) { - r := &resourceCloudVmCluster{} - - r.SetDefaultCreateTimeout(24 * time.Hour) - r.SetDefaultUpdateTimeout(24 * time.Hour) - r.SetDefaultDeleteTimeout(24 * time.Hour) - - return r, nil -} - -const ( - ResNameCloudVmCluster = "Cloud Vm Cluster" -) - -var ResourceCloudVmCluster = newResourceCloudVmCluster - -type resourceCloudVmCluster struct { - framework.ResourceWithModel[cloudVmClusterResourceModel] - framework.WithTimeouts -} - -func (r *resourceCloudVmCluster) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - statusType := fwtypes.StringEnumType[odbtypes.ResourceStatus]() - licenseModelType := fwtypes.StringEnumType[odbtypes.LicenseModel]() - diskRedundancyType := fwtypes.StringEnumType[odbtypes.DiskRedundancy]() - computeModelType := fwtypes.StringEnumType[odbtypes.ComputeModel]() - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - names.AttrARN: framework.ARNAttributeComputedOnly(), - "cloud_exadata_infrastructure_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "cluster_name": schema.StringAttribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - stringplanmodifier.UseStateForUnknown(), - }, - }, - "cpu_core_count": schema.Int32Attribute{ - Required: true, - PlanModifiers: []planmodifier.Int32{ - int32planmodifier.RequiresReplace(), - }, - }, - "data_collection_options": schema.ObjectAttribute{ - Computed: true, - Optional: true, - CustomType: fwtypes.NewObjectTypeOf[cloudVMCResourceModelDataCollectionOptions](ctx), - }, - "data_storage_size_in_tbs": schema.Float64Attribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.Float64{ - float64planmodifier.RequiresReplace(), - float64planmodifier.UseStateForUnknown(), - }, - }, - "db_node_storage_size_in_gbs": schema.Int32Attribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.Int32{ - int32planmodifier.RequiresReplace(), - int32planmodifier.UseStateForUnknown(), - }, - }, - "db_servers": schema.SetAttribute{ - CustomType: fwtypes.SetOfStringType, - ElementType: types.StringType, - Required: true, - PlanModifiers: []planmodifier.Set{ - setplanmodifier.RequiresReplace(), - }, - }, - "disk_redundancy": schema.StringAttribute{ - CustomType: diskRedundancyType, - Computed: true, - }, - "display_name": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "domain": schema.StringAttribute{ - Computed: true, - }, - "gi_version": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "hostname_prefix_computed": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - "hostname_prefix": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - names.AttrID: framework.IDAttribute(), - "iorm_config_cache": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.NewListNestedObjectTypeOf[cloudVMCResourceModelExadataIormConfig](ctx), - ElementType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "lifecycle_details": types.StringType, - "lifecycle_state": fwtypes.StringEnumType[odbtypes.IormLifecycleState](), - "objective": fwtypes.StringEnumType[odbtypes.Objective](), - "db_plans": types.ListType{ - ElemType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "db_name": types.StringType, - "flash_cache_limit": types.StringType, - "share": types.Int32Type, - }, - }, - }, - }, - }, - }, - "is_local_backup_enabled": schema.BoolAttribute{ - Optional: true, - Computed: true, - }, - "is_sparse_diskgroup_enabled": schema.BoolAttribute{ - Optional: true, - Computed: true, - }, - "last_update_history_entry_id": schema.StringAttribute{ - Computed: true, - }, - "license_model": schema.StringAttribute{ - CustomType: licenseModelType, - Optional: true, - Computed: true, - }, - "listener_port": schema.Int32Attribute{ - Computed: true, - }, - "memory_size_in_gbs": schema.Int32Attribute{ - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.Int32{ - int32planmodifier.RequiresReplace(), - int32planmodifier.UseStateForUnknown(), - }, - }, - "node_count": schema.Int32Attribute{ - Computed: true, - }, - "ocid": schema.StringAttribute{ - Computed: true, - }, - "oci_resource_anchor_name": schema.StringAttribute{ - Computed: true, - }, - "oci_url": schema.StringAttribute{ - Computed: true, - }, - "odb_network_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - "percent_progress": schema.Float32Attribute{ - Computed: true, - }, - "scan_dns_name": schema.StringAttribute{ - Computed: true, - }, - "scan_dns_record_id": schema.StringAttribute{ - Computed: true, - }, - "scan_ip_ids": schema.ListAttribute{ - CustomType: fwtypes.ListOfStringType, - ElementType: types.StringType, - Computed: true, - }, - "shape": schema.StringAttribute{ - Computed: true, - }, - "ssh_public_keys": schema.SetAttribute{ - Required: true, - CustomType: fwtypes.SetOfStringType, - ElementType: types.StringType, - PlanModifiers: []planmodifier.Set{ - setplanmodifier.RequiresReplace(), - }, - }, - "status": schema.StringAttribute{ - Computed: true, - CustomType: statusType, - }, - "status_reason": schema.StringAttribute{ - Computed: true, - }, - "storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - }, - "system_version": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - "timezone": schema.StringAttribute{ - Optional: true, - Computed: true, - }, - "vip_ids": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.ListOfStringType, - ElementType: types.StringType, - }, - "created_at": schema.StringAttribute{ - Computed: true, - }, - "compute_model": schema.StringAttribute{ - CustomType: computeModelType, - Computed: true, - }, - "scan_listener_port_tcp": schema.Int32Attribute{ - Computed: true, - Optional: true, - PlanModifiers: []planmodifier.Int32{ - int32planmodifier.RequiresReplace(), - int32planmodifier.UseStateForUnknown(), - }, - }, - names.AttrTags: tftags.TagsAttribute(), - names.AttrTagsAll: tftags.TagsAttributeComputedOnly(), - }, - Blocks: map[string]schema.Block{ - "timeouts": timeouts.Block(ctx, timeouts.Opts{ - Create: true, - Update: true, - Delete: true, - }), - }, - } -} - -func (r *resourceCloudVmCluster) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - conn := r.Meta().ODBClient(ctx) - - var plan cloudVmClusterResourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.CreateCloudVmClusterInput{ - Tags: getTagsIn(ctx), - GiVersion: plan.GiVersion.ValueStringPointer(), - ClientToken: aws.String(id.UniqueId()), - Hostname: plan.HostnamePrefix.ValueStringPointer(), - } - resp.Diagnostics.Append(flex.Expand(ctx, plan, &input)...) - - if resp.Diagnostics.HasError() { - return - } - - out, err := conn.CreateCloudVmCluster(ctx, &input) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameCloudVmCluster, plan.DisplayName.ValueString(), err), - err.Error(), - ) - return - } - if out == nil || out.CloudVmClusterId == nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameCloudVmCluster, plan.DisplayName.ValueString(), nil), - errors.New("empty output").Error(), - ) - return - } - - createTimeout := r.CreateTimeout(ctx, plan.Timeouts) - createdVmCluster, err := waitCloudVmClusterCreated(ctx, conn, *out.CloudVmClusterId, createTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForCreation, ResNameCloudVmCluster, plan.DisplayName.ValueString(), err), - err.Error(), - ) - return - } - hostnamePrefix := strings.Split(*input.Hostname, "-")[0] - plan.HostnamePrefix = types.StringValue(hostnamePrefix) - plan.HostnamePrefixComputed = types.StringValue(*createdVmCluster.Hostname) - plan.CreatedAt = types.StringValue(createdVmCluster.CreatedAt.Format(time.RFC3339)) - plan.ScanListenerPortTcp = types.Int32PointerValue(createdVmCluster.ListenerPort) - - resp.Diagnostics.Append(flex.Flatten(ctx, createdVmCluster, &plan, flex.WithIgnoredFieldNamesAppend("HostnamePrefix"), - flex.WithIgnoredFieldNamesAppend("HostnamePrefixComputed"), - flex.WithIgnoredFieldNamesAppend("CreatedAt"), - flex.WithIgnoredFieldNamesAppend("ScanListenerPortTcp"))...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) -} - -func (r *resourceCloudVmCluster) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - - conn := r.Meta().ODBClient(ctx) - var state cloudVmClusterResourceModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := FindCloudVmClusterForResourceByID(ctx, conn, state.CloudVmClusterId.ValueString()) - if tfresource.NotFound(err) { - resp.Diagnostics.Append(fwdiag.NewResourceNotFoundWarningDiagnostic(err)) - resp.State.RemoveResource(ctx) - return - } - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, ResNameCloudVmCluster, state.CloudVmClusterId.ValueString(), err), - err.Error(), - ) - return - } - hostnamePrefix := strings.Split(*out.Hostname, "-")[0] - state.HostnamePrefix = types.StringValue(hostnamePrefix) - state.HostnamePrefixComputed = types.StringValue(*out.Hostname) - state.CreatedAt = types.StringValue(out.CreatedAt.Format(time.RFC3339)) - state.ScanListenerPortTcp = types.Int32PointerValue(out.ListenerPort) - resp.Diagnostics.Append(flex.Flatten(ctx, out, &state, flex.WithIgnoredFieldNamesAppend("HostnamePrefix"), - flex.WithIgnoredFieldNamesAppend("HostnamePrefixComputed"), flex.WithIgnoredFieldNamesAppend("CreatedAt"), - flex.WithIgnoredFieldNamesAppend("ScanListenerPortTcp"))...) - - if resp.Diagnostics.HasError() { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) -} - -func (r *resourceCloudVmCluster) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - - var plan, state cloudVmClusterResourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - conn := r.Meta().ODBClient(ctx) - updateTimeout := r.UpdateTimeout(ctx, plan.Timeouts) - updatedVMC, err := waitCloudVmClusterUpdated(ctx, conn, plan.CloudVmClusterId.ValueString(), updateTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameCloudVmCluster, plan.CloudVmClusterId.String(), err), - err.Error(), - ) - return - } - hostnamePrefix := strings.Split(*updatedVMC.Hostname, "-")[0] - plan.HostnamePrefix = types.StringValue(hostnamePrefix) - plan.HostnamePrefixComputed = types.StringValue(*updatedVMC.Hostname) - plan.CreatedAt = types.StringValue(updatedVMC.CreatedAt.Format(time.RFC3339)) - plan.ScanListenerPortTcp = types.Int32PointerValue(updatedVMC.ListenerPort) - resp.Diagnostics.Append(flex.Flatten(ctx, updatedVMC, &plan, flex.WithIgnoredFieldNamesAppend("HostnamePrefix"), - flex.WithIgnoredFieldNamesAppend("HostnamePrefixComputed"), flex.WithIgnoredFieldNamesAppend("CreatedAt"), - flex.WithIgnoredFieldNamesAppend("ScanListenerPortTcp"))...) - - if resp.Diagnostics.HasError() { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) -} - -func (r *resourceCloudVmCluster) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - - conn := r.Meta().ODBClient(ctx) - - var state cloudVmClusterResourceModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.DeleteCloudVmClusterInput{ - CloudVmClusterId: state.CloudVmClusterId.ValueStringPointer(), - } - - _, err := conn.DeleteCloudVmCluster(ctx, &input) - if err != nil { - if errs.IsA[*awstypes.ResourceNotFoundException](err) { - return - } - - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionDeleting, ResNameCloudVmCluster, state.CloudVmClusterId.ValueString(), err), - err.Error(), - ) - return - } - - // TIP: -- 5. Use a waiter to wait for delete to complete - deleteTimeout := r.DeleteTimeout(ctx, state.Timeouts) - _, err = waitCloudVmClusterDeleted(ctx, conn, state.CloudVmClusterId.ValueString(), deleteTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForDeletion, ResNameCloudVmCluster, state.CloudVmClusterId.ValueString(), err), - err.Error(), - ) - return - } -} - -func (r *resourceCloudVmCluster) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resource.ImportStatePassthroughID(ctx, path.Root(names.AttrID), req, resp) -} - -func waitCloudVmClusterCreated(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.CloudVmCluster, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusProvisioning), - Target: enum.Slice(odbtypes.ResourceStatusAvailable, odbtypes.ResourceStatusFailed), - Refresh: statusCloudVmCluster(ctx, conn, id), - Timeout: timeout, - NotFoundChecks: 20, - ContinuousTargetOccurence: 2, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.CloudVmCluster); ok { - return out, err - } - - return nil, err -} - -func waitCloudVmClusterUpdated(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.CloudVmCluster, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusUpdating), - Target: enum.Slice(odbtypes.ResourceStatusAvailable, odbtypes.ResourceStatusFailed), - Refresh: statusCloudVmCluster(ctx, conn, id), - Timeout: timeout, - NotFoundChecks: 20, - ContinuousTargetOccurence: 2, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.CloudVmCluster); ok { - return out, err - } - - return nil, err -} - -func waitCloudVmClusterDeleted(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.CloudVmCluster, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusTerminating), - Target: []string{}, - Refresh: statusCloudVmCluster(ctx, conn, id), - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.CloudVmCluster); ok { - return out, err - } - - return nil, err -} - -func statusCloudVmCluster(ctx context.Context, conn *odb.Client, id string) retry.StateRefreshFunc { - return func() (any, string, error) { - out, err := FindCloudVmClusterForResourceByID(ctx, conn, id) - if tfresource.NotFound(err) { - return nil, "", nil - } - - if err != nil { - return nil, "", err - } - - return out, string(out.Status), nil - } -} - -func FindCloudVmClusterForResourceByID(ctx context.Context, conn *odb.Client, id string) (*odbtypes.CloudVmCluster, error) { - input := odb.GetCloudVmClusterInput{ - CloudVmClusterId: aws.String(id), - } - - out, err := conn.GetCloudVmCluster(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - - return nil, err - } - - if out == nil || out.CloudVmCluster == nil { - return nil, tfresource.NewEmptyResultError(&input) - } - return out.CloudVmCluster, nil -} - -// TIP: ==== SWEEPERS ==== -// When acceptance testing resources, interrupted or failed tests may -// leave behind orphaned resources in an account. To facilitate cleaning -// up lingering resources, each resource implementation should include -// a corresponding "sweeper" function. -// -// The sweeper function lists all resources of a given type and sets the -// appropriate identifers required to delete the resource via the Delete -// method implemented above. -// -// Once the sweeper function is implemented, register it in sweeper.go -// as follows: -// -// awsv2.Register("aws_odb_cloud_vm_cluster", sweepCloudVmClusters) -// -// See more: -// https://hashicorp.github.io/terraform-provider-aws/running-and-writing-acceptance-tests/#acceptance-test-sweepers -func sweepCloudVmClusters(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) { - input := odb.ListCloudVmClustersInput{} - conn := client.ODBClient(ctx) - var sweepResources []sweep.Sweepable - - pages := odb.NewListCloudVmClustersPaginator(conn, &input) - for pages.HasMorePages() { - page, err := pages.NextPage(ctx) - if err != nil { - return nil, err - } - - for _, v := range page.CloudVmClusters { - sweepResources = append(sweepResources, sweepfw.NewSweepResource(newResourceCloudVmCluster, client, - sweepfw.NewAttribute(names.AttrID, aws.ToString(v.CloudVmClusterId))), - ) - } - } - - return sweepResources, nil -} - -type cloudVmClusterResourceModel struct { - framework.WithRegionModel - CloudVmClusterArn types.String `tfsdk:"arn"` - CloudExadataInfrastructureId types.String `tfsdk:"cloud_exadata_infrastructure_id"` - CloudVmClusterId types.String `tfsdk:"id"` - ClusterName types.String `tfsdk:"cluster_name"` - CpuCoreCount types.Int32 `tfsdk:"cpu_core_count"` - DataCollectionOptions fwtypes.ObjectValueOf[cloudVMCResourceModelDataCollectionOptions] `tfsdk:"data_collection_options"` - DataStorageSizeInTBs types.Float64 `tfsdk:"data_storage_size_in_tbs"` - DbNodeStorageSizeInGBs types.Int32 `tfsdk:"db_node_storage_size_in_gbs"` - DbServers fwtypes.SetValueOf[types.String] `tfsdk:"db_servers"` - DiskRedundancy fwtypes.StringEnum[odbtypes.DiskRedundancy] `tfsdk:"disk_redundancy"` - DisplayName types.String `tfsdk:"display_name"` - Domain types.String `tfsdk:"domain"` - GiVersion types.String `tfsdk:"gi_version"` - HostnamePrefixComputed types.String `tfsdk:"hostname_prefix_computed"` - HostnamePrefix types.String `tfsdk:"hostname_prefix"` - IormConfigCache fwtypes.ListNestedObjectValueOf[cloudVMCResourceModelExadataIormConfig] `tfsdk:"iorm_config_cache"` - IsLocalBackupEnabled types.Bool `tfsdk:"is_local_backup_enabled"` - IsSparseDiskGroupEnabled types.Bool `tfsdk:"is_sparse_diskgroup_enabled"` - LastUpdateHistoryEntryId types.String `tfsdk:"last_update_history_entry_id"` - LicenseModel fwtypes.StringEnum[odbtypes.LicenseModel] `tfsdk:"license_model"` - ListenerPort types.Int32 `tfsdk:"listener_port"` - MemorySizeInGbs types.Int32 `tfsdk:"memory_size_in_gbs"` - NodeCount types.Int32 `tfsdk:"node_count"` - Ocid types.String `tfsdk:"ocid"` - OciResourceAnchorName types.String `tfsdk:"oci_resource_anchor_name"` - OciUrl types.String `tfsdk:"oci_url"` - OdbNetworkId types.String `tfsdk:"odb_network_id"` - PercentProgress types.Float32 `tfsdk:"percent_progress"` - ScanDnsName types.String `tfsdk:"scan_dns_name"` - ScanDnsRecordId types.String `tfsdk:"scan_dns_record_id"` - ScanIpIds fwtypes.ListValueOf[types.String] `tfsdk:"scan_ip_ids"` - Shape types.String `tfsdk:"shape"` - SshPublicKeys fwtypes.SetValueOf[types.String] `tfsdk:"ssh_public_keys"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - StorageSizeInGBs types.Int32 `tfsdk:"storage_size_in_gbs"` - SystemVersion types.String `tfsdk:"system_version"` - Timeouts timeouts.Value `tfsdk:"timeouts"` - Timezone types.String `tfsdk:"timezone"` - VipIds fwtypes.ListValueOf[types.String] `tfsdk:"vip_ids"` - CreatedAt types.String `tfsdk:"created_at"` - ComputeModel fwtypes.StringEnum[odbtypes.ComputeModel] `tfsdk:"compute_model"` - ScanListenerPortTcp types.Int32 `tfsdk:"scan_listener_port_tcp"` - Tags tftags.Map `tfsdk:"tags"` - TagsAll tftags.Map `tfsdk:"tags_all"` -} - -type cloudVMCResourceModelDataCollectionOptions struct { - IsDiagnosticsEventsEnabled types.Bool `tfsdk:"is_diagnostics_events_enabled"` - IsHealthMonitoringEnabled types.Bool `tfsdk:"is_health_monitoring_enabled"` - IsIncidentLogsEnabled types.Bool `tfsdk:"is_incident_logs_enabled"` -} - -type cloudVMCResourceModelExadataIormConfig struct { - DbPlans fwtypes.ListNestedObjectValueOf[cloudVMCResourceModelDbIormConfig] `tfsdk:"db_plans"` - LifecycleDetails types.String `tfsdk:"lifecycle_details"` - LifecycleState fwtypes.StringEnum[odbtypes.IormLifecycleState] `tfsdk:"lifecycle_state"` - Objective fwtypes.StringEnum[odbtypes.Objective] `tfsdk:"objective"` -} - -type cloudVMCResourceModelDbIormConfig struct { - DbName types.String `tfsdk:"db_name"` - FlashCacheLimit types.String `tfsdk:"flash_cache_limit"` - Share types.Int32 `tfsdk:"share"` -} diff --git a/internal/service/odb/cloud_vm_cluster_data_source.go b/internal/service/odb/cloud_vm_cluster_data_source.go deleted file mode 100644 index bf63f25c157f..000000000000 --- a/internal/service/odb/cloud_vm_cluster_data_source.go +++ /dev/null @@ -1,368 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "time" - - "github.com/aws/aws-sdk-go-v2/service/odb" - - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// @FrameworkDataSource("aws_odb_cloud_vm_cluster", name="Cloud Vm Cluster") -func newDataSourceCloudVmCluster(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceCloudVmCluster{}, nil -} - -const ( - DSNameCloudVmCluster = "Cloud Vm Cluster Data Source" -) - -type dataSourceCloudVmCluster struct { - framework.DataSourceWithModel[dataSourceCloudVmClusterModel] -} - -func (d *dataSourceCloudVmCluster) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - statusType := fwtypes.StringEnumType[odbtypes.ResourceStatus]() - diskRedundancyType := fwtypes.StringEnumType[odbtypes.DiskRedundancy]() - licenseModelType := fwtypes.StringEnumType[odbtypes.LicenseModel]() - computeModelType := fwtypes.StringEnumType[odbtypes.ComputeModel]() - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - names.AttrARN: framework.ARNAttributeComputedOnly(), - names.AttrID: schema.StringAttribute{ - Required: true, - Description: "The unique identifier of the VM cluster.", - }, - "cloud_exadata_infrastructure_id": schema.StringAttribute{ - Computed: true, - Description: "The ID of the Cloud Exadata Infrastructure.", - }, - "cluster_name": schema.StringAttribute{ - Computed: true, - Description: "The name of the Grid Infrastructure (GI) cluster.", - }, - "cpu_core_count": schema.Int32Attribute{ - Computed: true, - Description: "The number of CPU cores enabled on the VM cluster.", - }, - "data_storage_size_in_tbs": schema.Float64Attribute{ - Computed: true, - Description: "The size of the data disk group, in terabytes (TB), that's allocated for the VM cluster.", - }, - "db_node_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The amount of local node storage, in gigabytes (GB), that's allocated for the VM cluster.", - }, - "db_servers": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.ListOfStringType, - ElementType: types.StringType, - Description: "The list of database servers for the VM cluster.", - }, - "disk_redundancy": schema.StringAttribute{ - CustomType: diskRedundancyType, - Computed: true, - Description: "The type of redundancy configured for the VM cluster. NORMAL is 2-way redundancy. HIGH is 3-way redundancy.", - }, - "display_name": schema.StringAttribute{ - Computed: true, - Description: "The display name of the VM cluster.", - }, - "domain": schema.StringAttribute{ - Computed: true, - Description: "The domain name of the VM cluster.", - }, - "gi_version": schema.StringAttribute{ - Computed: true, - Description: "he software version of the Oracle Grid Infrastructure (GI) for the VM cluster.", - }, - "hostname_prefix_computed": schema.StringAttribute{ - Computed: true, - Description: "The computed hostname prefix for the VM cluster.", - }, - "is_local_backup_enabled": schema.BoolAttribute{ - Computed: true, - Description: "Indicates whether database backups to local Exadata storage is enabled for the VM cluster.", - }, - "is_sparse_disk_group_enabled": schema.BoolAttribute{ - Computed: true, - Description: "Indicates whether the VM cluster is configured with a sparse disk group.", - }, - "last_update_history_entry_id": schema.StringAttribute{ - Computed: true, - Description: "The Oracle Cloud ID (OCID) of the last maintenance update history entry.", - }, - "license_model": schema.StringAttribute{ - CustomType: licenseModelType, - Computed: true, - Description: "The Oracle license model applied to the VM cluster.", - }, - "listener_port": schema.Int32Attribute{ - Computed: true, - Description: "The port number configured for the listener on the VM cluster.", - }, - "memory_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The amount of memory, in gigabytes (GB), that's allocated for the VM cluster.", - }, - "node_count": schema.Int32Attribute{ - Computed: true, - Description: "The number of nodes in the VM cluster.", - }, - "ocid": schema.StringAttribute{ - Computed: true, - Description: "The OCID of the VM cluster.", - }, - "oci_resource_anchor_name": schema.StringAttribute{ - Computed: true, - Description: "The name of the OCI Resource Anchor.", - }, - "oci_url": schema.StringAttribute{ - Computed: true, - Description: "The HTTPS link to the VM cluster in OCI.", - }, - "odb_network_id": schema.StringAttribute{ - Computed: true, - Description: "The ID of the ODB network.", - }, - "percent_progress": schema.Float64Attribute{ - Computed: true, - Description: "The amount of progress made on the current operation on the VM cluster,expressed as a percentage.", - }, - "scan_dns_name": schema.StringAttribute{ - Computed: true, - Description: "The FQDN of the DNS record for the Single Client Access Name (SCAN) IP\n" + - " addresses that are associated with the VM cluster.", - }, - "scan_dns_record_id": schema.StringAttribute{ - Computed: true, - Description: "The OCID of the DNS record for the SCAN IP addresses that are associated with the VM cluster.", - }, - "scan_ip_ids": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.ListOfStringType, - ElementType: types.StringType, - Description: "The OCID of the SCAN IP addresses that are associated with the VM cluster.", - }, - "shape": schema.StringAttribute{ - Computed: true, - Description: "The hardware model name of the Exadata infrastructure that's running the VM cluster.", - }, - "ssh_public_keys": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.ListOfStringType, - ElementType: types.StringType, - Description: "he public key portion of one or more key pairs used for SSH access to the VM cluster.", - }, - "status": schema.StringAttribute{ - CustomType: statusType, - Computed: true, - Description: "The status of the VM cluster.", - }, - "status_reason": schema.StringAttribute{ - Computed: true, - Description: "Additional information about the status of the VM cluster.", - }, - "storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The amount of local node storage, in gigabytes (GB), that's allocated to the VM cluster.", - }, - "system_version": schema.StringAttribute{ - Computed: true, - Description: "The operating system version of the image chosen for the VM cluster.", - }, - "timezone": schema.StringAttribute{ - Computed: true, - Description: "The time zone of the VM cluster.", - }, - "vip_ids": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.ListOfStringType, - ElementType: types.StringType, - Description: "The virtual IP (VIP) addresses that are associated with the VM cluster.\n" + - "Oracle's Cluster Ready Services (CRS) creates and maintains one VIP address for\n" + - "each node in the VM cluster to enable failover. If one node fails, the VIP is\n" + - "reassigned to another active node in the cluster.", - }, - "created_at": schema.StringAttribute{ - Computed: true, - Description: "The time when the VM cluster was created.", - }, - "compute_model": schema.StringAttribute{ - CustomType: computeModelType, - Computed: true, - Description: "The OCI model compute model used when you create or clone an instance: ECPU or\n" + - "OCPU. An ECPU is an abstracted measure of compute resources. ECPUs are based on\n" + - "the number of cores elastically allocated from a pool of compute and storage\n" + - "servers. An OCPU is a legacy physical measure of compute resources. OCPUs are\n" + - "based on the physical core of a processor with hyper-threading enabled.", - }, - }, - Blocks: map[string]schema.Block{ - "data_collection_options": schema.ListNestedBlock{ - Description: "The set of diagnostic collection options enabled for the VM cluster.", - CustomType: fwtypes.NewListNestedObjectTypeOf[dataCollectionOptions](ctx), - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "is_diagnostics_events_enabled": schema.BoolAttribute{ - Computed: true, - }, - "is_health_monitoring_enabled": schema.BoolAttribute{ - Computed: true, - }, - "is_incident_logs_enabled": schema.BoolAttribute{ - Computed: true, - }, - }, - }, - }, - "iorm_config_cache": schema.ListNestedBlock{ - Description: "The ExadataIormConfig cache details for the VM cluster.", - CustomType: fwtypes.NewListNestedObjectTypeOf[exadataIormConfig](ctx), - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "lifecycle_details": schema.StringAttribute{ - Computed: true, - }, - "lifecycle_state": schema.StringAttribute{ - CustomType: fwtypes.StringEnumType[odbtypes.IormLifecycleState](), - Computed: true, - }, - "objective": schema.StringAttribute{ - CustomType: fwtypes.StringEnumType[odbtypes.Objective](), - Computed: true, - }, - }, - Blocks: map[string]schema.Block{ - "db_plans": schema.ListNestedBlock{ - CustomType: fwtypes.NewListNestedObjectTypeOf[dbIormConfig](ctx), - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "db_name": schema.StringAttribute{ - Computed: true, - }, - "flash_cache_limit": schema.StringAttribute{ - Computed: true, - }, - "share": schema.Int32Attribute{ - Computed: true, - }, - }, - }, - }, - }, - }, - }, - }, - } -} - -// Data sources only have a read method. -func (d *dataSourceCloudVmCluster) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - - var data dataSourceCloudVmClusterModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.GetCloudVmClusterInput{ - CloudVmClusterId: data.CloudVmClusterId.ValueStringPointer(), - } - - out, err := conn.GetCloudVmCluster(ctx, &input) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameCloudVmCluster, data.CloudVmClusterId.ValueString(), err), - err.Error(), - ) - return - } - - data.HostnamePrefixComputed = types.StringValue(*out.CloudVmCluster.Hostname) - data.CreatedAt = types.StringValue(time.Time{}.Format(time.RFC3339)) - - resp.Diagnostics.Append(flex.Flatten(ctx, out.CloudVmCluster, &data, flex.WithIgnoredFieldNamesAppend("HostnamePrefixComputed"), - flex.WithIgnoredFieldNamesAppend("CreatedAt"))...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type dataSourceCloudVmClusterModel struct { - framework.WithRegionModel - CloudExadataInfrastructureId types.String `tfsdk:"cloud_exadata_infrastructure_id"` - CloudVmClusterArn types.String `tfsdk:"arn"` - CloudVmClusterId types.String `tfsdk:"id"` - ClusterName types.String `tfsdk:"cluster_name"` - CpuCoreCount types.Int32 `tfsdk:"cpu_core_count"` - DataCollectionOptions fwtypes.ListNestedObjectValueOf[dataCollectionOptions] `tfsdk:"data_collection_options"` - DataStorageSizeInTBs types.Float64 `tfsdk:"data_storage_size_in_tbs"` - DbNodeStorageSizeInGBs types.Int32 `tfsdk:"db_node_storage_size_in_gbs"` - DbServers fwtypes.ListValueOf[types.String] `tfsdk:"db_servers"` - DiskRedundancy fwtypes.StringEnum[odbtypes.DiskRedundancy] `tfsdk:"disk_redundancy"` - DisplayName types.String `tfsdk:"display_name"` - Domain types.String `tfsdk:"domain"` - GiVersion types.String `tfsdk:"gi_version"` - HostnamePrefixComputed types.String `tfsdk:"hostname_prefix_computed"` - IormConfigCache fwtypes.ListNestedObjectValueOf[exadataIormConfig] `tfsdk:"iorm_config_cache"` - IsLocalBackupEnabled types.Bool `tfsdk:"is_local_backup_enabled"` - IsSparseDiskGroupEnabled types.Bool `tfsdk:"is_sparse_disk_group_enabled"` - LastUpdateHistoryEntryId types.String `tfsdk:"last_update_history_entry_id"` - LicenseModel fwtypes.StringEnum[odbtypes.LicenseModel] `tfsdk:"license_model"` - ListenerPort types.Int32 `tfsdk:"listener_port"` - MemorySizeInGbs types.Int32 `tfsdk:"memory_size_in_gbs"` - NodeCount types.Int32 `tfsdk:"node_count"` - Ocid types.String `tfsdk:"ocid"` - OciResourceAnchorName types.String `tfsdk:"oci_resource_anchor_name"` - OciUrl types.String `tfsdk:"oci_url"` - OdbNetworkId types.String `tfsdk:"odb_network_id"` - PercentProgress types.Float64 `tfsdk:"percent_progress"` - ScanDnsName types.String `tfsdk:"scan_dns_name"` - ScanDnsRecordId types.String `tfsdk:"scan_dns_record_id"` - ScanIpIds fwtypes.ListValueOf[types.String] `tfsdk:"scan_ip_ids"` - Shape types.String `tfsdk:"shape"` - SshPublicKeys fwtypes.ListValueOf[types.String] `tfsdk:"ssh_public_keys"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - StorageSizeInGBs types.Int32 `tfsdk:"storage_size_in_gbs"` - SystemVersion types.String `tfsdk:"system_version"` - Timezone types.String `tfsdk:"timezone"` - VipIds fwtypes.ListValueOf[types.String] `tfsdk:"vip_ids"` - CreatedAt types.String `tfsdk:"created_at"` - ComputeModel fwtypes.StringEnum[odbtypes.ComputeModel] `tfsdk:"compute_model"` -} - -type dataCollectionOptions struct { - IsDiagnosticsEventsEnabled types.Bool `tfsdk:"is_diagnostics_events_enabled"` - IsHealthMonitoringEnabled types.Bool `tfsdk:"is_health_monitoring_enabled"` - IsIncidentLogsEnabled types.Bool `tfsdk:"is_incident_logs_enabled"` -} - -type exadataIormConfig struct { - DbPlans fwtypes.ListNestedObjectValueOf[dbIormConfig] `tfsdk:"db_plans"` - LifecycleDetails types.String `tfsdk:"lifecycle_details"` - LifecycleState fwtypes.StringEnum[odbtypes.IormLifecycleState] `tfsdk:"lifecycle_state"` - Objective fwtypes.StringEnum[odbtypes.Objective] `tfsdk:"objective"` -} - -type dbIormConfig struct { - DbName types.String `tfsdk:"db_name"` - FlashCacheLimit types.String `tfsdk:"flash_cache_limit"` - Share types.Int32 `tfsdk:"share"` -} diff --git a/internal/service/odb/cloud_vm_cluster_data_source_test.go b/internal/service/odb/cloud_vm_cluster_data_source_test.go deleted file mode 100644 index c7e688523d98..000000000000 --- a/internal/service/odb/cloud_vm_cluster_data_source_test.go +++ /dev/null @@ -1,165 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "github.com/hashicorp/terraform-provider-aws/names" - "testing" -) - -import ( - "github.com/hashicorp/terraform-plugin-testing/helper/resource" -) - -type cloudVmClusterDSTest struct { - vmClusterDisplayNamePrefix string - exaInfraDisplayNamePrefix string - odbNetDisplayNamePrefix string -} - -var vmClusterTestDS = cloudVmClusterDSTest{ - vmClusterDisplayNamePrefix: "Ofake-vmc", - exaInfraDisplayNamePrefix: "Ofake-exa-infra", - odbNetDisplayNamePrefix: "odb-net", -} - -func TestAccODBCloudVmClusterDataSource_basic(t *testing.T) { - ctx := acctest.Context(t) - - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudvmcluster odbtypes.CloudVmCluster - vmcDisplayName := sdkacctest.RandomWithPrefix(vmClusterTestDS.vmClusterDisplayNamePrefix) - dataSourceName := "data.aws_odb_cloud_vm_cluster.test" - publicKey, _, err := sdkacctest.RandSSHKeyPair(acctest.DefaultEmailAddress) - if err != nil { - t.Fatal(err) - return - } - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - // testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: vmClusterTestDS.testAccCheckCloudVmClusterDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: vmClusterTestDS.cloudVmClusterWithHardcoded("odbnet_c91byo6y6m", "exa_ji5quxxzn9", vmcDisplayName, publicKey), - Check: resource.ComposeAggregateTestCheckFunc( - vmClusterTestDS.testAccCheckCloudVmClusterExists(ctx, dataSourceName, &cloudvmcluster), - resource.TestCheckResourceAttr(dataSourceName, "display_name", vmcDisplayName), - ), - }, - }, - }) -} - -func (cloudVmClusterDSTest) testAccCheckCloudVmClusterDestroy(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_cloud_vm_cluster" { - continue - } - - _, err := tfodb.FindCloudVmClusterForResourceByID(ctx, conn, rs.Primary.ID) - if tfresource.NotFound(err) { - return nil - } - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudVmCluster, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudVmCluster, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} - -func (cloudVmClusterDSTest) testAccCheckCloudVmClusterExists(ctx context.Context, name string, cloudvmcluster *odbtypes.CloudVmCluster) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, name, errors.New("not found")) - } - - if rs.Primary.ID == "" { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, name, errors.New("not set")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - resp, err := tfodb.FindCloudVmClusterForResourceByID(ctx, conn, rs.Primary.ID) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, rs.Primary.ID, err) - } - - *cloudvmcluster = *resp - - return nil - } -} - -func (cloudVmClusterDSTest) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListCloudVmClustersInput{} - - _, err := conn.ListCloudVmClusters(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} - -func (cloudVmClusterDSTest) cloudVmClusterWithHardcoded(odbNet, exaInfra, displayName, sshKey string) string { - dsTfCodeVmCluster := fmt.Sprintf(` -resource "aws_odb_cloud_vm_cluster" "test" { - odb_network_id = %[1]q - cloud_exadata_infrastructure_id = %[2]q - display_name = %[3]q - ssh_public_keys = [%[4]q] - cpu_core_count = 6 - gi_version = "23.0.0.0" - hostname_prefix = "apollo12" - is_local_backup_enabled = true - is_sparse_diskgroup_enabled = true - license_model = "LICENSE_INCLUDED" - data_storage_size_in_tbs = 20.0 - db_servers = [ "dbs_7ecm4wbjxy","dbs_uy5wmaqk6s"] - db_node_storage_size_in_gbs = 120.0 - memory_size_in_gbs = 60 - tags = { - "env"= "dev" - } - -} - -data "aws_odb_cloud_vm_cluster" "test" { - id = aws_odb_cloud_vm_cluster.test.id -} -`, odbNet, exaInfra, displayName, sshKey) - //fmt.Println(dsTfCodeVmCluster) - return dsTfCodeVmCluster -} diff --git a/internal/service/odb/cloud_vm_cluster_test.go b/internal/service/odb/cloud_vm_cluster_test.go deleted file mode 100644 index 98de316a7e2d..000000000000 --- a/internal/service/odb/cloud_vm_cluster_test.go +++ /dev/null @@ -1,565 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "github.com/aws/aws-sdk-go-v2/service/odb" - "strings" - - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "github.com/hashicorp/terraform-provider-aws/names" - "testing" -) - -type cloudVmClusterResourceTest struct { - vmClusterDisplayNamePrefix string - exaInfraDisplayNamePrefix string - odbNetDisplayNamePrefix string -} - -var vmClusterTestResource = cloudVmClusterResourceTest{ - vmClusterDisplayNamePrefix: "Ofake-vmc", - exaInfraDisplayNamePrefix: "Ofake-exa-infra", - odbNetDisplayNamePrefix: "odb-net", -} - -func TestPrintCloudVmClusterUnitTest(t *testing.T) { - vmcRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.vmClusterDisplayNamePrefix) - exaInfraRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.exaInfraDisplayNamePrefix) - odbNetRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.odbNetDisplayNamePrefix) - - publicKey, _, err := sdkacctest.RandSSHKeyPair(acctest.DefaultEmailAddress) - if err != nil { - t.Fatal(err) - return - } - fmt.Println(vmClusterTestResource.testAccCloudVmClusterConfigBasic(vmClusterTestResource.exaInfra(exaInfraRName), vmClusterTestResource.odbNetwork(odbNetRName), vmcRName, publicKey)) -} - -func TestAccODBCloudVmCluster_basic(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudvmcluster odbtypes.CloudVmCluster - vmcRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.vmClusterDisplayNamePrefix) - exaInfraRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.exaInfraDisplayNamePrefix) - odbNetRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.odbNetDisplayNamePrefix) - - publicKey, _, err := sdkacctest.RandSSHKeyPair(acctest.DefaultEmailAddress) - if err != nil { - t.Fatal(err) - return - } - resourceName := "aws_odb_cloud_vm_cluster.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //acctest.PreCheckPartitionHasService(t, names.ODBEndpointID) - vmClusterTestResource.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: vmClusterTestResource.testAccCheckCloudVmClusterDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: vmClusterTestResource.testAccCloudVmClusterConfigBasic(vmClusterTestResource.exaInfra(exaInfraRName), vmClusterTestResource.odbNetwork(odbNetRName), vmcRName, publicKey), - Check: resource.ComposeAggregateTestCheckFunc( - vmClusterTestResource.testAccCheckCloudVmClusterExists(ctx, resourceName, &cloudvmcluster), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBCloudVmClusterCreationWithAllParams(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudvmcluster odbtypes.CloudVmCluster - vmcRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.vmClusterDisplayNamePrefix) - exaInfraRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.exaInfraDisplayNamePrefix) - odbNetRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.odbNetDisplayNamePrefix) - - publicKey, _, err := sdkacctest.RandSSHKeyPair(acctest.DefaultEmailAddress) - if err != nil { - t.Fatal(err) - return - } - resourceName := "aws_odb_cloud_vm_cluster.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //acctest.PreCheckPartitionHasService(t, names.ODBEndpointID) - vmClusterTestResource.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: vmClusterTestResource.testAccCheckCloudVmClusterDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: vmClusterTestResource.cloudVmClusterWithAllParameters(vmClusterTestResource.exaInfra(exaInfraRName), vmClusterTestResource.odbNetwork(odbNetRName), vmcRName, publicKey), - Check: resource.ComposeAggregateTestCheckFunc( - vmClusterTestResource.testAccCheckCloudVmClusterExists(ctx, resourceName, &cloudvmcluster), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBCloudVmClusterAddRemoveTags(t *testing.T) { - ctx := acctest.Context(t) - // TIP: This is a long-running test guard for tests that run longer than - // 300s (5 min) generally. - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudvmcluster1 odbtypes.CloudVmCluster - var cloudvmcluster2 odbtypes.CloudVmCluster - var cloudvmcluster3 odbtypes.CloudVmCluster - rName := sdkacctest.RandomWithPrefix(vmClusterTestResource.vmClusterDisplayNamePrefix) - exaInfraRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.exaInfraDisplayNamePrefix) - odbNetRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.odbNetDisplayNamePrefix) - resourceName := "aws_odb_cloud_vm_cluster.test" - - publicKey, _, err := sdkacctest.RandSSHKeyPair(acctest.DefaultEmailAddress) - if err != nil { - t.Fatal(err) - return - } - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //acctest.PreCheckPartitionHasService(t, names.ODBEndpointID) - vmClusterTestResource.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: vmClusterTestResource.testAccCheckCloudVmClusterDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: vmClusterTestResource.testAccCloudVmClusterConfigBasic(vmClusterTestResource.exaInfra(exaInfraRName), vmClusterTestResource.odbNetwork(odbNetRName), rName, publicKey), - Check: resource.ComposeAggregateTestCheckFunc( - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - return nil - }), - vmClusterTestResource.testAccCheckCloudVmClusterExists(ctx, resourceName, &cloudvmcluster1), - resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), - resource.TestCheckResourceAttr(resourceName, "tags.env", "dev"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - { - Config: vmClusterTestResource.testAccCloudVmClusterConfigUpdatedTags(vmClusterTestResource.exaInfra(exaInfraRName), vmClusterTestResource.odbNetwork(odbNetRName), rName, publicKey), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), - resource.TestCheckResourceAttr(resourceName, "tags.env", "dev"), - resource.TestCheckResourceAttr(resourceName, "tags.foo", "bar"), - vmClusterTestResource.testAccCheckCloudVmClusterExists(ctx, resourceName, &cloudvmcluster2), - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - if strings.Compare(*(cloudvmcluster1.CloudVmClusterId), *(cloudvmcluster2.CloudVmClusterId)) != 0 { - return errors.New("Should not create a new cloud vm cluster for tag update") - } - return nil - }), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - { - Config: vmClusterTestResource.testAccCloudVmClusterConfigBasic(vmClusterTestResource.exaInfra(exaInfraRName), vmClusterTestResource.odbNetwork(odbNetRName), rName, publicKey), - Check: resource.ComposeAggregateTestCheckFunc( - vmClusterTestResource.testAccCheckCloudVmClusterExists(ctx, resourceName, &cloudvmcluster3), - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - if strings.Compare(*(cloudvmcluster1.CloudVmClusterId), *(cloudvmcluster3.CloudVmClusterId)) != 0 { - return errors.New("Should not create a new cloud vm cluster for tag update") - } - return nil - }), - - resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), - resource.TestCheckResourceAttr(resourceName, "tags.env", "dev"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBCloudVmCluster_recreates_new(t *testing.T) { - ctx := acctest.Context(t) - // TIP: This is a long-running test guard for tests that run longer than - // 300s (5 min) generally. - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudvmcluster1 odbtypes.CloudVmCluster - var cloudvmcluster2 odbtypes.CloudVmCluster - rName := sdkacctest.RandomWithPrefix(vmClusterTestResource.vmClusterDisplayNamePrefix) - exaInfraRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.exaInfraDisplayNamePrefix) - odbNetRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.odbNetDisplayNamePrefix) - - resourceName := "aws_odb_cloud_vm_cluster.test" - publicKey, _, err := sdkacctest.RandSSHKeyPair(acctest.DefaultEmailAddress) - if err != nil { - t.Fatal(err) - return - } - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //acctest.PreCheckPartitionHasService(t, names.ODBEndpointID) - vmClusterTestResource.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: vmClusterTestResource.testAccCheckCloudVmClusterDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: vmClusterTestResource.testAccCloudVmClusterConfigBasic(vmClusterTestResource.exaInfra(exaInfraRName), vmClusterTestResource.odbNetwork(odbNetRName), rName, publicKey), - Check: resource.ComposeAggregateTestCheckFunc( - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - //fmt.Println(state) - return nil - }), - vmClusterTestResource.testAccCheckCloudVmClusterExists(ctx, resourceName, &cloudvmcluster1), - resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), - resource.TestCheckResourceAttr(resourceName, "tags.env", "dev"), - ), - }, - { - Config: vmClusterTestResource.testAccCloudVmClusterConfigUpdatedTags(vmClusterTestResource.exaInfra(exaInfraRName+"_u"), vmClusterTestResource.odbNetwork(odbNetRName), rName, publicKey), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), - resource.TestCheckResourceAttr(resourceName, "tags.env", "dev"), - resource.TestCheckResourceAttr(resourceName, "tags.foo", "bar"), - vmClusterTestResource.testAccCheckCloudVmClusterExists(ctx, resourceName, &cloudvmcluster2), - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - //fmt.Println(state) - if strings.Compare(*(cloudvmcluster1.CloudVmClusterId), *(cloudvmcluster2.CloudVmClusterId)) == 0 { - return errors.New("Should create a new cloud vm cluster for tag update") - } - return nil - }), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBCloudVmCluster_disappears(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var cloudvmcluster odbtypes.CloudVmCluster - rName := sdkacctest.RandomWithPrefix(vmClusterTestResource.vmClusterDisplayNamePrefix) - exaInfraRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.exaInfraDisplayNamePrefix) - odbNetRName := sdkacctest.RandomWithPrefix(vmClusterTestResource.odbNetDisplayNamePrefix) - - resourceName := "aws_odb_cloud_vm_cluster.test" - publicKey, _, err := sdkacctest.RandSSHKeyPair(acctest.DefaultEmailAddress) - if err != nil { - t.Fatal(err) - return - } - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //acctest.PreCheckPartitionHasService(t, names.ODBEndpointID) - vmClusterTestResource.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: vmClusterTestResource.testAccCheckCloudVmClusterDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: vmClusterTestResource.testAccCloudVmClusterConfigBasic(vmClusterTestResource.exaInfra(exaInfraRName), vmClusterTestResource.odbNetwork(odbNetRName), rName, publicKey), - Check: resource.ComposeAggregateTestCheckFunc( - vmClusterTestResource.testAccCheckCloudVmClusterExists(ctx, resourceName, &cloudvmcluster), - acctest.CheckFrameworkResourceDisappears(ctx, acctest.Provider, tfodb.ResourceCloudVmCluster, resourceName), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func (cloudVmClusterResourceTest) testAccCheckCloudVmClusterDestroy(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_cloud_vm_cluster" { - continue - } - - _, err := tfodb.FindCloudVmClusterForResourceByID(ctx, conn, rs.Primary.ID) - if tfresource.NotFound(err) { - return nil - } - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudVmCluster, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudVmCluster, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} - -func (cloudVmClusterResourceTest) testAccCheckCloudVmClusterExists(ctx context.Context, name string, cloudvmcluster *odbtypes.CloudVmCluster) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, name, errors.New("not found")) - } - - if rs.Primary.ID == "" { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, name, errors.New("not set")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - resp, err := tfodb.FindCloudVmClusterForResourceByID(ctx, conn, rs.Primary.ID) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, rs.Primary.ID, err) - } - - *cloudvmcluster = *resp - - return nil - } -} - -func (cloudVmClusterResourceTest) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListCloudVmClustersInput{} - - _, err := conn.ListCloudVmClusters(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} - -/*func testAccCheckCloudVmClusterNotRecreated(before, after *odb.DescribeCloudVmClusterResponse) resource.TestCheckFunc { - return func(s *terraform.State) error { - if before, after := aws.ToString(before.CloudVmClusterId), aws.ToString(after.CloudVmClusterId); before != after { - return create.Error(names.ODB, create.ErrActionCheckingNotRecreated, tfodb.ResNameCloudVmCluster, aws.ToString(before.CloudVmClusterId), errors.New("recreated")) - } - - return nil - } -}*/ - -func (cloudVmClusterResourceTest) testAccCloudVmClusterConfigBasic(exaInfra, odbNet, rName, sshKey string) string { - - res := fmt.Sprintf(` -%s - -%s - -data "aws_odb_db_servers_list" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id -} - -resource "aws_odb_cloud_vm_cluster" "test" { - display_name = %[3]q - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id - cpu_core_count = 6 - gi_version = "23.0.0.0" - hostname_prefix = "apollo12" - ssh_public_keys = [%[4]q] - odb_network_id = aws_odb_network.test.id - is_local_backup_enabled = true - is_sparse_diskgroup_enabled = true - license_model = "LICENSE_INCLUDED" - data_storage_size_in_tbs = 20.0 - db_servers = [ for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id] - db_node_storage_size_in_gbs = 120.0 - memory_size_in_gbs = 60 - tags = { - "env"= "dev" - } - -} -`, exaInfra, odbNet, rName, sshKey) - return res -} - -func (cloudVmClusterResourceTest) testAccCloudVmClusterConfigUpdatedTags(exaInfra, odbNet, rName, sshKey string) string { - - res := fmt.Sprintf(` -%s - -%s - -data "aws_odb_db_servers_list" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id -} - -resource "aws_odb_cloud_vm_cluster" "test" { - display_name = %[3]q - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id - cpu_core_count = 6 - gi_version = "23.0.0.0" - hostname_prefix = "apollo12" - ssh_public_keys = [%[4]q] - odb_network_id = aws_odb_network.test.id - is_local_backup_enabled = true - is_sparse_diskgroup_enabled = true - license_model = "LICENSE_INCLUDED" - data_storage_size_in_tbs = 20.0 - db_servers = [ for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id] - db_node_storage_size_in_gbs = 120.0 - memory_size_in_gbs = 60 - tags = { - "env"= "dev" - "foo"= "bar" - } - -} -`, exaInfra, odbNet, rName, sshKey) - return res -} - -func (cloudVmClusterResourceTest) exaInfra(rName string) string { - resource := fmt.Sprintf(` -resource "aws_odb_cloud_exadata_infrastructure" "test" { - display_name = "%[1]s" - shape = "Exadata.X9M" - storage_count = 3 - compute_count = 2 - availability_zone_id = "use1-az6" - customer_contacts_to_send_to_oci = ["abc@example.com"] - maintenance_window = { - custom_action_timeout_in_mins = 16 - days_of_week = [] - hours_of_day = [] - is_custom_action_timeout_enabled = true - lead_time_in_weeks = 0 - months = [] - patching_mode = "ROLLING" - preference = "NO_PREFERENCE" - weeks_of_month =[] - } - -} -`, rName) - //fmt.Println(resource) - return resource -} - -func (cloudVmClusterResourceTest) odbNetwork(rName string) string { - resource := fmt.Sprintf(` -resource "aws_odb_network" "test" { - display_name = %[1]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" -} -`, rName) - //fmt.Println(resource) - return resource -} - -func (cloudVmClusterResourceTest) cloudVmClusterWithAllParameters(exaInfra, odbNet, rName, sshKey string) string { - - res := fmt.Sprintf(` - -%s - -%s - - -data "aws_odb_db_servers_list" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id -} - -resource "aws_odb_cloud_vm_cluster" "test" { - display_name = %[3]q - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id - cpu_core_count = 6 - gi_version = "23.0.0.0" - hostname_prefix = "apollo12" - ssh_public_keys = [%[4]q] - odb_network_id = aws_odb_network.test.id - is_local_backup_enabled = true - is_sparse_diskgroup_enabled = true - license_model = "LICENSE_INCLUDED" - data_storage_size_in_tbs = 20.0 - db_servers = [ for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id] - db_node_storage_size_in_gbs = 120.0 - memory_size_in_gbs = 60 - cluster_name = "julia-13" - timezone = "UTC" - scan_listener_port_tcp = 1521 - system_version = "23.1.26.0.0.250516" - tags = { - "env"= "dev" - } - data_collection_options ={ - is_diagnostics_events_enabled = true - is_health_monitoring_enabled = true - is_incident_logs_enabled = true - } -} -`, exaInfra, odbNet, rName, sshKey) - return res -} diff --git a/internal/service/odb/cloud_vm_clusters_list_data_source.go b/internal/service/odb/cloud_vm_clusters_list_data_source.go deleted file mode 100644 index 1bf76740aec1..000000000000 --- a/internal/service/odb/cloud_vm_clusters_list_data_source.go +++ /dev/null @@ -1,95 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "github.com/hashicorp/terraform-plugin-framework/attr" - - "github.com/aws/aws-sdk-go-v2/service/odb" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_cloud_vm_clusters_list", name="Cloud Vm Clusters List") -func newDataSourceCloudVmClustersList(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceCloudVmClustersList{}, nil -} - -const ( - DSNameCloudVmClustersList = "Cloud Vm Clusters List Data Source" -) - -type dataSourceCloudVmClustersList struct { - framework.DataSourceWithModel[dataSourceCloudVmClustersListModel] -} - -func (d *dataSourceCloudVmClustersList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "cloud_vm_clusters": schema.ListAttribute{ - Computed: true, - Description: "List of Cloud VM Clusters (OCID, ID, ARN, OCI URL, Display Name)", - CustomType: fwtypes.NewListNestedObjectTypeOf[cloudAutonomousVmClusterSummary](ctx), - ElementType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "arn": types.StringType, - "id": types.StringType, - "oci_url": types.StringType, - "ocid": types.StringType, - "display_name": types.StringType, - }, - }, - }, - }, - } -} - -// Data sources only have a read method. -func (d *dataSourceCloudVmClustersList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - - var data dataSourceCloudVmClustersListModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := conn.ListCloudVmClusters(ctx, &odb.ListCloudVmClustersInput{}) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameCloudVmClustersList, "", err), - err.Error(), - ) - return - } - - resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type dataSourceCloudVmClustersListModel struct { - framework.WithRegionModel - CloudVmClusters fwtypes.ListNestedObjectValueOf[cloudVmClusterSummary] `tfsdk:"cloud_vm_clusters"` -} - -type cloudVmClusterSummary struct { - CloudExadataInfrastructureArn types.String `tfsdk:"arn"` - CloudAutonomousVmClusterId types.String `tfsdk:"id"` - OciUrl types.String `tfsdk:"oci_url"` - Ocid types.String `tfsdk:"ocid"` - DisplayName types.String `tfsdk:"display_name"` -} diff --git a/internal/service/odb/cloud_vm_clusters_list_data_source_test.go b/internal/service/odb/cloud_vm_clusters_list_data_source_test.go deleted file mode 100644 index c06772c2db74..000000000000 --- a/internal/service/odb/cloud_vm_clusters_list_data_source_test.go +++ /dev/null @@ -1,101 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "strconv" - - "testing" - - "github.com/aws/aws-sdk-go-v2/service/odb" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/names" -) - -type listVMCListDSTest struct { -} - -func TestAccListVmClusterDataSource(t *testing.T) { - ctx := acctest.Context(t) - var vmcListTest = listVMCListDSTest{} - var output odb.ListCloudVmClustersOutput - - dataSourceName := "data.aws_odb_cloud_vm_clusters_list.test" - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - vmcListTest.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - Steps: []resource.TestStep{ - { - Config: vmcListTest.basic(), - Check: resource.ComposeAggregateTestCheckFunc( - - resource.ComposeTestCheckFunc(func(s *terraform.State) error { - vmcListTest.count(ctx, dataSourceName, &output) - resource.TestCheckResourceAttr(dataSourceName, "cloud_autonomous_vm_clusters.#", strconv.Itoa(len(output.CloudVmClusters))) - return nil - }, - ), - ), - }, - }, - }) -} - -func (listVMCListDSTest) basic() string { - config := fmt.Sprintf(` - - -data "aws_odb_cloud_vm_clusters_list" "test" { - -} -`) - return config -} - -func (listVMCListDSTest) count(ctx context.Context, name string, list *odb.ListCloudVmClustersOutput) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, name, errors.New("not found")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - resp, err := conn.ListCloudVmClusters(ctx, &odb.ListCloudVmClustersInput{}) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, rs.Primary.ID, err) - } - - list.CloudVmClusters = resp.CloudVmClusters - - return nil - } -} -func (listVMCListDSTest) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListCloudVmClustersInput{} - - _, err := conn.ListCloudVmClusters(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} diff --git a/internal/service/odb/db_server_data_source.go b/internal/service/odb/db_server_data_source.go deleted file mode 100644 index 77adc1626e1d..000000000000 --- a/internal/service/odb/db_server_data_source.go +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package odb - -import ( - "context" - "github.com/hashicorp/terraform-plugin-framework/attr" - "time" - - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_db_server", name="Db Server") -func newDataSourceDbServer(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceDbServer{}, nil -} - -const ( - DSNameDbServer = "Db Server Data Source" -) - -type dataSourceDbServer struct { - framework.DataSourceWithModel[dbServerDataSourceModel] -} - -func (d *dataSourceDbServer) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - names.AttrID: schema.StringAttribute{ - Description: "The identifier of the the database server.", - Required: true, - }, - "cloud_exadata_infrastructure_id": schema.StringAttribute{ - Description: "The identifier of the database server to retrieve information about.", - Required: true, - }, - "status": schema.StringAttribute{ - CustomType: fwtypes.StringEnumType[odbtypes.ResourceStatus](), - Computed: true, - Description: "The status of the database server.", - }, - "status_reason": schema.StringAttribute{ - Computed: true, - Description: "Additional information about the current status of the database server.", - }, - "cpu_core_count": schema.Int32Attribute{ - Computed: true, - Description: "The number of CPU cores enabled on the database server.", - }, - "db_node_ids": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.ListOfStringType, - ElementType: types.StringType, - }, - "db_node_storage_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The allocated local node storage in GBs on the database server.", - }, - "db_server_patching_details": schema.ObjectAttribute{ - Description: "The scheduling details for the quarterly maintenance window. Patching and\n" + - "system updates take place during the maintenance window.", - Computed: true, - CustomType: fwtypes.NewObjectTypeOf[dbNodePatchingDetailsDbServerDataSourceModel](ctx), - AttributeTypes: map[string]attr.Type{ - "estimated_patch_duration": types.Int32Type, - "patching_status": types.StringType, - "time_patching_ended": types.StringType, - "time_patching_started": types.StringType, - }, - }, - "display_name": schema.StringAttribute{ - Computed: true, - Description: "The display name of the database server.", - }, - "exadata_infrastructure_id": schema.StringAttribute{ - Computed: true, - Description: "The exadata infrastructure ID of the database server.", - }, - "ocid": schema.StringAttribute{ - Computed: true, - Description: "The OCID of the database server to retrieve information about.", - }, - "oci_resource_anchor_name": schema.StringAttribute{ - Computed: true, - Description: "The name of the OCI resource anchor.", - }, - "max_cpu_count": schema.Int32Attribute{ - Computed: true, - Description: "The total number of CPU cores available.", - }, - "max_db_node_storage_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The total local node storage available in GBs.", - }, - "max_memory_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The total memory available in GBs.", - }, - "memory_size_in_gbs": schema.Int32Attribute{ - Computed: true, - Description: "The allocated memory in GBs on the database server.", - }, - "shape": schema.StringAttribute{ - Computed: true, - Description: "// The shape of the database server. The shape determines the amount of CPU,\n" + - "storage, and memory resources available.", - }, - "created_at": schema.StringAttribute{ - Computed: true, - Description: "The date and time when the database server was created.", - }, - "vm_cluster_ids": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.ListOfStringType, - ElementType: types.StringType, - Description: "The OCID of the VM clusters that are associated with the database server.", - }, - "compute_model": schema.StringAttribute{ - Computed: true, - CustomType: fwtypes.StringEnumType[odbtypes.ComputeModel](), - Description: " The compute model of the database server.", - }, - "autonomous_vm_cluster_ids": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.ListOfStringType, - ElementType: types.StringType, - Description: "The OCID of the autonomous VM clusters that are associated with the database server.", - }, - "autonomous_virtual_machine_ids": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.ListOfStringType, - ElementType: types.StringType, - Description: "The list of unique identifiers for the Autonomous VMs associated with this database server.", - }, - }, - } -} - -func (d *dataSourceDbServer) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - - var data dbServerDataSourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.GetDbServerInput{ - DbServerId: data.DbServerID.ValueStringPointer(), - CloudExadataInfrastructureId: data.CloudExadataInfrastructureID.ValueStringPointer(), - } - - out, err := conn.GetDbServer(ctx, &input) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameDbServer, data.DbServerID.ValueString(), err), - err.Error(), - ) - return - } - - if out.DbServer.CreatedAt != nil { - data.CreatedAt = types.StringValue(out.DbServer.CreatedAt.Format(time.RFC3339)) - } - - resp.Diagnostics.Append(flex.Flatten(ctx, out.DbServer, &data)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type dbServerDataSourceModel struct { - framework.WithRegionModel - DbServerID types.String `tfsdk:"id"` - CloudExadataInfrastructureID types.String `tfsdk:"cloud_exadata_infrastructure_id"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - CpuCoreCount types.Int32 `tfsdk:"cpu_core_count"` - DbNodeIds fwtypes.ListOfString `tfsdk:"db_node_ids"` - DbNodeStorageSizeInGBs types.Int32 `tfsdk:"db_node_storage_size_in_gbs"` - DbServerPatchingDetails fwtypes.ObjectValueOf[dbNodePatchingDetailsDbServerDataSourceModel] `tfsdk:"db_server_patching_details"` - DisplayName types.String `tfsdk:"display_name"` - ExadataInfrastructureId types.String `tfsdk:"exadata_infrastructure_id"` - OCID types.String `tfsdk:"ocid"` - OciResourceAnchorName types.String `tfsdk:"oci_resource_anchor_name"` - MaxCpuCount types.Int32 `tfsdk:"max_cpu_count"` - MaxDbNodeStorageInGBs types.Int32 `tfsdk:"max_db_node_storage_in_gbs"` - MaxMemoryInGBs types.Int32 `tfsdk:"max_memory_in_gbs"` - MemorySizeInGBs types.Int32 `tfsdk:"memory_size_in_gbs"` - Shape types.String `tfsdk:"shape"` - CreatedAt types.String `tfsdk:"created_at" autoflex:",noflatten"` - VmClusterIds fwtypes.ListOfString `tfsdk:"vm_cluster_ids"` - ComputeModel fwtypes.StringEnum[odbtypes.ComputeModel] `tfsdk:"compute_model"` - AutonomousVmClusterIds fwtypes.ListOfString `tfsdk:"autonomous_vm_cluster_ids"` - AutonomousVirtualMachineIds fwtypes.ListOfString `tfsdk:"autonomous_virtual_machine_ids"` -} - -type dbNodePatchingDetailsDbServerDataSourceModel struct { - EstimatedPatchDuration types.Int32 `tfsdk:"estimated_patch_duration"` - PatchingStatus types.String `tfsdk:"patching_status"` - TimePatchingEnded types.String `tfsdk:"time_patching_ended"` - TimePatchingStarted types.String `tfsdk:"time_patching_started"` -} diff --git a/internal/service/odb/db_server_data_source_test.go b/internal/service/odb/db_server_data_source_test.go deleted file mode 100644 index 3eee595e9544..000000000000 --- a/internal/service/odb/db_server_data_source_test.go +++ /dev/null @@ -1,196 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "github.com/aws/aws-sdk-go-v2/aws" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "testing" - - "github.com/aws/aws-sdk-go-v2/service/odb" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/names" -) - -type testDbServerDataSourceTest struct { - exaDisplayNamePrefix string -} - -var dbServerDataSourceTestEntity = testDbServerDataSourceTest{ - exaDisplayNamePrefix: "Ofake-exa", -} - -// Acceptance test access AWS and cost money to run. -func TestAccODBDbServerDataSource(t *testing.T) { - ctx := acctest.Context(t) - - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var dbServer odb.GetDbServerOutput - exaInfraDisplayName := sdkacctest.RandomWithPrefix(dbServersListDataSourceTests.displayNamePrefix) - - dataSourceName := "data.aws_odb_db_server.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: dbServerDataSourceTestEntity.testAccCheckDbServersDestroyed(ctx), - Steps: []resource.TestStep{ - { - Config: dbServerDataSourceTestEntity.basic(dbServerDataSourceTestEntity.exaInfra(exaInfraDisplayName)), - Check: resource.ComposeAggregateTestCheckFunc( - dbServerDataSourceTestEntity.testAccCheckDbServerExists(ctx, dataSourceName, &dbServer), - ), - }, - }, - }) -} - -func (testDbServerDataSourceTest) testAccCheckDbServerExists(ctx context.Context, name string, output *odb.GetDbServerOutput) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.DSNameDbServer, name, errors.New("not found")) - } - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - var dbServerId = rs.Primary.ID - var attributes = rs.Primary.Attributes - exaId := attributes["exadata_infrastructure_id"] - resp, err := dbServerDataSourceTestEntity.findDbServer(ctx, conn, &dbServerId, &exaId) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.DSNameDbServer, rs.Primary.ID, err) - } - *output = *resp - return nil - } -} - -func (testDbServerDataSourceTest) testAccCheckDbServersDestroyed(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_cloud_exadata_infrastructure" { - continue - } - - _, err := dbServerDataSourceTestEntity.findExaInfra(ctx, conn, rs.Primary.ID) - - if tfresource.NotFound(err) { - return nil - } - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.DSNameDbServer, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.DSNameDbServer, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} - -func (testDbServerDataSourceTest) findExaInfra(ctx context.Context, conn *odb.Client, id string) (*odbtypes.CloudExadataInfrastructure, error) { - input := odb.GetCloudExadataInfrastructureInput{ - CloudExadataInfrastructureId: aws.String(id), - } - - out, err := conn.GetCloudExadataInfrastructure(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - - return nil, err - } - - if out == nil || out.CloudExadataInfrastructure == nil { - return nil, tfresource.NewEmptyResultError(&input) - } - - return out.CloudExadataInfrastructure, nil -} - -func (testDbServerDataSourceTest) findDbServer(ctx context.Context, conn *odb.Client, dbServerId *string, exaInfraId *string) (*odb.GetDbServerOutput, error) { - inputWithExaId := &odb.GetDbServerInput{ - DbServerId: dbServerId, - CloudExadataInfrastructureId: exaInfraId, - } - output, err := conn.GetDbServer(ctx, inputWithExaId) - if err != nil { - return nil, err - } - return output, nil -} - -func (testDbServerDataSourceTest) basic(exaInfra string) string { - return fmt.Sprintf(` -%s - -data "aws_odb_db_servers_list" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id -} - -data "aws_odb_db_server" "test" { - id = data.aws_odb_db_servers_list.test.db_servers[0].id - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id -} -`, exaInfra) -} - -func (testDbServerDataSourceTest) exaInfra(rName string) string { - exaRes := fmt.Sprintf(` -resource "aws_odb_cloud_exadata_infrastructure" "test" { - display_name = "%[1]s" - shape = "Exadata.X9M" - storage_count = 3 - compute_count = 2 - availability_zone_id = "use1-az6" - customer_contacts_to_send_to_oci = ["abc@example.com"] - maintenance_window = { - custom_action_timeout_in_mins = 16 - days_of_week = [] - hours_of_day = [] - is_custom_action_timeout_enabled = true - lead_time_in_weeks = 0 - months = [] - patching_mode = "ROLLING" - preference = "NO_PREFERENCE" - weeks_of_month =[] - } -} -`, rName) - return exaRes -} - -/*func (testDbServerDataSourceTest) foo(dbServerId, exaInfraId string) string { - return fmt.Sprintf(` - -data "aws_odb_db_server" "test" { - id = %[1]q -cloud_exadata_infrastructure_id = %[2]q -} -`, dbServerId, exaInfraId) -} -*/ diff --git a/internal/service/odb/db_servers_list_data_source.go b/internal/service/odb/db_servers_list_data_source.go deleted file mode 100644 index 763c2bf587a5..000000000000 --- a/internal/service/odb/db_servers_list_data_source.go +++ /dev/null @@ -1,151 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "github.com/hashicorp/terraform-plugin-framework/attr" - - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_db_servers_list", name="Db Servers List") -func newDataSourceDbServersList(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceDbServersList{}, nil -} - -const ( - DSNameDbServersList = "Db Servers List Data Source" -) - -type dataSourceDbServersList struct { - framework.DataSourceWithModel[dbServersListDataSourceModel] -} - -func (d *dataSourceDbServersList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "cloud_exadata_infrastructure_id": schema.StringAttribute{ - Required: true, - Description: "The cloud exadata infrastructure ID. Mandatory field.", - }, - "db_servers": schema.ListAttribute{ - Description: "List of database servers associated with cloud_exadata_infrastructure_id.", - Computed: true, - CustomType: fwtypes.NewListNestedObjectTypeOf[dbServerForDbServersListDataSourceModel](ctx), - ElementType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "id": types.StringType, - "status": fwtypes.StringEnumType[odbtypes.ResourceStatus](), - "status_reason": types.StringType, - "cpu_core_count": types.Int32Type, - "cpu_core_count_per_node": types.Int32Type, - "db_server_patching_details": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "estimated_patch_duration": types.Int32Type, - "patching_status": fwtypes.StringEnumType[odbtypes.DbServerPatchingStatus](), - "time_patching_ended": types.StringType, - "time_patching_started": types.StringType, - }, - }, - "display_name": types.StringType, - "exadata_infrastructure_id": types.StringType, - "ocid": types.StringType, - "oci_resource_anchor_name": types.StringType, - "max_cpu_count": types.Int32Type, - "max_db_node_storage_in_gbs": types.Int32Type, - "max_memory_in_gbs": types.Int32Type, - "memory_size_in_gbs": types.Int32Type, - "shape": types.StringType, - "vm_cluster_ids": types.ListType{ - ElemType: types.StringType, - }, - "compute_model": fwtypes.StringEnumType[odbtypes.ComputeModel](), - "autonomous_vm_cluster_ids": types.ListType{ - ElemType: types.StringType, - }, - "autonomous_virtual_machine_ids": types.ListType{ - ElemType: types.StringType, - }, - }, - }, - }, - }, - } -} - -// Data sources only have a read method. -func (d *dataSourceDbServersList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - var data dbServersListDataSourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - input := odb.ListDbServersInput{} - if !data.CloudExadataInfrastructureId.IsNull() && !data.CloudExadataInfrastructureId.IsUnknown() { - input.CloudExadataInfrastructureId = data.CloudExadataInfrastructureId.ValueStringPointer() - } - out, err := conn.ListDbServers(ctx, &input) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameDbServersList, "", err), - err.Error(), - ) - return - } - - resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...) - if resp.Diagnostics.HasError() { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type dbServersListDataSourceModel struct { - framework.WithRegionModel - CloudExadataInfrastructureId types.String `tfsdk:"cloud_exadata_infrastructure_id"` - DbServers fwtypes.ListNestedObjectValueOf[dbServerForDbServersListDataSourceModel] `tfsdk:"db_servers"` -} - -type dbServerForDbServersListDataSourceModel struct { - DbServerId types.String `tfsdk:"id"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - CpuCoreCount types.Int32 `tfsdk:"cpu_core_count"` - DbNodeStorageSizeInGBs types.Int32 `tfsdk:"db_node_storage_size_in_gbs"` - DbServerPatchingDetails fwtypes.ObjectValueOf[dbNodePatchingDetailsForDbServersListDataSourceModel] `tfsdk:"db_server_patching_details"` - DisplayName types.String `tfsdk:"display_name"` - ExadataInfrastructureId types.String `tfsdk:"exadata_infrastructure_id"` - OCID types.String `tfsdk:"ocid"` - OciResourceAnchorName types.String `tfsdk:"oci_resource_anchor_name"` - MaxCpuCount types.Int32 `tfsdk:"max_cpu_count"` - MaxDbNodeStorageInGBs types.Int32 `tfsdk:"max_db_node_storage_in_gbs"` - MaxMemoryInGBs types.Int32 `tfsdk:"max_memory_in_gbs"` - MemorySizeInGBs types.Int32 `tfsdk:"memory_size_in_gbs"` - Shape types.String `tfsdk:"shape"` - //CreatedAt types.String `tfsdk:"created_at"` - VmClusterIds fwtypes.ListOfString `tfsdk:"vm_cluster_ids"` - ComputeModel fwtypes.StringEnum[odbtypes.ComputeModel] `tfsdk:"compute_model"` - AutonomousVmClusterIds fwtypes.ListOfString `tfsdk:"autonomous_vm_cluster_ids"` - AutonomousVirtualMachineIds fwtypes.ListOfString `tfsdk:"autonomous_virtual_machine_ids"` -} - -type dbNodePatchingDetailsForDbServersListDataSourceModel struct { - EstimatedPatchDuration types.Int32 `tfsdk:"estimated_patch_duration"` - PatchingStatus fwtypes.StringEnum[odbtypes.DbServerPatchingStatus] `tfsdk:"patching_status"` - TimePatchingEnded types.String `tfsdk:"time_patching_ended"` - TimePatchingStarted types.String `tfsdk:"time_patching_started"` -} diff --git a/internal/service/odb/db_servers_list_data_source_test.go b/internal/service/odb/db_servers_list_data_source_test.go deleted file mode 100644 index f70a6b38d184..000000000000 --- a/internal/service/odb/db_servers_list_data_source_test.go +++ /dev/null @@ -1,183 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "github.com/aws/aws-sdk-go-v2/aws" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "strconv" - "testing" - - "github.com/aws/aws-sdk-go-v2/service/odb" - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/names" -) - -type testDbServersListDataSource struct { - displayNamePrefix string -} - -var dbServersListDataSourceTests = testDbServersListDataSource{ - displayNamePrefix: "Ofake-exa", -} - -// Acceptance test access AWS and cost money to run. -func TestAccODBDbServersListDataSource_basic(t *testing.T) { - ctx := acctest.Context(t) - - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var dbserverslist odb.ListDbServersOutput - exaInfraDisplayName := sdkacctest.RandomWithPrefix(dbServersListDataSourceTests.displayNamePrefix) - - dataSourceName := "data.aws_odb_db_servers_list.test" - exaInfraResourceName := "aws_odb_cloud_exadata_infrastructure.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: dbServersListDataSourceTests.testAccCheckDbServersDestroyed(ctx), - Steps: []resource.TestStep{ - { - Config: dbServersListDataSourceTests.testAccDbServersListDataSourceConfigBasic(dbServersListDataSourceTests.exaInfra(exaInfraDisplayName)), - Check: resource.ComposeAggregateTestCheckFunc( - dbServersListDataSourceTests.testAccCheckDbServersListExists(ctx, exaInfraResourceName, &dbserverslist), - resource.TestCheckResourceAttr(dataSourceName, "aws_odb_db_servers_list.db_servers.#", strconv.Itoa(len(dbserverslist.DbServers))), - ), - }, - }, - }) -} - -func (testDbServersListDataSource) testAccCheckDbServersListExists(ctx context.Context, name string, output *odb.ListDbServersOutput) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.DSNameDbServersList, name, errors.New("not found")) - } - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - var exaInfraId = &rs.Primary.ID - - resp, err := dbServersListDataSourceTests.findDbServersList(ctx, conn, exaInfraId) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.DSNameDbServersList, rs.Primary.ID, err) - } - *output = *resp - return nil - } -} - -func (testDbServersListDataSource) testAccCheckDbServersDestroyed(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_cloud_exadata_infrastructure" { - continue - } - - _, err := dbServersListDataSourceTests.findExaInfra(ctx, conn, rs.Primary.ID) - - if tfresource.NotFound(err) { - return nil - } - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.DSNameDbServersList, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.DSNameDbServersList, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} - -func (testDbServersListDataSource) findExaInfra(ctx context.Context, conn *odb.Client, id string) (*odbtypes.CloudExadataInfrastructure, error) { - input := odb.GetCloudExadataInfrastructureInput{ - CloudExadataInfrastructureId: aws.String(id), - } - - out, err := conn.GetCloudExadataInfrastructure(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - - return nil, err - } - - if out == nil || out.CloudExadataInfrastructure == nil { - return nil, tfresource.NewEmptyResultError(&input) - } - - return out.CloudExadataInfrastructure, nil -} - -func (testDbServersListDataSource) findDbServersList(ctx context.Context, conn *odb.Client, exaInfraId *string) (*odb.ListDbServersOutput, error) { - inputWithExaId := &odb.ListDbServersInput{ - CloudExadataInfrastructureId: exaInfraId, - } - output, err := conn.ListDbServers(ctx, inputWithExaId) - if err != nil { - return nil, err - } - return output, nil -} - -func (testDbServersListDataSource) testAccDbServersListDataSourceConfigBasic(exaInfra string) string { - return fmt.Sprintf(` -%s - -data "aws_odb_db_servers_list" "test" { - cloud_exadata_infrastructure_id = aws_odb_cloud_exadata_infrastructure.test.id -} -`, exaInfra) -} - -func (testDbServersListDataSource) exaInfra(rName string) string { - exaRes := fmt.Sprintf(` -resource "aws_odb_cloud_exadata_infrastructure" "test" { - display_name = "%[1]s" - shape = "Exadata.X9M" - storage_count = 3 - compute_count = 2 - availability_zone_id = "use1-az6" - customer_contacts_to_send_to_oci = ["abc@example.com"] - maintenance_window = { - custom_action_timeout_in_mins = 16 - days_of_week = [] - hours_of_day = [] - is_custom_action_timeout_enabled = true - lead_time_in_weeks = 0 - months = [] - patching_mode = "ROLLING" - preference = "NO_PREFERENCE" - weeks_of_month =[] - } -} -`, rName) - //fmt.Println(resource) - return exaRes -} diff --git a/internal/service/odb/db_system_shapes_list_data_source.go b/internal/service/odb/db_system_shapes_list_data_source.go deleted file mode 100644 index 5272b2d0ed8b..000000000000 --- a/internal/service/odb/db_system_shapes_list_data_source.go +++ /dev/null @@ -1,150 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "fmt" - "github.com/hashicorp/terraform-plugin-framework/attr" - - "github.com/aws/aws-sdk-go-v2/service/odb" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_db_system_shapes_list", name="Db System Shapes List") -func newDataSourceDbSystemShapesList(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceDbSystemShapesList{}, nil -} - -const ( - DSNameDbSystemShapesList = "Db System Shapes List Data Source" -) - -type dataSourceDbSystemShapesList struct { - framework.DataSourceWithModel[dbSystemShapesListDataSourceModel] -} - -func (d *dataSourceDbSystemShapesList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "availability_zone_id": schema.StringAttribute{ - Optional: true, - Description: "The physical ID of the AZ, for example, use1-az4. This ID persists across accounts", - }, - "db_system_shapes": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.NewListNestedObjectTypeOf[dbSystemShapeDataSourceModel](ctx), - Description: fmt.Sprint("The list of shapes and their properties.\n\n" + - "(structure)\n" + - "Information about a hardware system model (shape) that's\n " + - "available for an Exadata infrastructure. The shape determines\n" + - "resources, such as CPU cores, memory, and storage, to allocate to\n " + - "the Exadata infrastructure.\n"), - ElementType: types.ObjectType{ - - AttrTypes: map[string]attr.Type{ - "available_core_count": types.Int32Type, - "available_core_count_per_node": types.Int32Type, - "available_data_storage_in_tbs": types.Int32Type, - "available_data_storage_per_server_in_tbs": types.Int32Type, - "available_db_node_per_node_in_gbs": types.Int32Type, - "available_db_node_storage_in_gbs": types.Int32Type, - "available_memory_in_gbs": types.Int32Type, - "available_memory_per_node_in_gbs": types.Int32Type, - "core_count_increment": types.Int32Type, - "max_storage_count": types.Int32Type, - "maximum_node_count": types.Int32Type, - "min_core_count_per_node": types.Int32Type, - "min_data_storage_in_tbs": types.Int32Type, - "min_db_node_storage_per_node_in_gbs": types.Int32Type, - "min_memory_per_node_in_gbs": types.Int32Type, - "min_storage_count": types.Int32Type, - "minimum_core_count": types.Int32Type, - "minimum_node_count": types.Int32Type, - "name": types.StringType, - "runtime_minimum_core_count": types.Int32Type, - "shape_family": types.StringType, - "shape_type": types.StringType, - }, - }, - }, - }, - } -} - -func (d *dataSourceDbSystemShapesList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - - var data dbSystemShapesListDataSourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - input := odb.ListDbSystemShapesInput{} - if !data.AvailabilityZoneId.IsNull() && !data.AvailabilityZoneId.IsUnknown() { - input.AvailabilityZoneId = data.AvailabilityZoneId.ValueStringPointer() - } - paginator := odb.NewListDbSystemShapesPaginator(conn, &input) - var out odb.ListDbSystemShapesOutput - for paginator.HasMorePages() { - page, err := paginator.NextPage(ctx) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameDbSystemShapesList, "", err), - err.Error(), - ) - return - } - - if page != nil && len(page.DbSystemShapes) > 0 { - out.DbSystemShapes = append(out.DbSystemShapes, page.DbSystemShapes...) - } - } - resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type dbSystemShapesListDataSourceModel struct { - framework.WithRegionModel - AvailabilityZoneId types.String `tfsdk:"availability_zone_id"` - DbSystemShapes fwtypes.ListNestedObjectValueOf[dbSystemShapeDataSourceModel] `tfsdk:"db_system_shapes"` -} - -type dbSystemShapeDataSourceModel struct { - AvailableCoreCount types.Int32 `tfsdk:"available_core_count"` - AvailableCoreCountPerNode types.Int32 `tfsdk:"available_core_count_per_node"` - AvailableDataStorageInTBs types.Int32 `tfsdk:"available_data_storage_in_tbs"` - AvailableDataStoragePerServerInTBs types.Int32 `tfsdk:"available_data_storage_per_server_in_tbs"` - AvailableDbNodePerNodeInGBs types.Int32 `tfsdk:"available_db_node_per_node_in_gbs"` - AvailableDbNodeStorageInGBs types.Int32 `tfsdk:"available_db_node_storage_in_gbs"` - AvailableMemoryInGBs types.Int32 `tfsdk:"available_memory_in_gbs"` - AvailableMemoryPerNodeInGBs types.Int32 `tfsdk:"available_memory_per_node_in_gbs"` - CoreCountIncrement types.Int32 `tfsdk:"core_count_increment"` - MaxStorageCount types.Int32 `tfsdk:"max_storage_count"` - MaximumNodeCount types.Int32 `tfsdk:"maximum_node_count"` - MinCoreCountPerNode types.Int32 `tfsdk:"min_core_count_per_node"` - MinDataStorageInTBs types.Int32 `tfsdk:"min_data_storage_in_tbs"` - MinDbNodeStoragePerNodeInGBs types.Int32 `tfsdk:"min_db_node_storage_per_node_in_gbs"` - MinMemoryPerNodeInGBs types.Int32 `tfsdk:"min_memory_per_node_in_gbs"` - MinStorageCount types.Int32 `tfsdk:"min_storage_count"` - MinimumCoreCount types.Int32 `tfsdk:"minimum_core_count"` - MinimumNodeCount types.Int32 `tfsdk:"minimum_node_count"` - Name types.String `tfsdk:"name"` - RuntimeMinimumCoreCount types.Int32 `tfsdk:"runtime_minimum_core_count"` - ShapeFamily types.String `tfsdk:"shape_family"` - ShapeType types.String `tfsdk:"shape_type"` -} diff --git a/internal/service/odb/db_system_shapes_list_data_source_test.go b/internal/service/odb/db_system_shapes_list_data_source_test.go deleted file mode 100644 index 3e5802761975..000000000000 --- a/internal/service/odb/db_system_shapes_list_data_source_test.go +++ /dev/null @@ -1,48 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "fmt" - - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/names" -) - -func TestAccODBDbSystemShapesListDataSource_basic(t *testing.T) { - ctx := acctest.Context(t) - // TIP: This is a long-running test guard for tests that run longer than - // 300s (5 min) generally. - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - dataSourceName := "data.aws_odb_db_system_shapes_list.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - Steps: []resource.TestStep{ - { - Config: testAccDbSystemShapesListDataSourceConfig_basic("use1-az6"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "db_system_shapes.#", "2"), - ), - }, - }, - }) -} - -func testAccDbSystemShapesListDataSourceConfig_basic(availabilityZoneId string) string { - return fmt.Sprintf(` -data "aws_odb_db_system_shapes_list" "test"{ - availability_zone_id = %[1]q -} -`, availabilityZoneId) -} diff --git a/internal/service/odb/generate.go b/internal/service/odb/generate.go deleted file mode 100644 index 2fef8ab1a1c7..000000000000 --- a/internal/service/odb/generate.go +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -ListTags -KVTValues -UpdateTags -//go:generate go run ../../generate/servicepackage/main.go -// ONLY generate directives and package declaration! Do not add anything else to this file. - -package odb diff --git a/internal/service/odb/gi_versions_list_data_source.go b/internal/service/odb/gi_versions_list_data_source.go deleted file mode 100644 index 9708dd98f9e9..000000000000 --- a/internal/service/odb/gi_versions_list_data_source.go +++ /dev/null @@ -1,103 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "fmt" - - "github.com/aws/aws-sdk-go-v2/service/odb" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_gi_versions_list", name="Gi Versions List") -func newDataSourceGiVersionsList(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceGiVersionsList{}, nil -} - -const ( - DSNameGiVersionsList = "Gi Versions List Data Source" -) - -type dataSourceGiVersionsList struct { - framework.DataSourceWithModel[giVersionDataSourceModel] -} - -func (d *dataSourceGiVersionsList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "shape": schema.StringAttribute{ - Optional: true, - Description: "The system shape.", - }, - }, - Blocks: map[string]schema.Block{ - "gi_versions": schema.ListNestedBlock{ - Description: fmt.Sprint(" (structure)\n " + - "Information about a specific version of Oracle Grid\n" + - "Infrastructure (GI) software that can be installed on a VM\n " + - "cluster.\n\n " + - "version -> (string)\n " + - "The GI software version."), - CustomType: fwtypes.NewListNestedObjectTypeOf[giVersionSummaryModel](ctx), - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - "version": schema.StringAttribute{ - Computed: true, - }, - }, - }, - }, - }, - } -} - -func (d *dataSourceGiVersionsList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - - var data giVersionDataSourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - var input odb.ListGiVersionsInput - if !data.Shape.IsNull() { - input.Shape = data.Shape.ValueStringPointer() - } - out, err := conn.ListGiVersions(ctx, &input) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameGiVersionsList, "", err), - err.Error(), - ) - return - } - - resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type giVersionDataSourceModel struct { - framework.WithRegionModel - GiVersions fwtypes.ListNestedObjectValueOf[giVersionSummaryModel] `tfsdk:"gi_versions"` - Shape types.String `tfsdk:"shape"` -} - -type giVersionSummaryModel struct { - Version types.String `tfsdk:"version"` -} diff --git a/internal/service/odb/gi_versions_list_data_source_test.go b/internal/service/odb/gi_versions_list_data_source_test.go deleted file mode 100644 index 0e0e19a2272a..000000000000 --- a/internal/service/odb/gi_versions_list_data_source_test.go +++ /dev/null @@ -1,71 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "fmt" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/names" - "testing" -) - -func TestAccGiVersionsListDataSource_basicX9M(t *testing.T) { - ctx := acctest.Context(t) - - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - dataSourceName := "data.aws_odb_gi_versions_list.test" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - Steps: []resource.TestStep{ - { - Config: testAccGiVersionsListeConfig_basic("Exadata.X9M"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "gi_versions.#", "2"), - ), - }, - }, - }) - -} - -func TestAccGiVersionsListDataSource_basicX11M(t *testing.T) { - ctx := acctest.Context(t) - - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - dataSourceName := "data.aws_odb_gi_versions_list.test" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - Steps: []resource.TestStep{ - { - Config: testAccGiVersionsListeConfig_basic("Exadata.X11M"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "gi_versions.#", "2"), - ), - }, - }, - }) -} - -func testAccGiVersionsListeConfig_basic(shape string) string { - return fmt.Sprintf(` - -data "aws_odb_gi_versions_list" "test" { - shape = %[1]q -} -`, shape) -} diff --git a/internal/service/odb/network.go b/internal/service/odb/network.go deleted file mode 100644 index cc81deb4f37a..000000000000 --- a/internal/service/odb/network.go +++ /dev/null @@ -1,829 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "errors" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" - "github.com/hashicorp/terraform-provider-aws/internal/enum" - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" - "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/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - "github.com/hashicorp/terraform-provider-aws/internal/errs/fwdiag" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/sweep" - sweepfw "github.com/hashicorp/terraform-provider-aws/internal/sweep/framework" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for resource registration to the Provider. DO NOT EDIT. -// @FrameworkResource("aws_odb_network", name="Network") -// @Tags(identifierAttribute="arn") -func newResourceNetwork(_ context.Context) (resource.ResourceWithConfigure, error) { - r := &resourceNetwork{} - r.SetDefaultCreateTimeout(24 * time.Hour) - r.SetDefaultUpdateTimeout(24 * time.Hour) - r.SetDefaultDeleteTimeout(24 * time.Hour) - - return r, nil -} - -const ( - ResNameNetwork = "Odb Network" -) - -type resourceNetwork struct { - framework.ResourceWithModel[odbNetworkResourceModel] - framework.WithTimeouts -} - -var OdbNetwork = newResourceNetwork -var managedServiceTimeout = 15 * time.Minute - -func (r *resourceNetwork) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - statusType := fwtypes.StringEnumType[odbtypes.ResourceStatus]() - stringLengthBetween1And255Validator := []validator.String{ - stringvalidator.LengthBetween(1, 255), - } - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - names.AttrARN: framework.ARNAttributeComputedOnly(), - names.AttrID: framework.IDAttribute(), - "display_name": schema.StringAttribute{ - Required: true, - Description: "Display name for the network resource.", - }, - "availability_zone_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "The AZ ID of the AZ where the ODB network is located. Changing this will force terraform to create new resource.", - }, - "client_subnet_cidr": schema.StringAttribute{ - Required: true, - Validators: stringLengthBetween1And255Validator, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "The CIDR notation for the network resource. Changing this will force terraform to create new resource.\n" + - " Constraints:\n " + - "\t - Must not overlap with the CIDR range of the backup subnet.\n " + - "\t- Must not overlap with the CIDR ranges of the VPCs that are connected to the\n " + - " ODB network.\n " + - "\t- Must not use the following CIDR ranges that are reserved by OCI:\n " + - "\t - 100.106.0.0/16 and 100.107.0.0/16\n " + - "\t - 169.254.0.0/16\n " + - "\t- 224.0.0.0 - 239.255.255.255\n " + - "\t- 240.0.0.0 - 255.255.255.255", - }, - "backup_subnet_cidr": schema.StringAttribute{ - Required: true, - Validators: stringLengthBetween1And255Validator, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: " The CIDR range of the backup subnet for the ODB network. Changing this will force terraform to create new resource.\n" + - "\tConstraints:\n" + - "\t - Must not overlap with the CIDR range of the client subnet.\n" + - "\t - Must not overlap with the CIDR ranges of the VPCs that are connected to the\n" + - "\t ODB network.\n" + - "\t - Must not use the following CIDR ranges that are reserved by OCI:\n" + - "\t - 100.106.0.0/16 and 100.107.0.0/16\n" + - "\t - 169.254.0.0/16\n" + - "\t - 224.0.0.0 - 239.255.255.255\n" + - "\t - 240.0.0.0 - 255.255.255.255", - }, - - "custom_domain_name": schema.StringAttribute{ - Optional: true, - Validators: stringLengthBetween1And255Validator, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "The name of the custom domain that the network is located. custom_domain_name and default_dns_prefix both can't be given.", - }, - "default_dns_prefix": schema.StringAttribute{ - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "The default DNS prefix for the network resource. Changing this will force terraform to create new resource.", - }, - "s3_access": schema.StringAttribute{ - Required: true, - CustomType: fwtypes.StringEnumType[odbtypes.Access](), - Description: "Specifies the configuration for Amazon S3 access from the ODB network.", - }, - "zero_etl_access": schema.StringAttribute{ - Required: true, - CustomType: fwtypes.StringEnumType[odbtypes.Access](), - Description: "pecifies the configuration for Zero-ETL access from the ODB network.", - }, - "s3_policy_document": schema.StringAttribute{ - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - Description: "Specifies the endpoint policy for Amazon S3 access from the ODB network.", - }, - "oci_dns_forwarding_configs": schema.ListAttribute{ - CustomType: fwtypes.NewListNestedObjectTypeOf[odbNwkOciDnsForwardingConfigResourceModel](ctx), - Computed: true, - Description: "The DNS resolver endpoint in OCI for forwarding DNS queries for the ociPrivateZone domain.", - ElementType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "domain_name": types.StringType, - "oci_dns_listener_ip": types.StringType, - }, - }, - }, - "peered_cidrs": schema.SetAttribute{ - CustomType: fwtypes.SetOfStringType, - ElementType: types.StringType, - Computed: true, - Description: "The list of CIDR ranges from the peered VPC that are allowed access to the ODB network. Please refer odb network peering documentation.", - }, - "oci_network_anchor_id": schema.StringAttribute{ - Computed: true, - Description: "The unique identifier of the OCI network anchor for the ODB network.", - }, - "oci_network_anchor_url": schema.StringAttribute{ - Computed: true, - Description: "The URL of the OCI network anchor for the ODB network.", - }, - "oci_resource_anchor_name": schema.StringAttribute{ - Computed: true, - Description: "The name of the OCI resource anchor for the ODB network.", - }, - "oci_vcn_id": schema.StringAttribute{ - Computed: true, - Description: "The unique identifier Oracle Cloud ID (OCID) of the OCI VCN for the ODB network.", - }, - "oci_vcn_url": schema.StringAttribute{ - Computed: true, - Description: "The URL of the OCI VCN for the ODB network.", - }, - "percent_progress": schema.Float32Attribute{ - Computed: true, - Description: "The amount of progress made on the current operation on the ODB network, expressed as a percentage.", - }, - "status": schema.StringAttribute{ - CustomType: statusType, - Computed: true, - Description: "The status of the network resource.", - }, - "status_reason": schema.StringAttribute{ - Computed: true, - Description: "Additional information about the current status of the ODB network.", - }, - "created_at": schema.StringAttribute{ - Computed: true, - Description: "The date and time when the ODB network was created.", - }, - "managed_services": schema.ObjectAttribute{ - Computed: true, - CustomType: fwtypes.NewObjectTypeOf[odbNetworkManagedServicesResourceModel](ctx), - Description: "The managed services configuration for the ODB network.", - AttributeTypes: map[string]attr.Type{ - "service_network_arn": types.StringType, - "resource_gateway_arn": types.StringType, - "managed_service_ipv4_cidrs": types.SetType{ - ElemType: types.StringType, - }, - "service_network_endpoint": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "vpc_endpoint_id": types.StringType, - "vpc_endpoint_type": fwtypes.StringEnumType[odbtypes.VpcEndpointType](), - }, - }, - "managed_s3_backup_access": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "status": fwtypes.StringEnumType[odbtypes.ManagedResourceStatus](), - "ipv4_addresses": types.SetType{ - ElemType: types.StringType, - }, - }, - }, - "zero_tl_access": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "status": fwtypes.StringEnumType[odbtypes.ManagedResourceStatus](), - "cidr": types.StringType, - }, - }, - "s3_access": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "status": fwtypes.StringEnumType[odbtypes.ManagedResourceStatus](), - "ipv4_addresses": types.SetType{ - ElemType: types.StringType, - }, - "domain_name": types.StringType, - "s3_policy_document": types.StringType, - }, - }, - }, - }, - names.AttrTags: tftags.TagsAttribute(), - names.AttrTagsAll: tftags.TagsAttributeComputedOnly(), - }, - Blocks: map[string]schema.Block{ - names.AttrTimeouts: timeouts.Block(ctx, timeouts.Opts{ - Create: true, - Update: true, - Delete: true, - }), - }, - } -} - -func (r *resourceNetwork) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - - conn := r.Meta().ODBClient(ctx) - var plan odbNetworkResourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.CreateOdbNetworkInput{ - ClientToken: aws.String(id.UniqueId()), - Tags: getTagsIn(ctx), - } - - resp.Diagnostics.Append(flex.Expand(ctx, plan, &input)...) - if resp.Diagnostics.HasError() { - return - } - out, err := conn.CreateOdbNetwork(ctx, &input) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameNetwork, plan.DisplayName.String(), err), - err.Error(), - ) - return - } - if out == nil || out.OdbNetworkId == nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameNetwork, plan.DisplayName.String(), nil), - errors.New("empty output").Error(), - ) - return - } - - createTimeout := r.CreateTimeout(ctx, plan.Timeouts) - createdOdbNetwork, err := waitNetworkCreated(ctx, conn, *out.OdbNetworkId, createTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForCreation, ResNameNetwork, plan.DisplayName.String(), err), - err.Error(), - ) - return - } - //set zero etl access - if plan.ZeroEtlAccess.ValueEnum() == odbtypes.AccessEnabled { - _, err = waitManagedServiceEnabled(ctx, conn, *createdOdbNetwork.OdbNetworkId, managedServiceTimeout, func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus { - return managedService.ZeroEtlAccess.Status - }) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameNetwork, plan.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - plan.ZeroEtlAccess = fwtypes.StringEnumValue(odbtypes.AccessEnabled) - - } else if plan.ZeroEtlAccess.ValueEnum() == odbtypes.AccessDisabled { - _, err = waitManagedServiceDisabled(ctx, conn, *createdOdbNetwork.OdbNetworkId, managedServiceTimeout, func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus { - return managedService.ZeroEtlAccess.Status - }) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameNetwork, plan.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - plan.ZeroEtlAccess = fwtypes.StringEnumValue(odbtypes.AccessDisabled) - } - - //set s3 access - if plan.S3Access.ValueEnum() == odbtypes.AccessEnabled { - _, err = waitManagedServiceEnabled(ctx, conn, *createdOdbNetwork.OdbNetworkId, managedServiceTimeout, func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus { - return managedService.S3Access.Status - }) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameNetwork, plan.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - plan.S3Access = fwtypes.StringEnumValue(odbtypes.AccessEnabled) - - } else if plan.S3Access.ValueEnum() == odbtypes.AccessDisabled { - _, err = waitManagedServiceDisabled(ctx, conn, *createdOdbNetwork.OdbNetworkId, managedServiceTimeout, func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus { - return managedService.S3Access.Status - }) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameNetwork, plan.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - plan.S3Access = fwtypes.StringEnumValue(odbtypes.AccessDisabled) - } - - plan.S3PolicyDocument = types.StringPointerValue(createdOdbNetwork.ManagedServices.S3Access.S3PolicyDocument) - plan.CreatedAt = types.StringValue(createdOdbNetwork.CreatedAt.Format(time.RFC3339)) - - resp.Diagnostics.Append(flex.Flatten(ctx, createdOdbNetwork, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) - -} - -func (r *resourceNetwork) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - conn := r.Meta().ODBClient(ctx) - - var state odbNetworkResourceModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := FindOdbNetworkByID(ctx, conn, state.OdbNetworkId.ValueString()) - if tfresource.NotFound(err) { - resp.Diagnostics.Append(fwdiag.NewResourceNotFoundWarningDiagnostic(err)) - resp.State.RemoveResource(ctx) - return - } - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, ResNameNetwork, state.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - if out.ManagedServices != nil { - - readS3AccessStatus, err := managedServiceStatusToAccessStatus(out.ManagedServices.S3Access.Status) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, ResNameNetwork, state.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - state.S3Access = fwtypes.StringEnumValue(readS3AccessStatus) - state.S3PolicyDocument = types.StringPointerValue(out.ManagedServices.S3Access.S3PolicyDocument) - - readZeroEtlAccessStatus, err := managedServiceStatusToAccessStatus(out.ManagedServices.ZeroEtlAccess.Status) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, ResNameNetwork, state.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - state.ZeroEtlAccess = fwtypes.StringEnumValue(readZeroEtlAccessStatus) - } else { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, ResNameNetwork, state.OdbNetworkId.String(), errors.New("odbNetwork managed service not found")), - "Odb Network managed service cannot be nil", - ) - return - } - state.CreatedAt = types.StringValue(out.CreatedAt.Format(time.RFC3339)) - resp.Diagnostics.Append(flex.Flatten(ctx, out, &state)...) - if resp.Diagnostics.HasError() { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) -} - -func (r *resourceNetwork) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - - conn := r.Meta().ODBClient(ctx) - - var plan, state odbNetworkResourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - isUpdateRequired := false - var input odb.UpdateOdbNetworkInput - - if !plan.DisplayName.Equal(state.DisplayName) { - isUpdateRequired = true - input.DisplayName = plan.DisplayName.ValueStringPointer() - } - - if !plan.S3Access.Equal(state.S3Access) { - isUpdateRequired = true - input.S3Access = plan.S3Access.ValueEnum() - } - - if !plan.ZeroEtlAccess.Equal(state.ZeroEtlAccess) { - isUpdateRequired = true - input.ZeroEtlAccess = plan.ZeroEtlAccess.ValueEnum() - } - if !plan.S3PolicyDocument.Equal(state.S3PolicyDocument) { - isUpdateRequired = true - if !plan.S3PolicyDocument.IsNull() || !plan.S3PolicyDocument.IsUnknown() { - input.S3PolicyDocument = plan.S3PolicyDocument.ValueStringPointer() - } - } - if isUpdateRequired { - input.OdbNetworkId = state.OdbNetworkId.ValueStringPointer() - - out, err := conn.UpdateOdbNetwork(ctx, &input) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionUpdating, ResNameNetwork, plan.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - if out == nil || out.OdbNetworkId == nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionUpdating, ResNameNetwork, plan.OdbNetworkId.String(), nil), - errors.New("empty output").Error(), - ) - return - } - } - - updateTimeout := r.UpdateTimeout(ctx, plan.Timeouts) - updatedOdbNwk, err := waitNetworkUpdated(ctx, conn, plan.OdbNetworkId.ValueString(), updateTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameNetwork, plan.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - - if plan.S3Access.ValueEnum() == odbtypes.AccessEnabled { - _, err = waitManagedServiceEnabled(ctx, conn, *input.OdbNetworkId, managedServiceTimeout, func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus { - return managedService.S3Access.Status - }) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameNetwork, plan.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - plan.S3Access = fwtypes.StringEnumValue(odbtypes.AccessEnabled) - - } else if plan.S3Access.ValueEnum() == odbtypes.AccessDisabled { - _, err = waitManagedServiceDisabled(ctx, conn, *input.OdbNetworkId, managedServiceTimeout, func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus { - return managedService.S3Access.Status - }) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameNetwork, plan.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - plan.S3Access = fwtypes.StringEnumValue(odbtypes.AccessDisabled) - } - - if plan.ZeroEtlAccess.ValueEnum() == odbtypes.AccessEnabled { - _, err = waitManagedServiceEnabled(ctx, conn, *input.OdbNetworkId, managedServiceTimeout, func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus { - return managedService.ZeroEtlAccess.Status - }) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameNetwork, plan.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - plan.ZeroEtlAccess = fwtypes.StringEnumValue(odbtypes.AccessEnabled) - - } else if plan.ZeroEtlAccess.ValueEnum() == odbtypes.AccessDisabled { - _, err = waitManagedServiceDisabled(ctx, conn, *input.OdbNetworkId, managedServiceTimeout, func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus { - return managedService.ZeroEtlAccess.Status - }) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameNetwork, plan.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - plan.ZeroEtlAccess = fwtypes.StringEnumValue(odbtypes.AccessDisabled) - } - plan.S3PolicyDocument = types.StringPointerValue(updatedOdbNwk.ManagedServices.S3Access.S3PolicyDocument) - plan.CreatedAt = types.StringValue(updatedOdbNwk.CreatedAt.Format(time.RFC3339)) - - resp.Diagnostics.Append(flex.Flatten(ctx, updatedOdbNwk, &plan)...) - resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) -} - -func (r *resourceNetwork) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - conn := r.Meta().ODBClient(ctx) - - var state odbNetworkResourceModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - deleteAssociatedResources := false - input := odb.DeleteOdbNetworkInput{ - OdbNetworkId: state.OdbNetworkId.ValueStringPointer(), - DeleteAssociatedResources: &deleteAssociatedResources, - } - - _, err := conn.DeleteOdbNetwork(ctx, &input) - - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return - } - - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionDeleting, ResNameNetwork, state.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - - deleteTimeout := r.DeleteTimeout(ctx, state.Timeouts) - _, err = waitNetworkDeleted(ctx, conn, state.OdbNetworkId.ValueString(), deleteTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForDeletion, ResNameNetwork, state.OdbNetworkArn.String(), err), - err.Error(), - ) - return - } -} - -func (r *resourceNetwork) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resource.ImportStatePassthroughID(ctx, path.Root(names.AttrID), req, resp) -} - -func waitNetworkCreated(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.OdbNetwork, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusProvisioning), - Target: enum.Slice(odbtypes.ResourceStatusAvailable, odbtypes.ResourceStatusFailed), - Refresh: statusNetwork(ctx, conn, id), - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.OdbNetwork); ok { - return out, err - } - - return nil, err -} - -func managedServiceStatusToAccessStatus(mangedStatus odbtypes.ManagedResourceStatus) (odbtypes.Access, error) { - if mangedStatus == odbtypes.ManagedResourceStatusDisabled { - return odbtypes.AccessDisabled, nil - } - if mangedStatus == odbtypes.ManagedResourceStatusEnabled { - return odbtypes.AccessEnabled, nil - } - return "", errors.New("can not convert managed status to access status") -} - -func waitManagedServiceEnabled(ctx context.Context, conn *odb.Client, id string, timeout time.Duration, managedResourceStatus func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus) (*odbtypes.OdbNetwork, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ManagedResourceStatusEnabling), - Target: enum.Slice(odbtypes.ManagedResourceStatusEnabled), - Refresh: statusManagedService(ctx, conn, id, managedResourceStatus), - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.OdbNetwork); ok { - return out, err - } - - return nil, err -} - -func waitManagedServiceDisabled(ctx context.Context, conn *odb.Client, id string, timeout time.Duration, managedResourceStatus func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus) (*odbtypes.OdbNetwork, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ManagedResourceStatusDisabling), - Target: enum.Slice(odbtypes.ManagedResourceStatusDisabled), - Refresh: statusManagedService(ctx, conn, id, managedResourceStatus), - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.OdbNetwork); ok { - return out, err - } - - return nil, err -} - -func statusManagedService(ctx context.Context, conn *odb.Client, id string, managedResourceStatus func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus) retry.StateRefreshFunc { - return func() (any, string, error) { - out, err := FindOdbNetworkByID(ctx, conn, id) - - if err != nil { - return nil, "", err - } - - if out.ManagedServices == nil { - return nil, "", nil - } - - return out, string(managedResourceStatus(out.ManagedServices)), nil - } -} - -func waitNetworkUpdated(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.OdbNetwork, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusUpdating), - Target: enum.Slice(odbtypes.ResourceStatusAvailable, odbtypes.ResourceStatusFailed), - Refresh: statusNetwork(ctx, conn, id), - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.OdbNetwork); ok { - return out, err - } - - return nil, err -} - -func waitNetworkDeleted(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.OdbNetwork, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusTerminating), - Target: []string{}, - Refresh: statusNetwork(ctx, conn, id), - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.OdbNetwork); ok { - return out, err - } - - return nil, err -} - -func statusNetwork(ctx context.Context, conn *odb.Client, id string) retry.StateRefreshFunc { - return func() (any, string, error) { - out, err := FindOdbNetworkByID(ctx, conn, id) - if tfresource.NotFound(err) { - return nil, "", nil - } - - if err != nil { - return nil, "", err - } - - return out, string(out.Status), nil - } -} - -func FindOdbNetworkByID(ctx context.Context, conn *odb.Client, id string) (*odbtypes.OdbNetwork, error) { - input := odb.GetOdbNetworkInput{ - OdbNetworkId: aws.String(id), - } - - out, err := conn.GetOdbNetwork(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - - return nil, err - } - - if out == nil || out.OdbNetwork == nil { - return nil, tfresource.NewEmptyResultError(&input) - } - - return out.OdbNetwork, nil -} - -func sweepNetworks(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) { - input := odb.ListOdbNetworksInput{} - conn := client.ODBClient(ctx) - var sweepResources []sweep.Sweepable - - pages := odb.NewListOdbNetworksPaginator(conn, &input) - for pages.HasMorePages() { - page, err := pages.NextPage(ctx) - if err != nil { - return nil, err - } - - for _, v := range page.OdbNetworks { - sweepResources = append(sweepResources, sweepfw.NewSweepResource(newResourceNetwork, client, - sweepfw.NewAttribute(names.AttrID, aws.ToString(v.OdbNetworkId))), - ) - } - } - - return sweepResources, nil -} - -type odbNetworkResourceModel struct { - framework.WithRegionModel - DisplayName types.String `tfsdk:"display_name"` - 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.ObjectValueOf[odbNetworkManagedServicesResourceModel] `tfsdk:"managed_services"` - CreatedAt types.String `tfsdk:"created_at" autoflex:",noflatten"` - Tags tftags.Map `tfsdk:"tags"` - TagsAll tftags.Map `tfsdk:"tags_all"` -} - -type odbNwkOciDnsForwardingConfigResourceModel struct { - DomainName types.String `tfsdk:"domain_name"` - OciDnsListenerIp types.String `tfsdk:"oci_dns_listener_ip"` -} -type odbNetworkManagedServicesResourceModel struct { - ServiceNetworkArn types.String `tfsdk:"service_network_arn"` - ResourceGatewayArn types.String `tfsdk:"resource_gateway_arn"` - ManagedServicesIpv4Cidrs fwtypes.SetOfString `tfsdk:"managed_service_ipv4_cidrs"` - ServiceNetworkEndpoint fwtypes.ObjectValueOf[serviceNetworkEndpointOdbNetworkResourceModel] `tfsdk:"service_network_endpoint"` - ManagedS3BackupAccess fwtypes.ObjectValueOf[managedS3BackupAccessOdbNetworkResourceModel] `tfsdk:"managed_s3_backup_access"` - ZeroEtlAccess fwtypes.ObjectValueOf[zeroEtlAccessOdbNetworkResourceModel] `tfsdk:"zero_etl_access"` - S3Access fwtypes.ObjectValueOf[s3AccessOdbNetworkResourceModel] `tfsdk:"s3_access"` -} - -type serviceNetworkEndpointOdbNetworkResourceModel struct { - VpcEndpointId types.String `tfsdk:"vpc_endpoint_id"` - VpcEndpointType fwtypes.StringEnum[odbtypes.VpcEndpointType] `tfsdk:"vpc_endpoint_type"` -} - -type managedS3BackupAccessOdbNetworkResourceModel struct { - Status fwtypes.StringEnum[odbtypes.ManagedResourceStatus] `tfsdk:"status"` - Ipv4Addresses fwtypes.SetOfString `tfsdk:"ipv4_addresses"` -} - -type zeroEtlAccessOdbNetworkResourceModel struct { - Status fwtypes.StringEnum[odbtypes.ManagedResourceStatus] `tfsdk:"status"` - Cidr types.String `tfsdk:"cidr"` -} - -type s3AccessOdbNetworkResourceModel struct { - Status fwtypes.StringEnum[odbtypes.ManagedResourceStatus] `tfsdk:"status"` - Ipv4Addresses fwtypes.SetOfString `tfsdk:"ipv4_addresses"` - DomainName types.String `tfsdk:"domain_name"` - S3PolicyDocument types.String `tfsdk:"s3_policy_document"` -} diff --git a/internal/service/odb/network_data_source.go b/internal/service/odb/network_data_source.go deleted file mode 100644 index 1f7e94865848..000000000000 --- a/internal/service/odb/network_data_source.go +++ /dev/null @@ -1,248 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "github.com/hashicorp/terraform-provider-aws/names" - "time" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_network", name="Network") -func newDataSourceNetwork(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceNetwork{}, nil -} - -const ( - DSNameNetwork = "Odb Network Data Source" -) - -type dataSourceNetwork struct { - framework.DataSourceWithModel[odbNetworkDataSourceModel] -} - -var OdbNetworkDataSource dataSourceNetwork - -func (d *dataSourceNetwork) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - statusType := fwtypes.StringEnumType[odbtypes.ResourceStatus]() - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - names.AttrARN: framework.ARNAttributeComputedOnly(), - names.AttrID: schema.StringAttribute{ - Required: true, - }, - "display_name": schema.StringAttribute{ - Computed: true, - }, - "availability_zone_id": schema.StringAttribute{ - Computed: true, - }, - "availability_zone": schema.StringAttribute{ - Computed: true, - }, - "backup_subnet_cidr": schema.StringAttribute{ - Computed: true, - }, - "client_subnet_cidr": schema.StringAttribute{ - Computed: true, - }, - "custom_domain_name": schema.StringAttribute{ - Computed: true, - }, - "default_dns_prefix": schema.StringAttribute{ - Computed: true, - }, - "oci_network_anchor_id": schema.StringAttribute{ - Computed: true, - }, - "oci_network_anchor_url": schema.StringAttribute{ - Computed: true, - }, - "oci_resource_anchor_name": schema.StringAttribute{ - Computed: true, - }, - "oci_vcn_id": schema.StringAttribute{ - Computed: true, - }, - "oci_vcn_url": schema.StringAttribute{ - Computed: true, - }, - "percent_progress": schema.Float64Attribute{ - Computed: true, - }, - "peered_cidrs": schema.SetAttribute{ - CustomType: fwtypes.SetOfStringType, - ElementType: types.StringType, - Computed: true, - Description: "The list of CIDR ranges from the peered VPC that are allowed access to the ODB network. Please refer odb network peering documentation.", - }, - "status": schema.StringAttribute{ - CustomType: statusType, - Computed: true, - }, - "status_reason": schema.StringAttribute{ - Computed: true, - }, - "created_at": schema.StringAttribute{ - Computed: true, - }, - "managed_services": schema.ObjectAttribute{ - Computed: true, - CustomType: fwtypes.NewObjectTypeOf[odbNetworkManagedServicesDataSourceModel](ctx), - AttributeTypes: map[string]attr.Type{ - "service_network_arn": types.StringType, - "resource_gateway_arn": types.StringType, - "managed_service_ipv4_cidrs": types.ListType{ - ElemType: types.StringType, - }, - "service_network_endpoint": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "vpc_endpoint_id": types.StringType, - "vpc_endpoint_type": fwtypes.StringEnumType[odbtypes.VpcEndpointType](), - }, - }, - "managed_s3_backup_access": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "status": fwtypes.StringEnumType[odbtypes.ResourceStatus](), - "ipv4_addresses": types.ListType{ - ElemType: types.StringType, - }, - }, - }, - "zero_tl_access": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "status": fwtypes.StringEnumType[odbtypes.ManagedResourceStatus](), - "cidr": types.StringType, - }, - }, - "s3_access": types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "status": fwtypes.StringEnumType[odbtypes.ManagedResourceStatus](), - "ipv4_addresses": types.ListType{ - ElemType: types.StringType, - }, - "domain_name": types.StringType, - "s3_policy_document": types.StringType, - }, - }, - }, - }, - names.AttrTags: tftags.TagsAttributeComputedOnly(), - "oci_dns_forwarding_configs": schema.ListAttribute{ - Computed: true, - CustomType: fwtypes.NewListNestedObjectTypeOf[odbNwkOciDnsForwardingConfigDataSourceModel](ctx), - ElementType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "domain_name": types.StringType, - "oci_dns_listener_ip": types.StringType, - }, - }, - }, - }, - } -} - -func (d *dataSourceNetwork) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - conn := d.Meta().ODBClient(ctx) - var data odbNetworkDataSourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.GetOdbNetworkInput{ - OdbNetworkId: data.OdbNetworkId.ValueStringPointer(), - } - - out, err := conn.GetOdbNetwork(ctx, &input) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameNetwork, data.OdbNetworkId.String(), err), - err.Error(), - ) - return - } - - data.CreatedAt = types.StringValue(out.OdbNetwork.CreatedAt.Format(time.RFC3339)) - resp.Diagnostics.Append(flex.Flatten(ctx, out.OdbNetwork, &data, flex.WithIgnoredFieldNamesAppend("CreatedAt"))...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type odbNetworkDataSourceModel struct { - framework.WithRegionModel - AvailabilityZone types.String `tfsdk:"availability_zone"` - AvailabilityZoneId types.String `tfsdk:"availability_zone_id"` - BackupSubnetCidr types.String `tfsdk:"backup_subnet_cidr"` - ClientSubnetCidr types.String `tfsdk:"client_subnet_cidr"` - CustomDomainName types.String `tfsdk:"custom_domain_name"` - DefaultDnsPrefix types.String `tfsdk:"default_dns_prefix"` - DisplayName types.String `tfsdk:"display_name"` - OciDnsForwardingConfigs fwtypes.ListNestedObjectValueOf[odbNwkOciDnsForwardingConfigDataSourceModel] `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"` - OdbNetworkId types.String `tfsdk:"id"` - PeeredCidrs fwtypes.SetValueOf[types.String] `tfsdk:"peered_cidrs"` - PercentProgress types.Float64 `tfsdk:"percent_progress"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - CreatedAt types.String `tfsdk:"created_at"` - ManagedServices fwtypes.ObjectValueOf[odbNetworkManagedServicesDataSourceModel] `tfsdk:"managed_services"` - Tags tftags.Map `tfsdk:"tags"` -} - -type odbNwkOciDnsForwardingConfigDataSourceModel struct { - DomainName types.String `tfsdk:"domain_name"` - OciDnsListenerIp types.String `tfsdk:"oci_dns_listener_ip"` -} - -type odbNetworkManagedServicesDataSourceModel struct { - ServiceNetworkArn types.String `tfsdk:"service_network_arn"` - ResourceGatewayArn types.String `tfsdk:"resource_gateway_arn"` - ManagedServicesIpv4Cidrs fwtypes.ListOfString `tfsdk:"managed_service_ipv4_cidrs"` - ServiceNetworkEndpoint fwtypes.ObjectValueOf[serviceNetworkEndpointOdbNetworkDataSourceModel] `tfsdk:"service_network_endpoint"` - ManagedS3BackupAccess fwtypes.ObjectValueOf[managedS3BackupAccessOdbNetworkDataSourceModel] `tfsdk:"managed_s3_backup_access"` - ZeroEtlAccess fwtypes.ObjectValueOf[zeroEtlAccessOdbNetworkDataSourceModel] `tfsdk:"zero_tl_access"` - S3Access fwtypes.ObjectValueOf[s3AccessOdbNetworkDataSourceModel] `tfsdk:"s3_access"` -} - -type serviceNetworkEndpointOdbNetworkDataSourceModel struct { - VpcEndpointId types.String `tfsdk:"vpc_endpoint_id"` - VpcEndpointType fwtypes.StringEnum[odbtypes.VpcEndpointType] `tfsdk:"vpc_endpoint_type"` -} - -type managedS3BackupAccessOdbNetworkDataSourceModel struct { - Status fwtypes.StringEnum[odbtypes.ManagedResourceStatus] `tfsdk:"status"` - Ipv4Addresses fwtypes.ListOfString `tfsdk:"ipv4_addresses"` -} - -type zeroEtlAccessOdbNetworkDataSourceModel struct { - Status fwtypes.StringEnum[odbtypes.ManagedResourceStatus] `tfsdk:"status"` - Cidr types.String `tfsdk:"cidr"` -} - -type s3AccessOdbNetworkDataSourceModel struct { - Status fwtypes.StringEnum[odbtypes.ManagedResourceStatus] `tfsdk:"status"` - Ipv4Addresses fwtypes.ListOfString `tfsdk:"ipv4_addresses"` - DomainName types.String `tfsdk:"domain_name"` - S3PolicyDocument types.String `tfsdk:"s3_policy_document"` -} diff --git a/internal/service/odb/network_data_source_test.go b/internal/service/odb/network_data_source_test.go deleted file mode 100644 index a6a4161a7461..000000000000 --- a/internal/service/odb/network_data_source_test.go +++ /dev/null @@ -1,144 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/names" -) - -type odbNetworkDataSourceTestCase struct { -} - -var odbNetDSTest = odbNetworkDataSourceTestCase{} - -func TestAccODBOdbNetworkDataSource_basic(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - networkResource := "aws_odb_network.test_resource" - networkDataSource := "data.aws_odb_network.test" - rName := sdkacctest.RandomWithPrefix("tf-odb-net") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - odbNetDSTest.testAccOdbNetworkDataSourcePreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: odbNetDSTest.testAccCheckOdbNetworkDataSourceDestroyed(ctx), - Steps: []resource.TestStep{ - { - Config: odbNetDSTest.basicOdbNetworkDataSource(rName), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrPair(networkResource, "id", networkDataSource, "id"), - ), - }, - }, - }) -} - -func (odbNetworkDataSourceTestCase) testAccCheckOdbNetworkDataSourceDestroyed(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_network" { - continue - } - _, err := odbNetDSTest.findOdbNetwork(ctx, conn, rs.Primary.ID) - if tfresource.NotFound(err) { - return nil - } - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameNetwork, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameNetwork, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} - -func (odbNetworkDataSourceTestCase) findOdbNetwork(ctx context.Context, conn *odb.Client, id string) (*odbtypes.OdbNetwork, error) { - input := odb.GetOdbNetworkInput{ - OdbNetworkId: aws.String(id), - } - - out, err := conn.GetOdbNetwork(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - - return nil, err - } - - if out == nil || out.OdbNetwork == nil { - return nil, tfresource.NewEmptyResultError(&input) - } - - return out.OdbNetwork, nil -} - -func (odbNetworkDataSourceTestCase) basicOdbNetworkDataSource(rName string) string { - networkRes := fmt.Sprintf(` - - -resource "aws_odb_network" "test_resource" { - display_name = %[1]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" - tags = { - "env"= "dev" - } -} - - -data "aws_odb_network" "test" { - id = aws_odb_network.test_resource.id -} - -`, rName) - return networkRes -} -func (odbNetworkDataSourceTestCase) testAccOdbNetworkDataSourcePreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListOdbNetworksInput{} - - _, err := conn.ListOdbNetworks(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} diff --git a/internal/service/odb/network_peering_connection.go b/internal/service/odb/network_peering_connection.go deleted file mode 100644 index 46f057869e4c..000000000000 --- a/internal/service/odb/network_peering_connection.go +++ /dev/null @@ -1,481 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "errors" - "github.com/hashicorp/terraform-provider-aws/internal/enum" - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" - - "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/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - "github.com/hashicorp/terraform-provider-aws/internal/errs/fwdiag" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/sweep" - sweepfw "github.com/hashicorp/terraform-provider-aws/internal/sweep/framework" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for resource registration to the Provider. DO NOT EDIT. -// @FrameworkResource("aws_odb_network_peering_connection", name="Network Peering Connection") -// @Tags(identifierAttribute="arn") -func newResourceNetworkPeeringConnection(_ context.Context) (resource.ResourceWithConfigure, error) { - r := &resourceNetworkPeeringConnection{} - - r.SetDefaultCreateTimeout(24 * time.Hour) - r.SetDefaultUpdateTimeout(24 * time.Hour) - r.SetDefaultDeleteTimeout(24 * time.Hour) - - return r, nil -} - -const ( - ResNameNetworkPeeringConnection = "Network Peering Connection" -) - -type resourceNetworkPeeringConnection struct { - framework.ResourceWithModel[odbNetworkPeeringConnectionResourceModel] - framework.WithTimeouts -} - -func (r *resourceNetworkPeeringConnection) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - Description: "Information about an ODB network. Also refer odb_network_peering resource : A peering connection between an ODB network and either another ODB network or a customer-owned VPC.", - Attributes: map[string]schema.Attribute{ - names.AttrARN: framework.ARNAttributeComputedOnly(), - names.AttrID: framework.IDAttribute(), - "odb_network_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "Required field. The unique identifier of the ODB network that initiates the peering connection. " + - "A sample ID is odbpcx-abcdefgh12345678. Changing this will force terraform to create new resource.", - }, - "peer_network_id": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Description: "Required field. The unique identifier of the ODB peering connection. Changing this will force terraform to create new resource", - }, - - "display_name": schema.StringAttribute{ - Description: "Display name of the odb network peering connection. Changing this will force terraform to create new resource", - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "status": schema.StringAttribute{ - Description: "Status of the odb network peering connection.", - CustomType: fwtypes.StringEnumType[odbtypes.ResourceStatus](), - Computed: true, - }, - "status_reason": schema.StringAttribute{ - Description: "The reason for the current status of the ODB peering connection..", - Computed: true, - }, - - "odb_network_arn": schema.StringAttribute{ - Description: "ARN of the odb network peering connection.", - Computed: true, - }, - - "peer_network_arn": schema.StringAttribute{ - Description: "ARN of the peer network peering connection.", - Computed: true, - }, - "odb_peering_connection_type": schema.StringAttribute{ - Description: "Type of the odb peering connection.", - Computed: true, - }, - "created_at": schema.StringAttribute{ - Description: "Created time of the odb network peering connection.", - Computed: true, - }, - "percent_progress": schema.Float32Attribute{ - Description: "Progress of the odb network peering connection.", - Computed: true, - }, - names.AttrTags: tftags.TagsAttribute(), - names.AttrTagsAll: tftags.TagsAttributeComputedOnly(), - }, - Blocks: map[string]schema.Block{ - names.AttrTimeouts: timeouts.Block(ctx, timeouts.Opts{ - Create: true, - Update: true, - Delete: true, - }), - }, - } -} - -func (r *resourceNetworkPeeringConnection) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - conn := r.Meta().ODBClient(ctx) - - var plan odbNetworkPeeringConnectionResourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.CreateOdbPeeringConnectionInput{ - OdbNetworkId: plan.OdbNetworkId.ValueStringPointer(), - PeerNetworkId: plan.PeerNetworkId.ValueStringPointer(), - DisplayName: plan.DisplayName.ValueStringPointer(), - Tags: getTagsIn(ctx), - } - - out, err := conn.CreateOdbPeeringConnection(ctx, &input) - if err != nil { - - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameNetworkPeeringConnection, plan.DisplayName.ValueString(), err), - err.Error(), - ) - return - } - if out == nil || out.OdbPeeringConnectionId == nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameNetworkPeeringConnection, plan.DisplayName.ValueString(), nil), - errors.New("empty output").Error(), - ) - return - } - - resp.Diagnostics.Append(flex.Flatten(ctx, out, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - createTimeout := r.CreateTimeout(ctx, plan.Timeouts) - createdPeeredConnection, err := waitNetworkPeeringConnectionCreated(ctx, conn, plan.OdbPeeringConnectionId.ValueString(), createTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForCreation, ResNameNetworkPeeringConnection, plan.DisplayName.ValueString(), err), - err.Error(), - ) - return - } - plan.CreatedAt = types.StringValue(createdPeeredConnection.CreatedAt.Format(time.RFC3339)) - resp.Diagnostics.Append(flex.Flatten(ctx, createdPeeredConnection, &plan, flex.WithIgnoredFieldNamesAppend("CreatedAt"))...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) -} - -func (r *resourceNetworkPeeringConnection) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - conn := r.Meta().ODBClient(ctx) - var state odbNetworkPeeringConnectionResourceModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := findNetworkPeeringConnectionByID(ctx, conn, state.OdbPeeringConnectionId.ValueString()) - if tfresource.NotFound(err) { - resp.Diagnostics.Append(fwdiag.NewResourceNotFoundWarningDiagnostic(err)) - resp.State.RemoveResource(ctx) - return - } - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, ResNameNetworkPeeringConnection, state.OdbPeeringConnectionId.ValueString(), err), - err.Error(), - ) - return - } - state.CreatedAt = types.StringValue(out.CreatedAt.Format(time.RFC3339)) - - resp.Diagnostics.Append(flex.Flatten(ctx, out, &state, flex.WithIgnoredFieldNamesAppend("CreatedAt"))...) - if resp.Diagnostics.HasError() { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) -} - -func (r *resourceNetworkPeeringConnection) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - conn := r.Meta().ODBClient(ctx) - - var plan, state odbNetworkPeeringConnectionResourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - updateTimeout := r.UpdateTimeout(ctx, plan.Timeouts) - updatedOdbNetPeeringConn, err := waitNetworkPeeringConnectionUpdated(ctx, conn, plan.OdbPeeringConnectionId.ValueString(), updateTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForUpdate, ResNameNetworkPeeringConnection, plan.OdbPeeringConnectionId.ValueString(), err), - err.Error(), - ) - return - } - plan.CreatedAt = types.StringValue(updatedOdbNetPeeringConn.CreatedAt.Format(time.RFC3339)) - resp.Diagnostics.Append(flex.Flatten(ctx, updatedOdbNetPeeringConn, &plan, flex.WithIgnoredFieldNamesAppend("CreatedAt"))...) - if resp.Diagnostics.HasError() { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) -} - -func (r *resourceNetworkPeeringConnection) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - conn := r.Meta().ODBClient(ctx) - var state odbNetworkPeeringConnectionResourceModel - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.DeleteOdbPeeringConnectionInput{ - OdbPeeringConnectionId: state.OdbPeeringConnectionId.ValueStringPointer(), - } - - _, err := conn.DeleteOdbPeeringConnection(ctx, &input) - - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return - } - - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionDeleting, ResNameNetworkPeeringConnection, state.OdbPeeringConnectionId.ValueString(), err), - err.Error(), - ) - return - } - - deleteTimeout := r.DeleteTimeout(ctx, state.Timeouts) - _, err = waitNetworkPeeringConnectionDeleted(ctx, conn, state.OdbPeeringConnectionId.ValueString(), deleteTimeout) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionWaitingForDeletion, ResNameNetworkPeeringConnection, state.OdbPeeringConnectionId.String(), err), - err.Error(), - ) - return - } -} - -// TIP: ==== TERRAFORM IMPORTING ==== -// If Read can get all the information it needs from the Identifier -// (i.e., path.Root("id")), you can use the PassthroughID importer. Otherwise, -// you'll need a custom import function. -// -// See more: -// https://developer.hashicorp.com/terraform/plugin/framework/resources/import -func (r *resourceNetworkPeeringConnection) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resource.ImportStatePassthroughID(ctx, path.Root(names.AttrID), req, resp) -} - -// TIP: ==== WAITERS ==== -// Some resources of some services have waiters provided by the AWS API. -// Unless they do not work properly, use them rather than defining new ones -// here. -// -// Sometimes we define the wait, status, and find functions in separate -// files, wait.go, status.go, and find.go. Follow the pattern set out in the -// service and define these where it makes the most sense. -// -// If these functions are used in the _test.go file, they will need to be -// exported (i.e., capitalized). -// -// You will need to adjust the parameters and names to fit the service. -func waitNetworkPeeringConnectionCreated(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.OdbPeeringConnection, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusProvisioning), - Target: enum.Slice(odbtypes.ResourceStatusAvailable, odbtypes.ResourceStatusFailed), - Refresh: statusNetworkPeeringConnection(ctx, conn, id), - Timeout: timeout, - NotFoundChecks: 20, - ContinuousTargetOccurence: 2, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.OdbPeeringConnection); ok { - return out, err - } - - return nil, err -} - -func waitNetworkPeeringConnectionUpdated(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.OdbPeeringConnection, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusUpdating), - Target: enum.Slice(odbtypes.ResourceStatusAvailable, odbtypes.ResourceStatusFailed), - Refresh: statusNetworkPeeringConnection(ctx, conn, id), - Timeout: timeout, - NotFoundChecks: 20, - ContinuousTargetOccurence: 2, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.OdbPeeringConnection); ok { - return out, err - } - - return nil, err -} - -// TIP: A deleted waiter is almost like a backwards created waiter. There may -// be additional pending states, however. -func waitNetworkPeeringConnectionDeleted(ctx context.Context, conn *odb.Client, id string, timeout time.Duration) (*odbtypes.OdbPeeringConnection, error) { - stateConf := &retry.StateChangeConf{ - Pending: enum.Slice(odbtypes.ResourceStatusTerminating), - Target: []string{}, - Refresh: statusNetworkPeeringConnection(ctx, conn, id), - Timeout: timeout, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - if out, ok := outputRaw.(*odbtypes.OdbPeeringConnection); ok { - return out, err - } - - return nil, err -} - -// TIP: ==== STATUS ==== -// The status function can return an actual status when that field is -// available from the API (e.g., out.Status). Otherwise, you can use custom -// statuses to communicate the states of the resource. -// -// Waiters consume the values returned by status functions. Design status so -// that it can be reused by a create, update, and delete waiter, if possible. -func statusNetworkPeeringConnection(ctx context.Context, conn *odb.Client, id string) retry.StateRefreshFunc { - return func() (any, string, error) { - out, err := findNetworkPeeringConnectionByID(ctx, conn, id) - if tfresource.NotFound(err) { - return nil, "", nil - } - - if err != nil { - return nil, "", err - } - - return out, string(out.Status), nil - } -} - -// TIP: ==== FINDERS ==== -// The find function is not strictly necessary. You could do the API -// request from the status function. However, we have found that find often -// comes in handy in other places besides the status function. As a result, it -// is good practice to define it separately. -func findNetworkPeeringConnectionByID(ctx context.Context, conn *odb.Client, id string) (*odbtypes.OdbPeeringConnection, error) { - input := odb.GetOdbPeeringConnectionInput{ - OdbPeeringConnectionId: &id, - } - - out, err := conn.GetOdbPeeringConnection(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - - return nil, err - } - - if out == nil || out.OdbPeeringConnection == nil { - return nil, tfresource.NewEmptyResultError(&input) - } - - return out.OdbPeeringConnection, nil -} - -// TIP: ==== DATA STRUCTURES ==== -// With Terraform Plugin-Framework configurations are deserialized into -// Go types, providing type safety without the need for type assertions. -// These structs should match the schema definition exactly, and the `tfsdk` -// tag value should match the attribute name. -// -// Nested objects are represented in their own basicExaInfraDataSource struct. These will -// also have a corresponding attribute type mapping for use inside flex -// functions. -// -// See more: -// https://developer.hashicorp.com/terraform/plugin/framework/handling-data/accessing-values -type odbNetworkPeeringConnectionResourceModel struct { - framework.WithRegionModel - OdbNetworkId types.String `tfsdk:"odb_network_id"` - PeerNetworkId types.String `tfsdk:"peer_network_id"` - OdbPeeringConnectionId types.String `tfsdk:"id"` - DisplayName types.String `tfsdk:"display_name"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - OdbPeeringConnectionArn types.String `tfsdk:"arn"` - OdbNetworkArn types.String `tfsdk:"odb_network_arn"` - PeerNetworkArn types.String `tfsdk:"peer_network_arn"` - OdbPeeringConnectionType types.String `tfsdk:"odb_peering_connection_type"` - CreatedAt types.String `tfsdk:"created_at"` - PercentProgress types.Float32 `tfsdk:"percent_progress"` - Timeouts timeouts.Value `tfsdk:"timeouts"` - Tags tftags.Map `tfsdk:"tags"` - TagsAll tftags.Map `tfsdk:"tags_all"` -} - -// TIP: ==== SWEEPERS ==== -// When acceptance testing resources, interrupted or failed tests may -// leave behind orphaned resources in an account. To facilitate cleaning -// up lingering resources, each resource implementation should include -// a corresponding "sweeper" function. -// -// The sweeper function lists all resources of a given type and sets the -// appropriate identifers required to delete the resource via the Delete -// method implemented above. -// -// Once the sweeper function is implemented, register it in sweeper.go -// as follows: -// -// awsv2.Register("aws_odb_network_peering_connection", sweepNetworkPeeringConnections) -// -// See more: -// https://hashicorp.github.io/terraform-provider-aws/running-and-writing-acceptance-tests/#acceptance-test-sweepers -func sweepNetworkPeeringConnections(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) { - input := odb.ListOdbPeeringConnectionsInput{} - conn := client.ODBClient(ctx) - var sweepResources []sweep.Sweepable - - pages := odb.NewListOdbPeeringConnectionsPaginator(conn, &input) - for pages.HasMorePages() { - page, err := pages.NextPage(ctx) - if err != nil { - return nil, err - } - - for _, v := range page.OdbPeeringConnections { - sweepResources = append(sweepResources, sweepfw.NewSweepResource(newResourceNetworkPeeringConnection, client, - sweepfw.NewAttribute(names.AttrID, aws.ToString(v.OdbPeeringConnectionId))), - ) - } - } - - return sweepResources, nil -} diff --git a/internal/service/odb/network_peering_connection_data_source.go b/internal/service/odb/network_peering_connection_data_source.go deleted file mode 100644 index 4afce23fad10..000000000000 --- a/internal/service/odb/network_peering_connection_data_source.go +++ /dev/null @@ -1,140 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "time" - - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_network_peering_connection", name="Network Peering Connection") -func newDataSourceNetworkPeeringConnection(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceNetworkPeeringConnection{}, nil -} - -const ( - DSNameNetworkPeeringConnection = "Network Peering Connection Data Source" -) - -type dataSourceNetworkPeeringConnection struct { - framework.DataSourceWithModel[odbNetworkPeeringConnectionDataSourceModel] -} - -func (d *dataSourceNetworkPeeringConnection) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - names.AttrID: schema.StringAttribute{ - Description: "Network Peering Connection identifier.", - Required: true, - }, - "display_name": schema.StringAttribute{ - Description: "Display name of the odb network peering connection.", - Computed: true, - }, - "status": schema.StringAttribute{ - Description: "Status of the odb network peering connection.", - CustomType: fwtypes.StringEnumType[odbtypes.ResourceStatus](), - Computed: true, - }, - "status_reason": schema.StringAttribute{ - Description: "Status of the odb network peering connection.", - Computed: true, - }, - - "odb_network_arn": schema.StringAttribute{ - Description: "ARN of the odb network peering connection.", - Computed: true, - }, - - names.AttrARN: framework.ARNAttributeComputedOnly(), - - "peer_network_arn": schema.StringAttribute{ - Description: "ARN of the peer network peering connection.", - Computed: true, - }, - "odb_peering_connection_type": schema.StringAttribute{ - Description: "Type of the odb peering connection.", - Computed: true, - }, - "created_at": schema.StringAttribute{ - Description: "Created time of the odb network peering connection.", - Computed: true, - }, - "percent_progress": schema.Float32Attribute{ - Description: "Progress of the odb network peering connection.", - Computed: true, - }, - names.AttrTags: tftags.TagsAttributeComputedOnly(), - }, - } -} - -func (d *dataSourceNetworkPeeringConnection) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - var data odbNetworkPeeringConnectionDataSourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - input := odb.GetOdbPeeringConnectionInput{ - OdbPeeringConnectionId: data.OdbPeeringConnectionId.ValueStringPointer(), - } - out, err := conn.GetOdbPeeringConnection(ctx, &input) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameNetworkPeeringConnection, data.OdbPeeringConnectionId.ValueString(), err), - err.Error(), - ) - return - } - tagsRead, err := listTags(ctx, conn, *out.OdbPeeringConnection.OdbPeeringConnectionArn) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameNetworkPeeringConnection, data.OdbPeeringConnectionId.ValueString(), err), - err.Error(), - ) - return - } - if tagsRead != nil { - data.Tags = tftags.FlattenStringValueMap(ctx, tagsRead.Map()) - } - if out.OdbPeeringConnection.CreatedAt != nil { - data.CreatedAt = types.StringValue(out.OdbPeeringConnection.CreatedAt.Format(time.RFC3339)) - } - resp.Diagnostics.Append(flex.Flatten(ctx, out.OdbPeeringConnection, &data, flex.WithIgnoredFieldNamesAppend("CreatedAt"))...) - if resp.Diagnostics.HasError() { - return - } - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type odbNetworkPeeringConnectionDataSourceModel struct { - framework.WithRegionModel - OdbPeeringConnectionId types.String `tfsdk:"id"` - DisplayName types.String `tfsdk:"display_name"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - OdbPeeringConnectionArn types.String `tfsdk:"arn"` - OdbNetworkArn types.String `tfsdk:"odb_network_arn"` - PeerNetworkArn types.String `tfsdk:"peer_network_arn"` - OdbPeeringConnectionType types.String `tfsdk:"odb_peering_connection_type"` - CreatedAt types.String `tfsdk:"created_at"` - PercentProgress types.Float32 `tfsdk:"percent_progress"` - Tags tftags.Map `tfsdk:"tags"` -} diff --git a/internal/service/odb/network_peering_connection_data_source_test.go b/internal/service/odb/network_peering_connection_data_source_test.go deleted file mode 100644 index ec8c0b0268ee..000000000000 --- a/internal/service/odb/network_peering_connection_data_source_test.go +++ /dev/null @@ -1,212 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "github.com/hashicorp/terraform-provider-aws/names" - "testing" -) - -type odbPeeringDataSourceTest struct { - odbNetDisplayNamePrefix string - odbNetworkPeeringDisplayNamePrefix string - vpcNamePrefix string -} - -var odbPeeringDSTest = odbPeeringDataSourceTest{ - odbNetDisplayNamePrefix: "tf", - odbNetworkPeeringDisplayNamePrefix: "tf", - vpcNamePrefix: "tf", -} - -func TestPrintOdbPeeringResourceUnitTest(t *testing.T) { - odbNetDispName := sdkacctest.RandomWithPrefix(odbPeeringDSTest.odbNetDisplayNamePrefix) - odbNetPeeringDisplayName := sdkacctest.RandomWithPrefix(odbPeeringDSTest.odbNetworkPeeringDisplayNamePrefix) - //vpcNamePrefix := sdkacctest.RandomWithPrefix(odbPeeringDSTest.vpcNamePrefix) - - fmt.Println(odbPeeringDSTest.basicVpcHardCoded("vpc-084bc7dd335e156cc", odbNetDispName, odbNetPeeringDisplayName)) -} - -// Acceptance test access AWS and cost money to run. -func TestAccODBNetworkPeeringConnectionDataSource_basic(t *testing.T) { - - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - networkPeeringResource := "aws_odb_network_peering_connection.test" - networkPerringDataSource := "data.aws_odb_network_peering_connection.test" - odbNetPeeringDisplayName := sdkacctest.RandomWithPrefix(odbPeeringDSTest.odbNetworkPeeringDisplayNamePrefix) - //odbNetDispName := sdkacctest.RandomWithPrefix(odbPeeringDSTest.odbNetDisplayNamePrefix) - //vpcName := sdkacctest.RandomWithPrefix(odbPeeringDSTest.vpcNamePrefix) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: odbPeeringDSTest.testAccCheckCloudOdbNetworkPeeringDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: odbPeeringDSTest.basicHardCoded("vpc-084bc7dd335e156cc", "odbnet_c91byo6y6m", odbNetPeeringDisplayName), - - //odbPeeringDSTest.basicPeeringConfig(vpcName, odbNetDispName, odbNetPeeringDisplayName), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrPair(networkPeeringResource, "id", networkPerringDataSource, "id"), - ), - }, - }, - }) -} - -func (odbPeeringDataSourceTest) testAccCheckCloudOdbNetworkPeeringDestroy(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_network_peering_connection" { - continue - } - _, err := odbPeeringDSTest.findOdbPeering(ctx, conn, rs.Primary.ID) - - if err != nil { - if tfresource.NotFound(err) { - return nil - } - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.DSNameNetworkPeeringConnection, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameCloudExadataInfrastructure, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} - -func (odbPeeringDataSourceTest) findOdbPeering(ctx context.Context, conn *odb.Client, id string) (output *odb.GetOdbPeeringConnectionOutput, err error) { - input := odb.GetOdbPeeringConnectionInput{ - OdbPeeringConnectionId: &id, - } - out, err := conn.GetOdbPeeringConnection(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - - return nil, err - } - if out == nil { - return nil, errors.New("odb Network Peering Connection resource can not be nil") - } - return out, nil -} -func (odbPeeringDataSourceTest) basicPeeringConfig(vpcName, odbNetDisplayName, odbPeeringDisplayName string) string { - - testData := fmt.Sprintf(` - -resource "aws_vpc" "test" { - cidr_block = "10.0.0.0/16" - instance_tenancy = "default" - - tags = { - Name = %[1]q - } -} - -resource "aws_odb_network" "test" { - display_name = %[2]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" -} - -resource "aws_odb_network_peering_connection" "test" { - display_name = %[3]q - odb_network_id = aws_odb_network.test.id - peer_network_id = aws_vpc.test.id - -} - -data "aws_odb_network_peering_connection" "test" { - id=aws_odb_network_peering_connection.test.id -} - -`, vpcName, odbNetDisplayName, odbPeeringDisplayName) - //fmt.Println(testData) - return testData -} - -func (odbPeeringDataSourceTest) basicVpcHardCoded(vpcName, odbNetDisplayName, odbPeeringDisplayName string) string { - - testData := fmt.Sprintf(` - - -resource "aws_odb_network" "test" { - display_name = %[2]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" -} - - -resource "aws_odb_network_peering_connection" "test" { - peer_network_id = %[1]q - odb_network_id = aws_odb_network.test.id - display_name = %[3]q - -} - -data "aws_odb_network_peering_connection" "test" { - id=aws_odb_network_peering_connection.test.id -} - -`, vpcName, odbNetDisplayName, odbPeeringDisplayName) - //fmt.Println(testData) - return testData -} - -func (odbPeeringDataSourceTest) basicHardCoded(vpcName, odbNetDisplayName, odbPeeringDisplayName string) string { - - testData := fmt.Sprintf(` - - - - -resource "aws_odb_network_peering_connection" "test" { - peer_network_id = %[1]q - odb_network_id = %[2]q - display_name = %[3]q - -} - -data "aws_odb_network_peering_connection" "test" { - id=aws_odb_network_peering_connection.test.id -} - -`, vpcName, odbNetDisplayName, odbPeeringDisplayName) - //fmt.Println(testData) - return testData -} diff --git a/internal/service/odb/network_peering_connection_test.go b/internal/service/odb/network_peering_connection_test.go deleted file mode 100644 index 7d4714930f90..000000000000 --- a/internal/service/odb/network_peering_connection_test.go +++ /dev/null @@ -1,335 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "testing" - - "github.com/aws/aws-sdk-go-v2/service/odb" - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/names" - - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" -) - -type odbNwkPeeringResourceTest struct { - vpcNamePrefix string - odbPeeringDisplayNamePrefix string - odbNwkDisplayNamePrefix string -} - -var odbPeeringTestResource = odbNwkPeeringResourceTest{ - vpcNamePrefix: "vpc", - odbPeeringDisplayNamePrefix: "odb-peering", - odbNwkDisplayNamePrefix: "odb-net", -} - -func TestAccODBNetworkPeeringConnection_basic(t *testing.T) { - ctx := acctest.Context(t) - - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var odbPeeringResource odb.GetOdbPeeringConnectionOutput - odbPeeringDisplayName := sdkacctest.RandomWithPrefix(odbPeeringTestResource.odbPeeringDisplayNamePrefix) - vpcName := sdkacctest.RandomWithPrefix(odbPeeringTestResource.vpcNamePrefix) - odbNetName := sdkacctest.RandomWithPrefix(odbPeeringTestResource.odbNwkDisplayNamePrefix) - resourceName := "aws_odb_network_peering_connection.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //acctest.PreCheckPartitionHasService(t, names.ODBEndpointID) - odbPeeringTestResource.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: odbPeeringTestResource.testAccCheckNetworkPeeringConnectionDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: odbPeeringTestResource.basicConfig(vpcName, odbNetName, odbPeeringDisplayName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckNetworkPeeringConnectionExists(ctx, resourceName, &odbPeeringResource), - resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), - resource.TestCheckResourceAttr(resourceName, "tags.env", "dev"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBNetworkPeeringConnectionAddRemoveTag(t *testing.T) { - ctx := acctest.Context(t) - - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var odbPeeringResource odb.GetOdbPeeringConnectionOutput - odbPeeringDisplayName := sdkacctest.RandomWithPrefix(odbPeeringTestResource.odbPeeringDisplayNamePrefix) - //vpcName := sdkacctest.RandomWithPrefix(odbPeeringTestResource.vpcNamePrefix) - odbNetName := sdkacctest.RandomWithPrefix(odbPeeringTestResource.odbNwkDisplayNamePrefix) - resourceName := "aws_odb_network_peering_connection.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //acctest.PreCheckPartitionHasService(t, names.ODBEndpointID) - odbPeeringTestResource.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: odbPeeringTestResource.testAccCheckNetworkPeeringConnectionDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: odbPeeringTestResource.basicConfigWithVPC("vpc-084bc7dd335e156cc", odbNetName, odbPeeringDisplayName), - //odbPeeringTestResource.basicConfig(vpcName, odbNetName, odbPeeringDisplayName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckNetworkPeeringConnectionExists(ctx, resourceName, &odbPeeringResource), - resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), - resource.TestCheckResourceAttr(resourceName, "tags.env", "dev"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - { - Config: odbPeeringTestResource.basicConfigWithVPCWithNoTag("vpc-084bc7dd335e156cc", odbNetName, odbPeeringDisplayName), - //odbPeeringTestResource.basicConfig(vpcName, odbNetName, odbPeeringDisplayName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckNetworkPeeringConnectionExists(ctx, resourceName, &odbPeeringResource), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBNetworkPeeringConnection_disappears(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var odbPeering odb.GetOdbPeeringConnectionOutput - odbPeeringDisplayName := sdkacctest.RandomWithPrefix(odbPeeringTestResource.odbPeeringDisplayNamePrefix) - vpcName := sdkacctest.RandomWithPrefix(odbPeeringTestResource.vpcNamePrefix) - odbNetDisplayName := sdkacctest.RandomWithPrefix(odbPeeringTestResource.odbPeeringDisplayNamePrefix) - resourceName := "aws_odb_network_peering_connection.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //acctest.PreCheckPartitionHasService(t, names.ODBEndpointID) - odbPeeringTestResource.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - //CheckDestroy: odbPeeringTestResource.testAccCheckNetworkPeeringConnectionDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: odbPeeringTestResource.basicConfig(vpcName, odbNetDisplayName, odbPeeringDisplayName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckNetworkPeeringConnectionExists(ctx, resourceName, &odbPeering), - - //acctest.CheckFrameworkResourceDisappears(ctx, acctest.Provider, tfodb.odbPeering, resourceName), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func (odbNwkPeeringResourceTest) testAccCheckNetworkPeeringConnectionDestroy(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_network_peering_connection" { - continue - } - - _, err := odbPeeringTestResource.findOdbPeering(ctx, conn, rs.Primary.ID) - if tfresource.NotFound(err) { - return nil - } - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameNetworkPeeringConnection, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameNetworkPeeringConnection, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} - -func testAccCheckNetworkPeeringConnectionExists(ctx context.Context, name string, odbPeeringConnection *odb.GetOdbPeeringConnectionOutput) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameNetworkPeeringConnection, name, errors.New("not found")) - } - - if rs.Primary.ID == "" { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameNetworkPeeringConnection, name, errors.New("not set")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - resp, err := odbPeeringTestResource.findOdbPeering(ctx, conn, rs.Primary.ID) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameNetworkPeeringConnection, rs.Primary.ID, err) - } - - *odbPeeringConnection = *resp - - return nil - } -} - -func (odbNwkPeeringResourceTest) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListOdbPeeringConnectionsInput{} - - _, err := conn.ListOdbPeeringConnections(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} - -/*func testAccCheckNetworkPeeringConnectionNotRecreated(before, after *odb.GetOdbPeeringConnectionOutput) resource.TestCheckFunc { - return func(s *terraform.State) error { - if before, after := aws.ToString(before.NetworkPeeringConnectionId), aws.ToString(after.NetworkPeeringConnectionId); before != after { - return create.Error(names.ODB, create.ErrActionCheckingNotRecreated, tfodb.ResNameNetworkPeeringConnection, aws.ToString(before.NetworkPeeringConnectionId), errors.New("recreated")) - } - - return nil - } -}*/ - -func (odbNwkPeeringResourceTest) findOdbPeering(ctx context.Context, conn *odb.Client, id string) (output *odb.GetOdbPeeringConnectionOutput, err error) { - input := odb.GetOdbPeeringConnectionInput{ - OdbPeeringConnectionId: &id, - } - out, err := conn.GetOdbPeeringConnection(ctx, &input) - if err != nil { - if errs.IsA[*odbtypes.ResourceNotFoundException](err) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: &input, - } - } - return nil, err - } - if out == nil { - return nil, errors.New("odb Network Peering Connection resource can not be nil") - } - return out, nil -} - -func (odbNwkPeeringResourceTest) basicConfig(vpcName, odbNetName, odbPeeringName string) string { - return fmt.Sprintf(` -resource "aws_vpc" "test" { - cidr_block = "10.0.0.0/16" - instance_tenancy = "default" - - tags = { - Name = %[1]q - } -} - -resource "aws_odb_network" "test" { - display_name = %[2]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" -} - -resource "aws_odb_network_peering_connection" "test" { - display_name = %[3]q - odb_network_id = aws_odb_network.test.id - peer_network_id = aws_vpc.test.id - tags = { - "env"="dev" - } -} -`, vpcName, odbNetName, odbPeeringName) -} - -func (odbNwkPeeringResourceTest) basicConfigWithVPC(vpcName, odbNetName, odbPeeringName string) string { - return fmt.Sprintf(` - - -resource "aws_odb_network" "test" { - display_name = %[2]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" -} - -resource "aws_odb_network_peering_connection" "test" { - display_name = %[3]q - odb_network_id = aws_odb_network.test.id - peer_network_id = %[1]q - tags = { - "env"="dev" - } -} -`, vpcName, odbNetName, odbPeeringName) -} - -func (odbNwkPeeringResourceTest) basicConfigWithVPCWithNoTag(vpcName, odbNetName, odbPeeringName string) string { - return fmt.Sprintf(` - - -resource "aws_odb_network" "test" { - display_name = %[2]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" -} - -resource "aws_odb_network_peering_connection" "test" { - display_name = %[3]q - odb_network_id = aws_odb_network.test.id - peer_network_id = %[1]q -} -`, vpcName, odbNetName, odbPeeringName) -} diff --git a/internal/service/odb/network_peering_connections_list_data_source.go b/internal/service/odb/network_peering_connections_list_data_source.go deleted file mode 100644 index b2a884b90ec2..000000000000 --- a/internal/service/odb/network_peering_connections_list_data_source.go +++ /dev/null @@ -1,144 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_network_peering_connections_list", name="Network Peering Connections List") -func newDataSourceNetworkPeeringConnectionsList(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceNetworkPeeringConnectionsList{}, nil -} - -const ( - DSNameNetworkPeeringConnectionsList = "Network Peering Connections List Data Source" -) - -type dataSourceNetworkPeeringConnectionsList struct { - framework.DataSourceWithModel[odbNetworkPeeringConnectionsListDataSourceModel] -} - -func (d *dataSourceNetworkPeeringConnectionsList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{}, - Blocks: map[string]schema.Block{ - "odb_peering_connections": schema.ListNestedBlock{ - Description: " The list of ODB peering connections. A summary of an ODB peering connection.", - CustomType: fwtypes.NewListNestedObjectTypeOf[odbNetworkPeeringConnectionSummaryDataSourceModel](ctx), - NestedObject: schema.NestedBlockObject{ - Attributes: map[string]schema.Attribute{ - names.AttrID: schema.StringAttribute{ - Computed: true, - Description: "ID of the network peering connection.", - }, - - "display_name": schema.StringAttribute{ - Computed: true, - Description: "Display name for the network peering connection.", - }, - "status": schema.StringAttribute{ - Computed: true, - CustomType: fwtypes.StringEnumType[odbtypes.ResourceStatus](), - Description: "Status of this network peering connection.", - }, - "status_reason": schema.StringAttribute{ - Computed: true, - Description: "Status reason of this network peering connection.", - }, - names.AttrARN: framework.ARNAttributeComputedOnly(), - "odb_network_arn": schema.StringAttribute{ - Computed: true, - Description: "The ARN of the ODB network peering connection.", - }, - "odb_peering_connection_type": schema.StringAttribute{ - Computed: true, - Description: "The type of the ODB peering connection.", - }, - "percent_progress": schema.Float32Attribute{ - Computed: true, - Description: "The percentage of progress made in network peering .", - }, - }, - }, - }, - }, - } -} - -func (d *dataSourceNetworkPeeringConnectionsList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - - var data odbNetworkPeeringConnectionsListDataSourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := conn.ListOdbPeeringConnections(ctx, &odb.ListOdbPeeringConnectionsInput{}) - listOfPeerConnections := make([]peeringConnectionSummaryRead, 0) - if err == nil && out.OdbPeeringConnections != nil { - for _, peerConn := range out.OdbPeeringConnections { - peerConnSummary := peeringConnectionSummaryRead{ - OdbPeeringConnectionId: peerConn.OdbPeeringConnectionId, - DisplayName: peerConn.DisplayName, - OdbNetworkArn: peerConn.OdbNetworkArn, - OdbPeeringConnectionArn: peerConn.OdbPeeringConnectionArn, - OdbPeeringConnectionType: peerConn.OdbPeeringConnectionType, - PeerNetworkArn: peerConn.PeerNetworkArn, - PercentProgress: peerConn.PercentProgress, - Status: peerConn.Status, - StatusReason: peerConn.StatusReason, - } - listOfPeerConnections = append(listOfPeerConnections, peerConnSummary) - } - resp.Diagnostics.Append(flex.Flatten(ctx, listOdbPeeringConnectionsOutputRead{ - OdbPeeringConnections: listOfPeerConnections, - }, &data)...) - if resp.Diagnostics.HasError() { - return - - } - } - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type odbNetworkPeeringConnectionsListDataSourceModel struct { - framework.WithRegionModel - OdbPeeringConnections fwtypes.ListNestedObjectValueOf[odbNetworkPeeringConnectionSummaryDataSourceModel] `tfsdk:"odb_peering_connections"` -} -type odbNetworkPeeringConnectionSummaryDataSourceModel struct { - OdbPeeringConnectionId types.String `tfsdk:"id"` - DisplayName types.String `tfsdk:"display_name"` - Status fwtypes.StringEnum[odbtypes.ResourceStatus] `tfsdk:"status"` - StatusReason types.String `tfsdk:"status_reason"` - OdbPeeringConnectionArn types.String `tfsdk:"arn"` - OdbNetworkArn types.String `tfsdk:"odb_network_arn"` - OdbPeeringConnectionType types.String `tfsdk:"odb_peering_connection_type"` - PercentProgress types.Float32 `tfsdk:"percent_progress"` -} -type peeringConnectionSummaryRead struct { - OdbPeeringConnectionId *string - DisplayName *string - OdbNetworkArn *string - OdbPeeringConnectionArn *string - OdbPeeringConnectionType *string - PeerNetworkArn *string - PercentProgress *float32 - Status odbtypes.ResourceStatus - StatusReason *string -} -type listOdbPeeringConnectionsOutputRead struct { - OdbPeeringConnections []peeringConnectionSummaryRead -} diff --git a/internal/service/odb/network_peering_connections_list_data_source_test.go b/internal/service/odb/network_peering_connections_list_data_source_test.go deleted file mode 100644 index aa1a6bfced24..000000000000 --- a/internal/service/odb/network_peering_connections_list_data_source_test.go +++ /dev/null @@ -1,101 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/create" - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "strconv" - "testing" - - "github.com/aws/aws-sdk-go-v2/service/odb" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - - "github.com/hashicorp/terraform-provider-aws/names" -) - -type listOdbNetworkPeering struct { -} - -func TestAccODBNetworkPeeringBasic(t *testing.T) { - ctx := acctest.Context(t) - var listOfPeeredNwks = listOdbNetworkPeering{} - var output odb.ListOdbPeeringConnectionsOutput - - dataSourceName := "data.aws_odb_network_peering_connections_list.test" - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - listOfPeeredNwks.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - Steps: []resource.TestStep{ - { - Config: listOfPeeredNwks.basic(), - Check: resource.ComposeAggregateTestCheckFunc( - - resource.ComposeTestCheckFunc(func(s *terraform.State) error { - listOfPeeredNwks.count(ctx, dataSourceName, &output) - resource.TestCheckResourceAttr(dataSourceName, "odb_peering_connections.#", strconv.Itoa(len(output.OdbPeeringConnections))) - return nil - }, - ), - ), - }, - }, - }) -} - -func (listOdbNetworkPeering) basic() string { - config := fmt.Sprintf(` - - -data "aws_odb_network_peering_connections_list" "test" { - -} -`) - return config -} - -func (listOdbNetworkPeering) count(ctx context.Context, name string, list *odb.ListOdbPeeringConnectionsOutput) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, name, errors.New("not found")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - resp, err := conn.ListOdbPeeringConnections(ctx, &odb.ListOdbPeeringConnectionsInput{}) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, rs.Primary.ID, err) - } - - list.OdbPeeringConnections = resp.OdbPeeringConnections - - return nil - } -} -func (listOdbNetworkPeering) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListOdbPeeringConnectionsInput{} - - _, err := conn.ListOdbPeeringConnections(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} diff --git a/internal/service/odb/network_test.go b/internal/service/odb/network_test.go deleted file mode 100644 index e5864fb21190..000000000000 --- a/internal/service/odb/network_test.go +++ /dev/null @@ -1,449 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "github.com/aws/aws-sdk-go-v2/service/odb" - odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types" - sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "github.com/hashicorp/terraform-provider-aws/names" - "strings" - "testing" - - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" -) - -type odbNetworkResourceTest struct { - displayNamePrefix string -} - -var odbNetResourceTest = odbNetworkResourceTest{ - displayNamePrefix: "tf-odb-net", -} - -// Basic test with bare minimum input -func TestOdbNetworkBasic(t *testing.T) { - ctx := acctest.Context(t) - // TIP: This is a long-running test guard for tests that run longer than - // 300s (5 min) generally. - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var network odbtypes.OdbNetwork - rName := sdkacctest.RandomWithPrefix(odbNetResourceTest.displayNamePrefix) - resourceName := "aws_odb_network.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: odbNetResourceTest.testAccCheckNetworkDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: odbNetResourceTest.basicOdbNetwork(rName), - Check: resource.ComposeAggregateTestCheckFunc( - odbNetResourceTest.testAccCheckNetworkExists(ctx, resourceName, &network), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestOdbNetworkWithAllParams(t *testing.T) { - ctx := acctest.Context(t) - - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var network odbtypes.OdbNetwork - rName := sdkacctest.RandomWithPrefix(odbNetResourceTest.displayNamePrefix) - resourceName := "aws_odb_network.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - odbNetResourceTest.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: odbNetResourceTest.testAccCheckNetworkDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: odbNetResourceTest.odbNetworkWithAllParams(rName, "julia.com"), - Check: resource.ComposeAggregateTestCheckFunc( - odbNetResourceTest.testAccCheckNetworkExists(ctx, resourceName, &network), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBNetworkUpdateManagedService(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var network1, network2 odbtypes.OdbNetwork - rName := sdkacctest.RandomWithPrefix(odbNetResourceTest.displayNamePrefix) - resourceName := "aws_odb_network.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - odbNetResourceTest.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: odbNetResourceTest.testAccCheckNetworkDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: odbNetResourceTest.basicOdbNetwork(rName), - Check: resource.ComposeAggregateTestCheckFunc( - odbNetResourceTest.testAccCheckNetworkExists(ctx, resourceName, &network1), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - { - Config: odbNetResourceTest.basicOdbNetworkWithActiveManagedService(rName), - Check: resource.ComposeAggregateTestCheckFunc( - odbNetResourceTest.testAccCheckNetworkExists(ctx, resourceName, &network2), - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - if strings.Compare(*(network1.OdbNetworkId), *(network2.OdbNetworkId)) != 0 { - return errors.New("should not create a new cloud odb network") - } - return nil - }), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBNetworkDisableManagedService(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var network1, network2 odbtypes.OdbNetwork - rName := sdkacctest.RandomWithPrefix(odbNetResourceTest.displayNamePrefix) - resourceName := "aws_odb_network.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - odbNetResourceTest.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: odbNetResourceTest.testAccCheckNetworkDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: odbNetResourceTest.basicOdbNetworkWithActiveManagedService(rName), - Check: resource.ComposeAggregateTestCheckFunc( - odbNetResourceTest.testAccCheckNetworkExists(ctx, resourceName, &network1), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - { - Config: odbNetResourceTest.basicOdbNetwork(rName), - Check: resource.ComposeAggregateTestCheckFunc( - odbNetResourceTest.testAccCheckNetworkExists(ctx, resourceName, &network2), - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - if strings.Compare(*(network1.OdbNetworkId), *(network2.OdbNetworkId)) != 0 { - return errors.New("should not create a new cloud odb network") - } - return nil - }), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBNetwork_Update_Tags(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var network1, network2 odbtypes.OdbNetwork - rName := sdkacctest.RandomWithPrefix(odbNetResourceTest.displayNamePrefix) - resourceName := "aws_odb_network.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - //acctest.PreCheckPartitionHasService(t, names.ODBEndpointID) - odbNetResourceTest.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: odbNetResourceTest.testAccCheckNetworkDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: odbNetResourceTest.basicOdbNetwork(rName), - - Check: resource.ComposeAggregateTestCheckFunc( - odbNetResourceTest.testAccCheckNetworkExists(ctx, resourceName, &network1), - ), - }, - { - Config: odbNetResourceTest.updateOdbNetworkTags(rName), - Check: resource.ComposeAggregateTestCheckFunc( - odbNetResourceTest.testAccCheckNetworkExists(ctx, resourceName, &network2), - resource.ComposeTestCheckFunc(func(state *terraform.State) error { - if strings.Compare(*(network1.OdbNetworkId), *(network2.OdbNetworkId)) != 0 { - return errors.New("should not create a new cloud odb network") - } - return nil - }), - resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), - resource.TestCheckResourceAttr(resourceName, "tags.env", "dev"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccODBNetwork_disappears(t *testing.T) { - ctx := acctest.Context(t) - if testing.Short() { - t.Skip("skipping long-running test in short mode") - } - - var network odbtypes.OdbNetwork - rName := sdkacctest.RandomWithPrefix(odbNetResourceTest.displayNamePrefix) - resourceName := "aws_odb_network.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - odbNetResourceTest.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: odbNetResourceTest.testAccCheckNetworkDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: odbNetResourceTest.basicOdbNetwork(rName), - Check: resource.ComposeAggregateTestCheckFunc( - odbNetResourceTest.testAccCheckNetworkExists(ctx, resourceName, &network), - acctest.CheckFrameworkResourceDisappears(ctx, acctest.Provider, tfodb.OdbNetwork, resourceName), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - -func (odbNetworkResourceTest) testAccCheckNetworkDestroy(ctx context.Context) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "aws_odb_network" { - continue - } - - // TIP: ==== FINDERS ==== - // The find function should be exported. Since it won't be used outside of the package, it can be exported - // in the `exports_test.go` file. - _, err := tfodb.FindOdbNetworkByID(ctx, conn, rs.Primary.ID) - if tfresource.NotFound(err) { - return nil - } - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameNetwork, rs.Primary.ID, err) - } - - return create.Error(names.ODB, create.ErrActionCheckingDestroyed, tfodb.ResNameNetwork, rs.Primary.ID, errors.New("not destroyed")) - } - - return nil - } -} - -func (odbNetworkResourceTest) testAccCheckNetworkExists(ctx context.Context, name string, network *odbtypes.OdbNetwork) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameNetwork, name, errors.New("not found")) - } - - if rs.Primary.ID == "" { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameNetwork, name, errors.New("not set")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - resp, err := tfodb.FindOdbNetworkByID(ctx, conn, rs.Primary.ID) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameNetwork, rs.Primary.ID, err) - } - - *network = *resp - - return nil - } -} - -func (odbNetworkResourceTest) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListOdbNetworksInput{} - - _, err := conn.ListOdbNetworks(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} - -/*func testAccCheckNetworkNotRecreated(before, after *odb.DescribeNetworkResponse) resource.TestCheckFunc { - return func(s *terraform.State) error { - if before, after := aws.ToString(before.NetworkId), aws.ToString(after.NetworkId); before != after { - return create.Error(names.ODB, create.ErrActionCheckingNotRecreated, tfodb.ResNameNetwork, aws.ToString(before.NetworkId), errors.New("recreated")) - } - - return nil - } -}*/ - -func (odbNetworkResourceTest) basicOdbNetwork(rName string) string { - networkRes := fmt.Sprintf(` - - -resource "aws_odb_network" "test" { - display_name = %[1]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" -} - -`, rName) - return networkRes -} - -func (odbNetworkResourceTest) basicOdbNetworkWithActiveManagedService(rName string) string { - networkRes := fmt.Sprintf(` - - -resource "aws_odb_network" "test" { - display_name = %[1]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "ENABLED" - zero_etl_access = "ENABLED" -} - -`, rName) - return networkRes -} - -func (odbNetworkResourceTest) odbNetworkWithAllParams(rName, customDomainName string) string { - networkRes := fmt.Sprintf(` - - -resource "aws_odb_network" "test" { - display_name = %[1]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" - custom_domain_name = %[2]q -} - -`, rName, customDomainName) - return networkRes -} - -func (odbNetworkResourceTest) updateOdbNetworkDisplayName(rName string) string { - networkRes := fmt.Sprintf(` - - -resource "aws_odb_network" "test" { - display_name = %[1]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" -} -`, rName) - return networkRes -} - -func (odbNetworkResourceTest) updateOdbNetworkTags(rName string) string { - networkRes := fmt.Sprintf(` - - -resource "aws_odb_network" "test" { - display_name = %[1]q - availability_zone_id = "use1-az6" - client_subnet_cidr = "10.2.0.0/24" - backup_subnet_cidr = "10.2.1.0/24" - s3_access = "DISABLED" - zero_etl_access = "DISABLED" - tags = { - "env"= "dev" - } -} -`, rName) - return networkRes -} diff --git a/internal/service/odb/networks_list_data_source.go b/internal/service/odb/networks_list_data_source.go deleted file mode 100644 index 5ebd6840caa9..000000000000 --- a/internal/service/odb/networks_list_data_source.go +++ /dev/null @@ -1,94 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "github.com/hashicorp/terraform-plugin-framework/attr" - - "github.com/aws/aws-sdk-go-v2/service/odb" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-aws/internal/create" - "github.com/hashicorp/terraform-provider-aws/internal/framework" - "github.com/hashicorp/terraform-provider-aws/internal/framework/flex" - fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// Function annotations are used for datasource registration to the Provider. DO NOT EDIT. -// @FrameworkDataSource("aws_odb_networks_list", name="Networks List") -func newDataSourceNetworksList(context.Context) (datasource.DataSourceWithConfigure, error) { - return &dataSourceNetworksList{}, nil -} - -const ( - DSNameNetworksList = "Networks List Data Source" -) - -type dataSourceNetworksList struct { - framework.DataSourceWithModel[odbNetworksListModel] -} - -func (d *dataSourceNetworksList) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "odb_networks": schema.ListAttribute{ - Computed: true, - Description: "List of odb networks (OCID, ID, ARN, OCI URL, Display Name)", - CustomType: fwtypes.NewListNestedObjectTypeOf[cloudAutonomousVmClusterSummary](ctx), - ElementType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "arn": types.StringType, - "id": types.StringType, - "oci_url": types.StringType, - "ocid": types.StringType, - "display_name": types.StringType, - }, - }, - }, - }, - } -} - -// Data sources only have a read method. -func (d *dataSourceNetworksList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - - conn := d.Meta().ODBClient(ctx) - - var data odbNetworksListModel - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - out, err := conn.ListOdbNetworks(ctx, &odb.ListOdbNetworksInput{}) - if err != nil { - resp.Diagnostics.AddError( - create.ProblemStandardMessage(names.ODB, create.ErrActionReading, DSNameNetworksList, "", err), - err.Error(), - ) - return - } - - resp.Diagnostics.Append(flex.Flatten(ctx, out, &data)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -type odbNetworksListModel struct { - framework.WithRegionModel - OdbNetworks fwtypes.ListNestedObjectValueOf[odbNetworkSummary] `tfsdk:"odb_networks"` -} - -type odbNetworkSummary struct { - CloudExadataInfrastructureArn types.String `tfsdk:"arn"` - CloudAutonomousVmClusterId types.String `tfsdk:"id"` - OciUrl types.String `tfsdk:"oci_url"` - Ocid types.String `tfsdk:"ocid"` - DisplayName types.String `tfsdk:"display_name"` -} diff --git a/internal/service/odb/networks_list_data_source_test.go b/internal/service/odb/networks_list_data_source_test.go deleted file mode 100644 index 77ce4b1b7836..000000000000 --- a/internal/service/odb/networks_list_data_source_test.go +++ /dev/null @@ -1,101 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "strconv" - - "testing" - - "github.com/aws/aws-sdk-go-v2/service/odb" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/acctest" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/create" - - tfodb "github.com/hashicorp/terraform-provider-aws/internal/service/odb" - "github.com/hashicorp/terraform-provider-aws/names" -) - -type odbNetworksListTestDS struct { -} - -func TestAccListOdbNetworksDataSource(t *testing.T) { - ctx := acctest.Context(t) - var networkListTest = odbNetworksListTestDS{} - var output odb.ListOdbNetworksOutput - - dataSourceName := "data.aws_odb_networks_list.test" - resource.Test(t, resource.TestCase{ - PreCheck: func() { - acctest.PreCheck(ctx, t) - networkListTest.testAccPreCheck(ctx, t) - }, - ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - Steps: []resource.TestStep{ - { - Config: networkListTest.basic(), - Check: resource.ComposeAggregateTestCheckFunc( - - resource.ComposeTestCheckFunc(func(s *terraform.State) error { - networkListTest.count(ctx, dataSourceName, &output) - resource.TestCheckResourceAttr(dataSourceName, "cloud_autonomous_vm_clusters.#", strconv.Itoa(len(output.OdbNetworks))) - return nil - }, - ), - ), - }, - }, - }) -} - -func (odbNetworksListTestDS) basic() string { - config := fmt.Sprintf(` - - -data "aws_odb_cloud_autonomous_vm_clusters_list" "test" { - -} -`) - return config -} - -func (odbNetworksListTestDS) count(ctx context.Context, name string, list *odb.ListOdbNetworksOutput) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[name] - if !ok { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, name, errors.New("not found")) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - resp, err := conn.ListOdbNetworks(ctx, &odb.ListOdbNetworksInput{}) - if err != nil { - return create.Error(names.ODB, create.ErrActionCheckingExistence, tfodb.ResNameCloudVmCluster, rs.Primary.ID, err) - } - - list.OdbNetworks = resp.OdbNetworks - - return nil - } -} -func (odbNetworksListTestDS) testAccPreCheck(ctx context.Context, t *testing.T) { - conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx) - - input := &odb.ListOdbNetworksInput{} - - _, err := conn.ListOdbNetworks(ctx, input) - - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} diff --git a/internal/service/odb/service_endpoint_resolver_gen.go b/internal/service/odb/service_endpoint_resolver_gen.go deleted file mode 100644 index 103f29abab6b..000000000000 --- a/internal/service/odb/service_endpoint_resolver_gen.go +++ /dev/null @@ -1,82 +0,0 @@ -// Code generated by internal/generate/servicepackage/main.go; DO NOT EDIT. - -package odb - -import ( - "context" - "fmt" - "net" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - smithyendpoints "github.com/aws/smithy-go/endpoints" - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-provider-aws/internal/errs" -) - -var _ odb.EndpointResolverV2 = resolverV2{} - -type resolverV2 struct { - defaultResolver odb.EndpointResolverV2 -} - -func newEndpointResolverV2() resolverV2 { - return resolverV2{ - defaultResolver: odb.NewDefaultEndpointResolverV2(), - } -} - -func (r resolverV2) ResolveEndpoint(ctx context.Context, params odb.EndpointParameters) (endpoint smithyendpoints.Endpoint, err error) { - params = params.WithDefaults() - useFIPS := aws.ToBool(params.UseFIPS) - - if eps := params.Endpoint; aws.ToString(eps) != "" { - tflog.Debug(ctx, "setting endpoint", map[string]any{ - "tf_aws.endpoint": endpoint, - }) - - if useFIPS { - tflog.Debug(ctx, "endpoint set, ignoring UseFIPSEndpoint setting") - params.UseFIPS = aws.Bool(false) - } - - return r.defaultResolver.ResolveEndpoint(ctx, params) - } else if useFIPS { - ctx = tflog.SetField(ctx, "tf_aws.use_fips", useFIPS) - - endpoint, err = r.defaultResolver.ResolveEndpoint(ctx, params) - if err != nil { - return endpoint, err - } - - tflog.Debug(ctx, "endpoint resolved", map[string]any{ - "tf_aws.endpoint": endpoint.URI.String(), - }) - - hostname := endpoint.URI.Hostname() - _, err = net.LookupHost(hostname) - if err != nil { - if dnsErr, ok := errs.As[*net.DNSError](err); ok && dnsErr.IsNotFound { - tflog.Debug(ctx, "default endpoint host not found, disabling FIPS", map[string]any{ - "tf_aws.hostname": hostname, - }) - params.UseFIPS = aws.Bool(false) - } else { - err = fmt.Errorf("looking up odb endpoint %q: %s", hostname, err) - return - } - } else { - return endpoint, err - } - } - - return r.defaultResolver.ResolveEndpoint(ctx, params) -} - -func withBaseEndpoint(endpoint string) func(*odb.Options) { - return func(o *odb.Options) { - if endpoint != "" { - o.BaseEndpoint = aws.String(endpoint) - } - } -} diff --git a/internal/service/odb/service_endpoints_gen_test.go b/internal/service/odb/service_endpoints_gen_test.go deleted file mode 100644 index bc88b1023c35..000000000000 --- a/internal/service/odb/service_endpoints_gen_test.go +++ /dev/null @@ -1,602 +0,0 @@ -// Code generated by internal/generate/serviceendpointtests/main.go; DO NOT EDIT. - -package odb_test - -import ( - "context" - "errors" - "fmt" - "maps" - "net" - "net/url" - "os" - "path/filepath" - "reflect" - "strings" - "testing" - - "github.com/aws/aws-sdk-go-v2/aws" - awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" - "github.com/aws/aws-sdk-go-v2/service/odb" - "github.com/aws/smithy-go/middleware" - smithyhttp "github.com/aws/smithy-go/transport/http" - "github.com/google/go-cmp/cmp" - "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/errs" - "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" - "github.com/hashicorp/terraform-provider-aws/internal/provider/sdkv2" - "github.com/hashicorp/terraform-provider-aws/names" -) - -type endpointTestCase struct { - with []setupFunc - expected caseExpectations -} - -type caseSetup struct { - config map[string]any - configFile configFile - environmentVariables map[string]string -} - -type configFile struct { - baseUrl string - serviceUrl string -} - -type caseExpectations struct { - diags diag.Diagnostics - endpoint string - region string -} - -type apiCallParams struct { - endpoint string - region string -} - -type setupFunc func(setup *caseSetup) - -type callFunc func(ctx context.Context, t *testing.T, meta *conns.AWSClient) apiCallParams - -const ( - packageNameConfigEndpoint = "https://packagename-config.endpoint.test/" - awsServiceEnvvarEndpoint = "https://service-envvar.endpoint.test/" - baseEnvvarEndpoint = "https://base-envvar.endpoint.test/" - serviceConfigFileEndpoint = "https://service-configfile.endpoint.test/" - baseConfigFileEndpoint = "https://base-configfile.endpoint.test/" -) - -const ( - packageName = "odb" - awsEnvVar = "AWS_ENDPOINT_URL_ODB" - baseEnvVar = "AWS_ENDPOINT_URL" - configParam = "odb" -) - -const ( - expectedCallRegion = "us-east-1" //lintignore:AWSAT003 -) - -func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.Setenv - ctx := t.Context() - const providerRegion = "us-west-2" //lintignore:AWSAT003 - const expectedEndpointRegion = providerRegion - - testcases := map[string]endpointTestCase{ - "no config": { - with: []setupFunc{withNoConfig}, - expected: expectDefaultEndpoint(ctx, t, expectedEndpointRegion), - }, - - // Package name endpoint on Config - - "package name endpoint config": { - with: []setupFunc{ - withPackageNameEndpointInConfig, - }, - expected: expectPackageNameConfigEndpoint(), - }, - - "package name endpoint config overrides aws service envvar": { - with: []setupFunc{ - withPackageNameEndpointInConfig, - withAwsEnvVar, - }, - expected: expectPackageNameConfigEndpoint(), - }, - - "package name endpoint config overrides base envvar": { - with: []setupFunc{ - withPackageNameEndpointInConfig, - withBaseEnvVar, - }, - expected: expectPackageNameConfigEndpoint(), - }, - - "package name endpoint config overrides service config file": { - with: []setupFunc{ - withPackageNameEndpointInConfig, - withServiceEndpointInConfigFile, - }, - expected: expectPackageNameConfigEndpoint(), - }, - - "package name endpoint config overrides base config file": { - with: []setupFunc{ - withPackageNameEndpointInConfig, - withBaseEndpointInConfigFile, - }, - expected: expectPackageNameConfigEndpoint(), - }, - - // Service endpoint in AWS envvar - - "service aws envvar": { - with: []setupFunc{ - withAwsEnvVar, - }, - expected: expectAwsEnvVarEndpoint(), - }, - - "service aws envvar overrides base envvar": { - with: []setupFunc{ - withAwsEnvVar, - withBaseEnvVar, - }, - expected: expectAwsEnvVarEndpoint(), - }, - - "service aws envvar overrides service config file": { - with: []setupFunc{ - withAwsEnvVar, - withServiceEndpointInConfigFile, - }, - expected: expectAwsEnvVarEndpoint(), - }, - - "service aws envvar overrides base config file": { - with: []setupFunc{ - withAwsEnvVar, - withBaseEndpointInConfigFile, - }, - expected: expectAwsEnvVarEndpoint(), - }, - - // Base endpoint in envvar - - "base endpoint envvar": { - with: []setupFunc{ - withBaseEnvVar, - }, - expected: expectBaseEnvVarEndpoint(), - }, - - "base endpoint envvar overrides service config file": { - with: []setupFunc{ - withBaseEnvVar, - withServiceEndpointInConfigFile, - }, - expected: expectBaseEnvVarEndpoint(), - }, - - "base endpoint envvar overrides base config file": { - with: []setupFunc{ - withBaseEnvVar, - withBaseEndpointInConfigFile, - }, - expected: expectBaseEnvVarEndpoint(), - }, - - // Service endpoint in config file - - "service config file": { - with: []setupFunc{ - withServiceEndpointInConfigFile, - }, - expected: expectServiceConfigFileEndpoint(), - }, - - "service config file overrides base config file": { - with: []setupFunc{ - withServiceEndpointInConfigFile, - withBaseEndpointInConfigFile, - }, - expected: expectServiceConfigFileEndpoint(), - }, - - // Base endpoint in config file - - "base endpoint config file": { - with: []setupFunc{ - withBaseEndpointInConfigFile, - }, - expected: expectBaseConfigFileEndpoint(), - }, - - // Use FIPS endpoint on Config - - "use fips config": { - with: []setupFunc{ - withUseFIPSInConfig, - }, - expected: expectDefaultFIPSEndpoint(ctx, t, expectedEndpointRegion), - }, - - "use fips config with package name endpoint config": { - with: []setupFunc{ - withUseFIPSInConfig, - withPackageNameEndpointInConfig, - }, - expected: expectPackageNameConfigEndpoint(), - }, - } - - for name, testcase := range testcases { //nolint:paralleltest // uses t.Setenv - t.Run(name, func(t *testing.T) { - testEndpointCase(ctx, t, providerRegion, testcase, callService) - }) - } -} - -func defaultEndpoint(ctx context.Context, region string) (url.URL, error) { - r := odb.NewDefaultEndpointResolverV2() - - ep, err := r.ResolveEndpoint(ctx, odb.EndpointParameters{ - Region: aws.String(region), - }) - if err != nil { - return url.URL{}, err - } - - if ep.URI.Path == "" { - ep.URI.Path = "/" - } - - return ep.URI, nil -} - -func defaultFIPSEndpoint(ctx context.Context, region string) (url.URL, error) { - r := odb.NewDefaultEndpointResolverV2() - - ep, err := r.ResolveEndpoint(ctx, odb.EndpointParameters{ - Region: aws.String(region), - UseFIPS: aws.Bool(true), - }) - if err != nil { - return url.URL{}, err - } - - if ep.URI.Path == "" { - ep.URI.Path = "/" - } - - return ep.URI, nil -} - -func callService(ctx context.Context, t *testing.T, meta *conns.AWSClient) apiCallParams { - t.Helper() - - client := meta.ODBClient(ctx) - - var result apiCallParams - - input := odb.ListCloudExadataInfrastructuresInput{} - _, err := client.ListCloudExadataInfrastructures(ctx, &input, - func(opts *odb.Options) { - opts.APIOptions = append(opts.APIOptions, - addRetrieveEndpointURLMiddleware(t, &result.endpoint), - addRetrieveRegionMiddleware(&result.region), - addCancelRequestMiddleware(), - ) - }, - ) - if err == nil { - t.Fatal("Expected an error, got none") - } else if !errors.Is(err, errCancelOperation) { - t.Fatalf("Unexpected error: %s", err) - } - - return result -} - -func withNoConfig(_ *caseSetup) { - // no-op -} - -func withPackageNameEndpointInConfig(setup *caseSetup) { - if _, ok := setup.config[names.AttrEndpoints]; !ok { - setup.config[names.AttrEndpoints] = []any{ - map[string]any{}, - } - } - endpoints := setup.config[names.AttrEndpoints].([]any)[0].(map[string]any) - endpoints[packageName] = packageNameConfigEndpoint -} - -func withAwsEnvVar(setup *caseSetup) { - setup.environmentVariables[awsEnvVar] = awsServiceEnvvarEndpoint -} - -func withBaseEnvVar(setup *caseSetup) { - setup.environmentVariables[baseEnvVar] = baseEnvvarEndpoint -} - -func withServiceEndpointInConfigFile(setup *caseSetup) { - setup.configFile.serviceUrl = serviceConfigFileEndpoint -} - -func withBaseEndpointInConfigFile(setup *caseSetup) { - setup.configFile.baseUrl = baseConfigFileEndpoint -} - -func withUseFIPSInConfig(setup *caseSetup) { - setup.config["use_fips_endpoint"] = true -} - -func expectDefaultEndpoint(ctx context.Context, t *testing.T, region string) caseExpectations { - t.Helper() - - endpoint, err := defaultEndpoint(ctx, region) - if err != nil { - t.Fatalf("resolving accessanalyzer default endpoint: %s", err) - } - - return caseExpectations{ - endpoint: endpoint.String(), - region: expectedCallRegion, - } -} - -func expectDefaultFIPSEndpoint(ctx context.Context, t *testing.T, region string) caseExpectations { - t.Helper() - - endpoint, err := defaultFIPSEndpoint(ctx, region) - if err != nil { - t.Fatalf("resolving accessanalyzer FIPS endpoint: %s", err) - } - - hostname := endpoint.Hostname() - _, err = net.LookupHost(hostname) - if dnsErr, ok := errs.As[*net.DNSError](err); ok && dnsErr.IsNotFound { - return expectDefaultEndpoint(ctx, t, region) - } else if err != nil { - t.Fatalf("looking up accessanalyzer endpoint %q: %s", hostname, err) - } - - return caseExpectations{ - endpoint: endpoint.String(), - region: expectedCallRegion, - } -} - -func expectPackageNameConfigEndpoint() caseExpectations { - return caseExpectations{ - endpoint: packageNameConfigEndpoint, - region: expectedCallRegion, - } -} - -func expectAwsEnvVarEndpoint() caseExpectations { - return caseExpectations{ - endpoint: awsServiceEnvvarEndpoint, - region: expectedCallRegion, - } -} - -func expectBaseEnvVarEndpoint() caseExpectations { - return caseExpectations{ - endpoint: baseEnvvarEndpoint, - region: expectedCallRegion, - } -} - -func expectServiceConfigFileEndpoint() caseExpectations { - return caseExpectations{ - endpoint: serviceConfigFileEndpoint, - region: expectedCallRegion, - } -} - -func expectBaseConfigFileEndpoint() caseExpectations { - return caseExpectations{ - endpoint: baseConfigFileEndpoint, - region: expectedCallRegion, - } -} - -func testEndpointCase(ctx context.Context, t *testing.T, region string, testcase endpointTestCase, callF callFunc) { - t.Helper() - - setup := caseSetup{ - config: map[string]any{}, - environmentVariables: map[string]string{}, - } - - for _, f := range testcase.with { - f(&setup) - } - - config := map[string]any{ - names.AttrAccessKey: servicemocks.MockStaticAccessKey, - names.AttrSecretKey: servicemocks.MockStaticSecretKey, - names.AttrRegion: region, - names.AttrSkipCredentialsValidation: true, - names.AttrSkipRequestingAccountID: true, - } - - maps.Copy(config, setup.config) - - if setup.configFile.baseUrl != "" || setup.configFile.serviceUrl != "" { - config[names.AttrProfile] = "default" - tempDir := t.TempDir() - writeSharedConfigFile(t, &config, tempDir, generateSharedConfigFile(setup.configFile)) - } - - for k, v := range setup.environmentVariables { - t.Setenv(k, v) - } - - p, err := sdkv2.NewProvider(ctx) - if err != nil { - t.Fatal(err) - } - - p.TerraformVersion = "1.0.0" - - expectedDiags := testcase.expected.diags - diags := p.Configure(ctx, terraformsdk.NewResourceConfigRaw(config)) - - if diff := cmp.Diff(diags, expectedDiags, cmp.Comparer(sdkdiag.Comparer)); diff != "" { - t.Errorf("unexpected diagnostics difference: %s", diff) - } - - if diags.HasError() { - return - } - - meta := p.Meta().(*conns.AWSClient) - - callParams := callF(ctx, t, meta) - - if e, a := testcase.expected.endpoint, callParams.endpoint; e != a { - t.Errorf("expected endpoint %q, got %q", e, a) - } - - if e, a := testcase.expected.region, callParams.region; e != a { - t.Errorf("expected region %q, got %q", e, a) - } -} - -func addRetrieveEndpointURLMiddleware(t *testing.T, endpoint *string) func(*middleware.Stack) error { - return func(stack *middleware.Stack) error { - return stack.Finalize.Add( - retrieveEndpointURLMiddleware(t, endpoint), - middleware.After, - ) - } -} - -func retrieveEndpointURLMiddleware(t *testing.T, endpoint *string) middleware.FinalizeMiddleware { - return middleware.FinalizeMiddlewareFunc( - "Test: Retrieve Endpoint", - func(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (middleware.FinalizeOutput, middleware.Metadata, error) { - t.Helper() - - request, ok := in.Request.(*smithyhttp.Request) - if !ok { - t.Fatalf("Expected *github.com/aws/smithy-go/transport/http.Request, got %s", fullTypeName(in.Request)) - } - - url := request.URL - url.RawQuery = "" - url.Path = "/" - - *endpoint = url.String() - - return next.HandleFinalize(ctx, in) - }) -} - -func addRetrieveRegionMiddleware(region *string) func(*middleware.Stack) error { - return func(stack *middleware.Stack) error { - return stack.Serialize.Add( - retrieveRegionMiddleware(region), - middleware.After, - ) - } -} - -func retrieveRegionMiddleware(region *string) middleware.SerializeMiddleware { - return middleware.SerializeMiddlewareFunc( - "Test: Retrieve Region", - func(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (middleware.SerializeOutput, middleware.Metadata, error) { - *region = awsmiddleware.GetRegion(ctx) - - return next.HandleSerialize(ctx, in) - }, - ) -} - -var errCancelOperation = fmt.Errorf("Test: Canceling request") - -func addCancelRequestMiddleware() func(*middleware.Stack) error { - return func(stack *middleware.Stack) error { - return stack.Finalize.Add( - cancelRequestMiddleware(), - middleware.After, - ) - } -} - -// cancelRequestMiddleware creates a Smithy middleware that intercepts the request before sending and cancels it -func cancelRequestMiddleware() middleware.FinalizeMiddleware { - return middleware.FinalizeMiddlewareFunc( - "Test: Cancel Requests", - func(_ context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (middleware.FinalizeOutput, middleware.Metadata, error) { - return middleware.FinalizeOutput{}, middleware.Metadata{}, errCancelOperation - }) -} - -func fullTypeName(i any) string { - return fullValueTypeName(reflect.ValueOf(i)) -} - -func fullValueTypeName(v reflect.Value) string { - if v.Kind() == reflect.Ptr { - return "*" + fullValueTypeName(reflect.Indirect(v)) - } - - requestType := v.Type() - return fmt.Sprintf("%s.%s", requestType.PkgPath(), requestType.Name()) -} - -func generateSharedConfigFile(config configFile) string { - var buf strings.Builder - - buf.WriteString(` -[default] -aws_access_key_id = DefaultSharedCredentialsAccessKey -aws_secret_access_key = DefaultSharedCredentialsSecretKey -`) - if config.baseUrl != "" { - fmt.Fprintf(&buf, "endpoint_url = %s\n", config.baseUrl) - } - - if config.serviceUrl != "" { - fmt.Fprintf(&buf, ` -services = endpoint-test - -[services endpoint-test] -%[1]s = - endpoint_url = %[2]s -`, configParam, serviceConfigFileEndpoint) - } - - return buf.String() -} - -func writeSharedConfigFile(t *testing.T, config *map[string]any, tempDir, content string) string { - t.Helper() - - file, err := os.Create(filepath.Join(tempDir, "aws-sdk-go-base-shared-configuration-file")) - if err != nil { - t.Fatalf("creating shared configuration file: %s", err) - } - - _, err = file.WriteString(content) - if err != nil { - t.Fatalf(" writing shared configuration file: %s", err) - } - - if v, ok := (*config)[names.AttrSharedConfigFiles]; !ok { - (*config)[names.AttrSharedConfigFiles] = []any{file.Name()} - } else { - (*config)[names.AttrSharedConfigFiles] = append(v.([]any), file.Name()) - } - - return file.Name() -} diff --git a/internal/service/odb/service_package.go b/internal/service/odb/service_package.go deleted file mode 100644 index 32a962a8ab63..000000000000 --- a/internal/service/odb/service_package.go +++ /dev/null @@ -1,21 +0,0 @@ -//Copyright © 2025, Oracle and/or its affiliates. All rights reserved. - -package odb - -import ( - "context" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - "github.com/hashicorp/terraform-provider-aws/names" -) - -func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) (*odb.Client, error) { - cfg := *(config["aws_sdkv2_config"].(*aws.Config)) - - return odb.NewFromConfig(cfg, - odb.WithEndpointResolverV2(newEndpointResolverV2()), - withBaseEndpoint(config[names.AttrEndpoint].(string)), - func(o *odb.Options) { - }, - ), nil -} diff --git a/internal/service/odb/service_package_gen.go b/internal/service/odb/service_package_gen.go deleted file mode 100644 index 68efcabb4e0b..000000000000 --- a/internal/service/odb/service_package_gen.go +++ /dev/null @@ -1,169 +0,0 @@ -// Code generated by internal/generate/servicepackage/main.go; DO NOT EDIT. - -package odb - -import ( - "context" - "unique" - - "github.com/hashicorp/terraform-provider-aws/internal/conns" - inttypes "github.com/hashicorp/terraform-provider-aws/internal/types" - "github.com/hashicorp/terraform-provider-aws/names" -) - -type servicePackage struct{} - -func (p *servicePackage) FrameworkDataSources(ctx context.Context) []*inttypes.ServicePackageFrameworkDataSource { - return []*inttypes.ServicePackageFrameworkDataSource{ - { - Factory: newDataSourceCloudAutonomousVmCluster, - TypeName: "aws_odb_cloud_autonomous_vm_cluster", - Name: "Cloud Autonomous Vm Cluster", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceCloudAutonomousVmClustersList, - TypeName: "aws_odb_cloud_autonomous_vm_clusters_list", - Name: "Cloud Autonomous Vm Clusters List", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceCloudExadataInfrastructure, - TypeName: "aws_odb_cloud_exadata_infrastructure", - Name: "Cloud Exadata Infrastructure", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceCloudExadataInfrastructuresList, - TypeName: "aws_odb_cloud_exadata_infrastructures_list", - Name: "Cloud Exadata Infrastructures List", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceCloudVmCluster, - TypeName: "aws_odb_cloud_vm_cluster", - Name: "Cloud Vm Cluster", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceCloudVmClustersList, - TypeName: "aws_odb_cloud_vm_clusters_list", - Name: "Cloud Vm Clusters List", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceDbServer, - TypeName: "aws_odb_db_server", - Name: "Db Server", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceDbServersList, - TypeName: "aws_odb_db_servers_list", - Name: "Db Servers List", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceDbSystemShapesList, - TypeName: "aws_odb_db_system_shapes_list", - Name: "Db System Shapes List", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceGiVersionsList, - TypeName: "aws_odb_gi_versions_list", - Name: "Gi Versions List", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceNetwork, - TypeName: "aws_odb_network", - Name: "Network", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceNetworkPeeringConnection, - TypeName: "aws_odb_network_peering_connection", - Name: "Network Peering Connection", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceNetworkPeeringConnectionsList, - TypeName: "aws_odb_network_peering_connections_list", - Name: "Network Peering Connections List", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newDataSourceNetworksList, - TypeName: "aws_odb_networks_list", - Name: "Networks List", - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - } -} - -func (p *servicePackage) FrameworkResources(ctx context.Context) []*inttypes.ServicePackageFrameworkResource { - return []*inttypes.ServicePackageFrameworkResource{ - { - Factory: newResourceCloudAutonomousVmCluster, - TypeName: "aws_odb_cloud_autonomous_vm_cluster", - Name: "Cloud Autonomous Vm Cluster", - Tags: unique.Make(inttypes.ServicePackageResourceTags{ - IdentifierAttribute: names.AttrARN, - }), - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newResourceCloudExadataInfrastructure, - TypeName: "aws_odb_cloud_exadata_infrastructure", - Name: "Cloud Exadata Infrastructure", - Tags: unique.Make(inttypes.ServicePackageResourceTags{ - IdentifierAttribute: names.AttrARN, - }), - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newResourceCloudVmCluster, - TypeName: "aws_odb_cloud_vm_cluster", - Name: "Cloud Vm Cluster", - Tags: unique.Make(inttypes.ServicePackageResourceTags{ - IdentifierAttribute: names.AttrARN, - }), - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newResourceNetwork, - TypeName: "aws_odb_network", - Name: "Network", - Tags: unique.Make(inttypes.ServicePackageResourceTags{ - IdentifierAttribute: names.AttrARN, - }), - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - { - Factory: newResourceNetworkPeeringConnection, - TypeName: "aws_odb_network_peering_connection", - Name: "Network Peering Connection", - Tags: unique.Make(inttypes.ServicePackageResourceTags{ - IdentifierAttribute: names.AttrARN, - }), - Region: unique.Make(inttypes.ResourceRegionDefault()), - }, - } -} - -func (p *servicePackage) SDKDataSources(ctx context.Context) []*inttypes.ServicePackageSDKDataSource { - return []*inttypes.ServicePackageSDKDataSource{} -} - -func (p *servicePackage) SDKResources(ctx context.Context) []*inttypes.ServicePackageSDKResource { - return []*inttypes.ServicePackageSDKResource{} -} - -func (p *servicePackage) ServicePackageName() string { - return names.ODB -} - -func ServicePackage(ctx context.Context) conns.ServicePackage { - return &servicePackage{} -} diff --git a/internal/service/odb/tags_gen.go b/internal/service/odb/tags_gen.go deleted file mode 100644 index bc4b9c504732..000000000000 --- a/internal/service/odb/tags_gen.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by internal/generate/tags/main.go; DO NOT EDIT. -package odb - -import ( - "context" - "fmt" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/odb" - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/logging" - tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" - "github.com/hashicorp/terraform-provider-aws/internal/types/option" - "github.com/hashicorp/terraform-provider-aws/names" -) - -// listTags lists odb service tags. -// The identifier is typically the Amazon Resource Name (ARN), although -// it may also be a different identifier depending on the service. -func listTags(ctx context.Context, conn *odb.Client, identifier string, optFns ...func(*odb.Options)) (tftags.KeyValueTags, error) { - input := odb.ListTagsForResourceInput{ - ResourceArn: aws.String(identifier), - } - - output, err := conn.ListTagsForResource(ctx, &input, optFns...) - - if err != nil { - return tftags.New(ctx, nil), err - } - - return keyValueTags(ctx, output.Tags), nil -} - -// ListTags lists odb service tags and set them in Context. -// It is called from outside this package. -func (p *servicePackage) ListTags(ctx context.Context, meta any, identifier string) error { - tags, err := listTags(ctx, meta.(*conns.AWSClient).ODBClient(ctx), identifier) - - if err != nil { - return err - } - - if inContext, ok := tftags.FromContext(ctx); ok { - inContext.TagsOut = option.Some(tags) - } - - return nil -} - -// map[string]string handling - -// svcTags returns odb service tags. -func svcTags(tags tftags.KeyValueTags) map[string]string { - return tags.Map() -} - -// keyValueTags creates tftags.KeyValueTags from odb service tags. -func keyValueTags(ctx context.Context, tags map[string]string) tftags.KeyValueTags { - return tftags.New(ctx, tags) -} - -// getTagsIn returns odb service tags from Context. -// nil is returned if there are no input tags. -func getTagsIn(ctx context.Context) map[string]string { - if inContext, ok := tftags.FromContext(ctx); ok { - if tags := svcTags(inContext.TagsIn.UnwrapOrDefault()); len(tags) > 0 { - return tags - } - } - - return nil -} - -// setTagsOut sets odb service tags in Context. -func setTagsOut(ctx context.Context, tags map[string]string) { - if inContext, ok := tftags.FromContext(ctx); ok { - inContext.TagsOut = option.Some(keyValueTags(ctx, tags)) - } -} - -// updateTags updates odb service tags. -// The identifier is typically the Amazon Resource Name (ARN), although -// it may also be a different identifier depending on the service. -func updateTags(ctx context.Context, conn *odb.Client, identifier string, oldTagsMap, newTagsMap any, optFns ...func(*odb.Options)) error { - oldTags := tftags.New(ctx, oldTagsMap) - newTags := tftags.New(ctx, newTagsMap) - - ctx = tflog.SetField(ctx, logging.KeyResourceId, identifier) - - removedTags := oldTags.Removed(newTags) - removedTags = removedTags.IgnoreSystem(names.ODB) - if len(removedTags) > 0 { - input := odb.UntagResourceInput{ - ResourceArn: aws.String(identifier), - TagKeys: removedTags.Keys(), - } - - _, err := conn.UntagResource(ctx, &input, optFns...) - - if err != nil { - return fmt.Errorf("untagging resource (%s): %w", identifier, err) - } - } - - updatedTags := oldTags.Updated(newTags) - updatedTags = updatedTags.IgnoreSystem(names.ODB) - if len(updatedTags) > 0 { - input := odb.TagResourceInput{ - ResourceArn: aws.String(identifier), - Tags: svcTags(updatedTags), - } - - _, err := conn.TagResource(ctx, &input, optFns...) - - if err != nil { - return fmt.Errorf("tagging resource (%s): %w", identifier, err) - } - } - - return nil -} - -// UpdateTags updates odb service tags. -// It is called from outside this package. -func (p *servicePackage) UpdateTags(ctx context.Context, meta any, identifier string, oldTags, newTags any) error { - return updateTags(ctx, meta.(*conns.AWSClient).ODBClient(ctx), identifier, oldTags, newTags) -} diff --git a/internal/sweep/service_packages_gen_test.go b/internal/sweep/service_packages_gen_test.go index b4930936066d..a063d088e82d 100644 --- a/internal/sweep/service_packages_gen_test.go +++ b/internal/sweep/service_packages_gen_test.go @@ -175,7 +175,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/service/notifications" "github.com/hashicorp/terraform-provider-aws/internal/service/notificationscontacts" "github.com/hashicorp/terraform-provider-aws/internal/service/oam" - "github.com/hashicorp/terraform-provider-aws/internal/service/odb" "github.com/hashicorp/terraform-provider-aws/internal/service/opensearch" "github.com/hashicorp/terraform-provider-aws/internal/service/opensearchserverless" "github.com/hashicorp/terraform-provider-aws/internal/service/organizations" @@ -431,7 +430,6 @@ func servicePackages(ctx context.Context) []conns.ServicePackage { notifications.ServicePackage(ctx), notificationscontacts.ServicePackage(ctx), oam.ServicePackage(ctx), - odb.ServicePackage(ctx), opensearch.ServicePackage(ctx), opensearchserverless.ServicePackage(ctx), organizations.ServicePackage(ctx), diff --git a/names/consts_gen.go b/names/consts_gen.go index 891ae53defe0..aa6170eb2602 100644 --- a/names/consts_gen.go +++ b/names/consts_gen.go @@ -168,7 +168,6 @@ const ( NetworkMonitor = "networkmonitor" Notifications = "notifications" NotificationsContacts = "notificationscontacts" - ODB = "odb" ObservabilityAccessManager = "oam" OpenSearch = "opensearch" OpenSearchIngestion = "osis" @@ -424,7 +423,6 @@ const ( NetworkMonitorServiceID = "NetworkMonitor" NotificationsServiceID = "notifications" NotificationsContactsServiceID = "notificationscontacts" - ODBServiceID = "ODB" ObservabilityAccessManagerServiceID = "OAM" OpenSearchServiceID = "OpenSearch" OpenSearchIngestionServiceID = "OSIS" diff --git a/names/data/names_data.hcl b/names/data/names_data.hcl index 43181a66f6a7..6a83a3386cfa 100644 --- a/names/data/names_data.hcl +++ b/names/data/names_data.hcl @@ -9441,33 +9441,4 @@ service "evs" { provider_package_correct = "evs" doc_prefix = ["evs_"] brand = "Amazon" -} -service "odb" { - sdk { - id = "ODB" - arn_namespace = "odb" - } - names { - provider_name_upper = "ODB" - human_friendly = "Oracle Database@AWS" - } - endpoint_info { - endpoint_api_call = "ListCloudExadataInfrastructures" - endpoint_region_overrides = { - "aws" = "us-east-1" - } - } - go_packages { - v1_package = "" - v2_package = "odb" - } - client{ - skip_client_generate = true - } - resource_prefix{ - correct = "aws_odb_" - } - provider_package_correct = "odb" - doc_prefix = ["odb_"] - brand = "AWS" } \ No newline at end of file diff --git a/website/allowed-subcategories.txt b/website/allowed-subcategories.txt index cd54f7ea7596..45c4b8b75701 100644 --- a/website/allowed-subcategories.txt +++ b/website/allowed-subcategories.txt @@ -174,7 +174,6 @@ Network Manager OpenSearch OpenSearch Ingestion OpenSearch Serverless -Oracle Database@AWS Organizations Outposts Outposts (EC2) diff --git a/website/docs/d/odb_cloud_autonomous_vm_clusters_list.html.markdown b/website/docs/d/odb_cloud_autonomous_vm_clusters_list.html.markdown deleted file mode 100644 index aaef5fcf4343..000000000000 --- a/website/docs/d/odb_cloud_autonomous_vm_clusters_list.html.markdown +++ /dev/null @@ -1,47 +0,0 @@ ---- -subcategory: "Oracle Database@AWS" -layout: "aws" -page_title: "AWS: aws_odb_cloud_autonomous_vm_clusters_list" -description: |- - Provides details about an AWS Oracle Database@AWS Cloud Autonomous Vm Clusters List. ---- - - -# Data Source: aws_odb_cloud_autonomous_vm_clusters_list - -Provides details about an AWS Oracle Database@AWS Cloud Autonomous Vm Clusters List. - -## Example Usage - -### Basic Usage - -```terraform -data "aws_odb_cloud_autonomous_vm_clusters_list" "example" { -} -``` - -## Argument Reference - -The following arguments are required: - -* `example_arg` - (Required) Brief description of the required argument. - -The following arguments are optional: - -* `optional_arg` - (Optional) Brief description of the optional argument. - -## Attribute Reference - -This data source exports the following attributes in addition to the arguments above: - -* `arn` - ARN of the Cloud Autonomous Vm Clusters List. -* `example_attribute` - Brief description of the attribute. diff --git a/website/docs/d/odb_cloud_vm_clusters_list.html.markdown b/website/docs/d/odb_cloud_vm_clusters_list.html.markdown deleted file mode 100644 index 1b9094fa50fb..000000000000 --- a/website/docs/d/odb_cloud_vm_clusters_list.html.markdown +++ /dev/null @@ -1,47 +0,0 @@ ---- -subcategory: "Oracle Database@AWS" -layout: "aws" -page_title: "AWS: aws_odb_cloud_vm_clusters_list" -description: |- - Provides details about an AWS Oracle Database@AWS Cloud Vm Clusters List. ---- - - -# Data Source: aws_odb_cloud_vm_clusters_list - -Provides details about an AWS Oracle Database@AWS Cloud Vm Clusters List. - -## Example Usage - -### Basic Usage - -```terraform -data "aws_odb_cloud_vm_clusters_list" "example" { -} -``` - -## Argument Reference - -The following arguments are required: - -* `example_arg` - (Required) Brief description of the required argument. - -The following arguments are optional: - -* `optional_arg` - (Optional) Brief description of the optional argument. - -## Attribute Reference - -This data source exports the following attributes in addition to the arguments above: - -* `arn` - ARN of the Cloud Vm Clusters List. -* `example_attribute` - Brief description of the attribute. diff --git a/website/docs/d/odb_networks_list.html.markdown b/website/docs/d/odb_networks_list.html.markdown deleted file mode 100644 index 759c339f9db3..000000000000 --- a/website/docs/d/odb_networks_list.html.markdown +++ /dev/null @@ -1,47 +0,0 @@ ---- -subcategory: "Oracle Database@AWS" -layout: "aws" -page_title: "AWS: aws_odb_networks_list" -description: |- - Provides details about an AWS Oracle Database@AWS Networks List. ---- - - -# Data Source: aws_odb_networks_list - -Provides details about an AWS Oracle Database@AWS Networks List. - -## Example Usage - -### Basic Usage - -```terraform -data "aws_odb_networks_list" "example" { -} -``` - -## Argument Reference - -The following arguments are required: - -* `example_arg` - (Required) Brief description of the required argument. - -The following arguments are optional: - -* `optional_arg` - (Optional) Brief description of the optional argument. - -## Attribute Reference - -This data source exports the following attributes in addition to the arguments above: - -* `arn` - ARN of the Networks List. -* `example_attribute` - Brief description of the attribute. diff --git a/website/docs/guides/custom-service-endpoints.html.markdown b/website/docs/guides/custom-service-endpoints.html.markdown index ee8b28828e8b..1bc7580337e4 100644 --- a/website/docs/guides/custom-service-endpoints.html.markdown +++ b/website/docs/guides/custom-service-endpoints.html.markdown @@ -250,7 +250,6 @@ provider "aws" { |User Notifications|`notifications`|`AWS_ENDPOINT_URL_NOTIFICATIONS`|`notifications`| |User Notifications Contacts|`notificationscontacts`|`AWS_ENDPOINT_URL_NOTIFICATIONSCONTACTS`|`notificationscontacts`| |CloudWatch Observability Access Manager|`oam`(or `cloudwatchobservabilityaccessmanager`)|`AWS_ENDPOINT_URL_OAM`|`oam`| -|Oracle Database@AWS|`odb`|`AWS_ENDPOINT_URL_ODB`|`odb`| |OpenSearch|`opensearch`(or `opensearchservice`)|`AWS_ENDPOINT_URL_OPENSEARCH`|`opensearch`| |OpenSearch Serverless|`opensearchserverless`|`AWS_ENDPOINT_URL_OPENSEARCHSERVERLESS`|`opensearchserverless`| |Organizations|`organizations`|`AWS_ENDPOINT_URL_ORGANIZATIONS`|`organizations`| diff --git a/website/docs/r/odb_cloud_exadata_infrastructure.html.markdown b/website/docs/r/odb_cloud_exadata_infrastructure.html.markdown deleted file mode 100644 index bc72d5c9a32b..000000000000 --- a/website/docs/r/odb_cloud_exadata_infrastructure.html.markdown +++ /dev/null @@ -1,72 +0,0 @@ ---- -subcategory: "Oracle Database@AWS" -layout: "aws" -page_title: "AWS: aws_odb_cloud_exadata_infrastructure" -description: |- - Manages an AWS Oracle Database@AWS Cloud Exadata Infrastructure. ---- - - -# Resource: aws_odb_cloud_exadata_infrastructure - -Manages an AWS Oracle Database@AWS Cloud Exadata Infrastructure. - -## Example Usage - -### Basic Usage - -```terraform -resource "aws_odb_cloud_exadata_infrastructure" "example" { -} -``` - -## Argument Reference - -The following arguments are required: - -* `example_arg` - (Required) Brief description of the required argument. - -The following arguments are optional: - -* `optional_arg` - (Optional) Brief description of the optional argument. - -## Attribute Reference - -This resource exports the following attributes in addition to the arguments above: - -* `arn` - ARN of the Cloud Exadata Infrastructure. -* `example_attribute` - Brief description of the attribute. - -## Timeouts - -[Configuration options](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts): - -* `create` - (Default `60m`) -* `update` - (Default `180m`) -* `delete` - (Default `90m`) - -## Import - -In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Oracle Database@AWS Cloud Exadata Infrastructure using the `example_id_arg`. For example: - -```terraform -import { - to = aws_odb_cloud_exadata_infrastructure.example - id = "cloud_exadata_infrastructure-id-12345678" -} -``` - -Using `terraform import`, import Oracle Database@AWS Cloud Exadata Infrastructure using the `example_id_arg`. For example: - -```console -% terraform import aws_odb_cloud_exadata_infrastructure.example cloud_exadata_infrastructure-id-12345678 -``` diff --git a/website/docs/r/odb_exa_infra.html.markdown b/website/docs/r/odb_exa_infra.html.markdown deleted file mode 100644 index f52a8ff927b8..000000000000 --- a/website/docs/r/odb_exa_infra.html.markdown +++ /dev/null @@ -1,72 +0,0 @@ ---- -subcategory: "Oracle Database@AWS" -layout: "aws" -page_title: "AWS: aws_odb_exa_infra" -description: |- - Manages an AWS Oracle Database@AWS Exa Infra. ---- - - -# Resource: aws_odb_exa_infra - -Manages an AWS Oracle Database@AWS Exa Infra. - -## Example Usage - -### Basic Usage - -```terraform -resource "aws_odb_exa_infra" "example" { -} -``` - -## Argument Reference - -The following arguments are required: - -* `example_arg` - (Required) Brief description of the required argument. - -The following arguments are optional: - -* `optional_arg` - (Optional) Brief description of the optional argument. - -## Attribute Reference - -This resource exports the following attributes in addition to the arguments above: - -* `arn` - ARN of the Exa Infra. -* `example_attribute` - Brief description of the attribute. - -## Timeouts - -[Configuration options](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts): - -* `create` - (Default `60m`) -* `update` - (Default `180m`) -* `delete` - (Default `90m`) - -## Import - -In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Oracle Database@AWS Exa Infra using the `example_id_arg`. For example: - -```terraform -import { - to = aws_odb_exa_infra.example - id = "exa_infra-id-12345678" -} -``` - -Using `terraform import`, import Oracle Database@AWS Exa Infra using the `example_id_arg`. For example: - -```console -% terraform import aws_odb_exa_infra.example exa_infra-id-12345678 -```