diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c04f1abc..bf47e527b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,11 @@ ## 6.5.3 ### Fixes +- `ionoslcoud_logging_pipeline` - `location` should be optional with `de/txl` default. Upgrading should not break existing pipelines. - Fix DBaaS tests ## 6.5.2 ### Features - support for all s3 resources configurations - - -## 6.5.1 -### Features - Add `location` to `logging_pipeline` resource and data source ### Fixes - Fix nil deref due to `GeoRestrictions` not being checked against nil diff --git a/docs/data-sources/logging_pipeline.md b/docs/data-sources/logging_pipeline.md index 24459ce66..cde3b2c84 100644 --- a/docs/data-sources/logging_pipeline.md +++ b/docs/data-sources/logging_pipeline.md @@ -19,6 +19,7 @@ If a single match is found, it will be returned. If your search results in multi ### By ID ```hcl data "ionoscloud_logging_pipeline" "example" { + location = "de/txl" id = } ``` @@ -32,7 +33,7 @@ data "ionoscloud_logging_pipeline" "example" { ``` ## Argument reference -* `location` - (Required)[string] The location of the Logging pipeline. One of `de/fra`, `de/txl`, `gb/lhr`, `es/vit`, `fr/par`. +* `location` - (Optional)[string] The location of the Logging pipeline. Default: `de/txl`. One of `de/fra`, `de/txl`, `gb/lhr`, `es/vit`, `fr/par`. * `id` - (Optional)[string] The ID of the Logging pipeline you want to search for. * `name` - (Optional)[string] The name of the Logging pipeline you want to search for. diff --git a/docs/resources/logging_pipeline.md b/docs/resources/logging_pipeline.md index 749909e4c..5ee6250fc 100644 --- a/docs/resources/logging_pipeline.md +++ b/docs/resources/logging_pipeline.md @@ -106,7 +106,7 @@ terraform apply -var-file="vars.tfvars" ## Argument reference -* `location` - (Required)[string] The location of the Logging pipeline. One of `de/fra`, `de/txl`, `gb/lhr`, `es/vit`, `fr/par`. +* `location` - (Optional)[string] The location of the Logging pipeline. Default: `de/txl` One of `de/fra`, `de/txl`, `gb/lhr`, `es/vit`, `fr/par`. * `name` - (Required)[string] The name of the Logging pipeline. * `grafana_address` - (Computed)[string] The address of the client's grafana instance. * `log` - (Required)[list] Pipeline logs, a list that contains elements with the following structure: @@ -124,7 +124,6 @@ In order to import a Logging pipeline, you can define an empty Logging pipeline ```hcl resource "ionoscloud_logging_pipeline" "example" { - } ``` diff --git a/ionoscloud/data_source_logging_pipeline.go b/ionoscloud/data_source_logging_pipeline.go index 784d4cf0b..1e391d2f4 100644 --- a/ionoscloud/data_source_logging_pipeline.go +++ b/ionoscloud/data_source_logging_pipeline.go @@ -20,9 +20,17 @@ func dataSourceLoggingPipeline() *schema.Resource { ReadContext: dataSourcePipelineRead, Schema: map[string]*schema.Schema{ "location": { - Type: schema.TypeString, - Description: fmt.Sprintf("The location of your logging pipeline. Supported locations: %s", strings.Join(loggingService.AvailableLocations, ", ")), - Required: true, + Type: schema.TypeString, + Description: fmt.Sprintf("The location of your logging pipeline. Default: de/txl. Supported locations: %s", strings.Join(loggingService.AvailableLocations, ", ")), + Optional: true, + Default: "de/txl", + // no diff in case it moves from "" to de/txl since it's an upgrade from when we had no location + DiffSuppressFunc: func(_, old, new string, _ *schema.ResourceData) bool { + if old == "" && new == "de/txl" { + return true + } + return false + }, ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(loggingService.AvailableLocations, false)), }, "id": { diff --git a/ionoscloud/resource_logging_pipeline.go b/ionoscloud/resource_logging_pipeline.go index d0b247a63..cd2857dd9 100644 --- a/ionoscloud/resource_logging_pipeline.go +++ b/ionoscloud/resource_logging_pipeline.go @@ -27,10 +27,18 @@ func resourceLoggingPipeline() *schema.Resource { }, Schema: map[string]*schema.Schema{ "location": { - Type: schema.TypeString, - Description: fmt.Sprintf("The location of your logging pipeline. Default: de/txl. Supported locations: %s", strings.Join(logging.AvailableLocations, ", ")), - Required: true, - ForceNew: true, + Type: schema.TypeString, + Description: fmt.Sprintf("The location of your logging pipeline. Default: de/txl. Supported locations: %s", strings.Join(logging.AvailableLocations, ", ")), + Optional: true, + Default: logging.DefaultLocation, + ForceNew: true, + // no diff in case it moves from "" to de/txl since it's an upgrade from when we had no location + DiffSuppressFunc: func(_, old, new string, _ *schema.ResourceData) bool { + if old == "" && new == logging.DefaultLocation { + return true + } + return false + }, ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(logging.AvailableLocations, false)), }, "name": { @@ -116,8 +124,10 @@ func pipelineCreate(ctx context.Context, d *schema.ResourceData, meta interface{ func pipelineRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(services.SdkBundle).LoggingClient pipelineID := d.Id() - location := d.Get("location").(string) - + location := logging.DefaultLocation + if newLocation, ok := d.GetOk("location"); ok { + location = newLocation.(string) + } pipeline, apiResponse, err := client.GetPipelineByID(ctx, location, pipelineID) if err != nil { if apiResponse.HttpNotFound() { diff --git a/services/logging/client.go b/services/logging/client.go index f9a70e56a..8430b5e18 100644 --- a/services/logging/client.go +++ b/services/logging/client.go @@ -33,6 +33,9 @@ func NewClient(username, password, token, url, terraformVersion string) *Client } func (c *Client) changeConfigURL(location string) { + if location == "" { + location = DefaultLocation + } config := c.sdkClient.GetConfig() config.Servers = shared.ServerConfigurations{ { @@ -44,6 +47,8 @@ func (c *Client) changeConfigURL(location string) { var ( // AvailableLocations is a list of available locations AvailableLocations = []string{"de/fra", "de/txl", "es/vit", "gb/lhr", "fr/par"} + // DefaultLocation is the default logging pipeline location + DefaultLocation = "de/txl" locationToURL = map[string]string{ "de/fra": "https://logging.de-fra.ionos.com",