Skip to content

Commit

Permalink
fix: remove location validations (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiGuranIonos authored Dec 9, 2024
1 parent ce102a0 commit eb66206
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 83 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 6.6.7
### Fix
- Remove location validations for `backup_location` in `ionoscloud_pg_cluster` resource
- Remove location validations for `ionoscloud_mongo_cluster` resource
- Remove location validations for `ionoscloud_datacenter` resource
- Remove location validations for `ionoscloud_vpn_ipsec_gateway` resource
- Remove location validations for `ionoscloud_vpn_wireguard_gateway` resource
- Remove location validations for kafa, auto_certificate, inmemorydb and nfs data sources

## 6.6.6
### Features
- Add `maintenance_window`, `tier` and regional endpoints for VPN resources
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/dbaas_pgsql_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: |-
Creates and manages DbaaS Postgres Cluster objects.
---

# ionoscloud\_pg_cluster
# ionoscloud_pg_cluster

Manages a **DbaaS PgSql Cluster**.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@ import (

"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services"
certService "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/cert"
"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant"
)

func dataSourceCertificateManagerAutoCertificate() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceAutoCertificateRead,
Schema: map[string]*schema.Schema{
"location": {
Type: schema.TypeString,
Required: true,
Description: "The location of the auto-certificate",
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(constant.Locations, false)),
Type: schema.TypeString,
Required: true,
Description: "The location of the auto-certificate",
},
"id": {
Type: schema.TypeString,
Expand Down
10 changes: 3 additions & 7 deletions ionoscloud/data_source_dbaas_inmemorydb_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services"
"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant"
)

func dataSourceDBaaSInMemoryDBSnapshot() *schema.Resource {
Expand All @@ -22,10 +19,9 @@ func dataSourceDBaaSInMemoryDBSnapshot() *schema.Resource {
Required: true,
},
"location": {
Type: schema.TypeString,
Description: "The location of the snapshot.",
Required: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(constant.Locations, false)),
Type: schema.TypeString,
Description: "The location of the snapshot.",
Required: true,
},
"metadata": {
Type: schema.TypeList,
Expand Down
9 changes: 4 additions & 5 deletions ionoscloud/data_source_kafka_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ func dataSourceKafkaCluster() *schema.Resource {
Optional: true,
},
"location": {
Type: schema.TypeString,
Description: fmt.Sprintf("The location of your Kafka Cluster. Supported locations: %s", strings.Join(kafka.AvailableLocations, ", ")),
Required: true,
ForceNew: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(kafka.AvailableLocations, false)),
Type: schema.TypeString,
Description: fmt.Sprintf("The location of your Kafka Cluster. Supported locations: %s", strings.Join(kafka.AvailableLocations, ", ")),
Required: true,
ForceNew: true,
},
"version": {
Type: schema.TypeString,
Expand Down
9 changes: 4 additions & 5 deletions ionoscloud/data_source_kafka_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ func dataSourceKafkaTopic() *schema.Resource {
Computed: true,
},
"location": {
Type: schema.TypeString,
Description: fmt.Sprintf("The location of your Kafka Cluster Topic. Supported locations: %s", strings.Join(kafka.AvailableLocations, ", ")),
Required: true,
ForceNew: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(kafka.AvailableLocations, false)),
Type: schema.TypeString,
Description: fmt.Sprintf("The location of your Kafka Cluster Topic. Supported locations: %s", strings.Join(kafka.AvailableLocations, ", ")),
Required: true,
ForceNew: true,
},
"cluster_id": {
Type: schema.TypeString,
Expand Down
7 changes: 2 additions & 5 deletions ionoscloud/data_source_nfs_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

nfs2 "github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/nfs"

"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services"
Expand All @@ -25,9 +23,8 @@ func dataSourceNFSCluster() *schema.Resource {
Type: schema.TypeString,
Description: fmt.Sprintf("The location of the Network File Storage Cluster. "+
"Available locations: '%s'", strings.Join(nfs2.ValidNFSLocations, ", '")),
Required: true,
ForceNew: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(nfs2.ValidNFSLocations, false)),
Required: true,
ForceNew: true,
},
"id": {
Type: schema.TypeString,
Expand Down
5 changes: 0 additions & 5 deletions ionoscloud/resource_certificate_manager_auto_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"slices"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand All @@ -13,7 +12,6 @@ import (
"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services"
"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/cert"
"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils"
"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant"
)

func resourceCertificateManagerAutoCertificate() *schema.Resource {
Expand Down Expand Up @@ -159,9 +157,6 @@ func autoCertificateImport(ctx context.Context, d *schema.ResourceData, meta int
return nil, fmt.Errorf("invalid import ID: %v, expected ID in the format: '<location>:<auto_certificate_ID>", d.Id())
}
location := parts[0]
if !slices.Contains(constant.Locations, location) {
return nil, fmt.Errorf("invalid location: %v, location must be one of %v", location, constant.Locations)
}
autoCertificateID := parts[1]
autoCertificate, apiResponse, err := client.GetAutoCertificate(ctx, autoCertificateID, location)
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions ionoscloud/resource_certificate_manager_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"slices"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand All @@ -13,7 +12,6 @@ import (
"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services"
"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/services/cert"
"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils"
"github.com/ionos-cloud/terraform-provider-ionoscloud/v6/utils/constant"
)

func resourceCertificateManagerProvider() *schema.Resource {
Expand Down Expand Up @@ -163,9 +161,6 @@ func providerImport(ctx context.Context, d *schema.ResourceData, meta interface{
return nil, fmt.Errorf("invalid import ID: %v, expected ID in the format: '<location>:<provider_id>'", d.Id())
}
location := parts[0]
if !slices.Contains(constant.Locations, location) {
return nil, fmt.Errorf("invalid location: %v, location must be one of: %v", location, constant.Locations)
}
providerID := parts[1]
provider, apiResponse, err := client.GetProvider(ctx, providerID, location)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions ionoscloud/resource_datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ func resourceDatacenter() *schema.Resource {
ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsNotWhiteSpace),
},
"location": {
Type: schema.TypeString,
Required: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsNotWhiteSpace),
Type: schema.TypeString,
Required: true,
},
"description": {
Type: schema.TypeString,
Expand Down
4 changes: 0 additions & 4 deletions ionoscloud/resource_dbaas_inmemorydb_replicaset.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -284,9 +283,6 @@ func replicaSetImport(ctx context.Context, d *schema.ResourceData, meta interfac
return nil, fmt.Errorf("invalid import ID: %q, expected ID in the format '<location>:<replica_set_id>'", d.Id())
}
location := parts[0]
if !slices.Contains(constant.Locations, location) {
return nil, fmt.Errorf("invalid import ID: %q, location must be one of %v", d.Id(), constant.Locations)
}
replicaSetID := parts[1]
replicaSet, apiResponse, err := client.GetReplicaSet(ctx, replicaSetID, location)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions ionoscloud/resource_dbaas_mariadb_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -233,9 +232,6 @@ func mariaDBClusterImport(ctx context.Context, d *schema.ResourceData, meta inte
return nil, fmt.Errorf("invalid import ID: %q, expected ID in the format '<location>:<cluster_id>'", d.Id())
}
location := parts[0]
if !slices.Contains(constant.Locations, location) {
return nil, fmt.Errorf("invalid import ID: %q, location must be one of %v", d.Id(), constant.Locations)
}
clusterID := parts[1]

cluster, apiResponse, err := client.GetCluster(ctx, clusterID, location)
Expand Down
5 changes: 2 additions & 3 deletions ionoscloud/resource_dbaas_mongodb_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ func resourceDbaasMongoDBCluster() *schema.Resource {
Type: schema.TypeString,
Description: "The physical location where the cluster will be created. This will be where all of your instances live. " +
"Property cannot be modified after datacenter creation (disallowed in update requests). Available locations: de/txl, gb/lhr, es/vit. Update forces cluster re-creation.",
Required: true,
ForceNew: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsNotWhiteSpace),
Required: true,
ForceNew: true,
},
"connections": {
Type: schema.TypeList,
Expand Down
9 changes: 4 additions & 5 deletions ionoscloud/resource_dbaas_pgsql_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,10 @@ func resourceDbaasPgSqlCluster() *schema.Resource {
ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsNotWhiteSpace),
},
"backup_location": {
Type: schema.TypeString,
Description: "The Object Storage location where the backups will be stored.",
Optional: true,
Computed: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"de", "eu-south-2", "eu-central-2"}, true)),
Type: schema.TypeString,
Description: "The Object Storage location where the backups will be stored.",
Optional: true,
Computed: true,
},
"display_name": {
Type: schema.TypeString,
Expand Down
7 changes: 1 addition & 6 deletions ionoscloud/resource_kafka_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -181,11 +180,7 @@ func resourceKafkaClusterImport(ctx context.Context, d *schema.ResourceData, met
}

location := parts[0]
if !slices.Contains(kafka.AvailableLocations, location) {
return nil, fmt.Errorf("invalid location: %v, location must be one of: %v", location, kafka.AvailableLocations)
}

if err := d.Set("location", parts[0]); err != nil {
if err := d.Set("location", location); err != nil {
return nil, fmt.Errorf("failed to set location Kafka Cluster for import: %w", err)
}
d.SetId(parts[1])
Expand Down
7 changes: 1 addition & 6 deletions ionoscloud/resource_logging_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"slices"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -189,11 +188,7 @@ func pipelineImport(ctx context.Context, d *schema.ResourceData, meta interface{
}

location := parts[0]
if !slices.Contains(logging.AvailableLocations, location) {
return nil, fmt.Errorf("invalid location: %v, location must be one of: %v", location, logging.AvailableLocations)
}

if err := d.Set("location", parts[0]); err != nil {
if err := d.Set("location", location); err != nil {
return nil, fmt.Errorf("failed to set location for Logging Pipeline import: %w", err)
}
d.SetId(parts[1])
Expand Down
4 changes: 0 additions & 4 deletions ionoscloud/resource_nfs_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"slices"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -151,9 +150,6 @@ func resourceNFSClusterImport(ctx context.Context, d *schema.ResourceData, meta
return nil, fmt.Errorf("invalid import ID: %q, expected ID in the format '<location>:<replica_set_id>'", d.Id())
}
location := parts[0]
if !slices.Contains(nfs.ValidNFSLocations, location) {
return nil, fmt.Errorf("invalid import ID: %q, location must be one of '%s'", d.Id(), strings.Join(nfs.ValidNFSLocations, ", '"))
}
id := parts[1]

err := d.Set("location", location)
Expand Down
9 changes: 4 additions & 5 deletions ionoscloud/resource_vpn_ipsec_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ func resourceVpnIPSecGateway() *schema.Resource {
Optional: true,
},
"location": {
Type: schema.TypeString,
Description: fmt.Sprintf("The location of the IPSec Gateway. Supported locations: %s", strings.Join(vpn.AvailableLocations, ", ")),
Optional: true,
ForceNew: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(vpn.AvailableLocations, false)),
Type: schema.TypeString,
Description: fmt.Sprintf("The location of the IPSec Gateway. Supported locations: %s", strings.Join(vpn.AvailableLocations, ", ")),
Optional: true,
ForceNew: true,
},
"gateway_ip": {
Type: schema.TypeString,
Expand Down
9 changes: 4 additions & 5 deletions ionoscloud/resource_vpn_wireguard_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ func resourceVpnWireguardGateway() *schema.Resource {
Required: true,
},
"location": {
Type: schema.TypeString,
Description: fmt.Sprintf("The location of the WireGuard Gateway. Supported locations: %s", strings.Join(vpn.AvailableLocations, ", ")),
Optional: true,
ForceNew: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(vpn.AvailableLocations, false)),
Type: schema.TypeString,
Description: fmt.Sprintf("The location of the WireGuard Gateway. Supported locations: %s", strings.Join(vpn.AvailableLocations, ", ")),
Optional: true,
ForceNew: true,
},
"connections": {
MinItems: 1,
Expand Down

0 comments on commit eb66206

Please sign in to comment.