From 9fc1c35d633ddacc34ccb85637630d316f725225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Mon, 11 Sep 2023 12:05:55 +0100 Subject: [PATCH 1/4] Fix internal ID strucutre description --- docs/data-sources/dns_record_set.md | 2 +- docs/resources/dns_record_set.md | 2 +- stackit/services/dns/recordset/datasource.go | 2 +- stackit/services/dns/recordset/resource.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/data-sources/dns_record_set.md b/docs/data-sources/dns_record_set.md index 6003f0bae..26089c4f9 100644 --- a/docs/data-sources/dns_record_set.md +++ b/docs/data-sources/dns_record_set.md @@ -34,7 +34,7 @@ data "stackit_dns_record_set" "example" { - `active` (Boolean) Specifies if the record set is active or not. - `comment` (String) Comment. - `error` (String) Error shows error in case create/update/delete failed. -- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`instance_id`,`record_set_id`". +- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`zone_id`,`record_set_id`". - `name` (String) Name of the record which should be a valid domain according to rfc1035 Section 2.3.4. E.g. `example.com` - `records` (List of String) Records. - `state` (String) Record set state. diff --git a/docs/resources/dns_record_set.md b/docs/resources/dns_record_set.md index 00eb44a37..cbe6feef8 100644 --- a/docs/resources/dns_record_set.md +++ b/docs/resources/dns_record_set.md @@ -43,6 +43,6 @@ resource "stackit_dns_record_set" "example" { ### Read-Only - `error` (String) Error shows error in case create/update/delete failed. -- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`instance_id`,`record_set_id`". +- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`zone_id`,`record_set_id`". - `record_set_id` (String) The rr set id. - `state` (String) Record set state. diff --git a/stackit/services/dns/recordset/datasource.go b/stackit/services/dns/recordset/datasource.go index de752e0ce..681cb26eb 100644 --- a/stackit/services/dns/recordset/datasource.go +++ b/stackit/services/dns/recordset/datasource.go @@ -76,7 +76,7 @@ func (d *recordSetDataSource) Schema(_ context.Context, _ datasource.SchemaReque Description: "DNS Record Set Resource schema.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Description: "Terraform's internal resource ID. It is structured as \"`project_id`,`instance_id`,`record_set_id`\".", + Description: "Terraform's internal resource ID. It is structured as \"`project_id`,`zone_id`,`record_set_id`\".", Computed: true, }, "project_id": schema.StringAttribute{ diff --git a/stackit/services/dns/recordset/resource.go b/stackit/services/dns/recordset/resource.go index 8858afc96..81e114b08 100644 --- a/stackit/services/dns/recordset/resource.go +++ b/stackit/services/dns/recordset/resource.go @@ -104,7 +104,7 @@ func (r *recordSetResource) Schema(_ context.Context, _ resource.SchemaRequest, Description: "DNS Record Set Resource schema.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Description: "Terraform's internal resource ID. It is structured as \"`project_id`,`instance_id`,`record_set_id`\".", + Description: "Terraform's internal resource ID. It is structured as \"`project_id`,`zone_id`,`record_set_id`\".", Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), From cf97485711678535f48b05e5e4a4e6e15716fb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Mon, 11 Sep 2023 12:06:12 +0100 Subject: [PATCH 2/4] Add example to MIGRATION.md --- MIGRATION.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/MIGRATION.md b/MIGRATION.md index 967bf10c1..57928989f 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -10,3 +10,54 @@ Before you begin the migration process, please ensure that you have done the nec For existing resources created with the old provider, you'll need to import them into your new configuration. Terraform provides a feature for importing existing resources and auto-generating new Terraform configuration files. To generate configuration code for the imported resources, refer to the official [Terraform documentation](https://developer.hashicorp.com/terraform/language/import/generating-configuration) for step-by-step guidance. Once the configuration is generated, compare the generated file with your existing configuration. Be aware that field names may have changed so you should adapt the configuration accordingly. However, not all attributes from the generated configuration are needed for managing the infrastructure, meaning this set of fields can be reduced to the relevant ones from your previous configuration. Check the Terraform plan for the imported resource to identify any differences. + +### Example (DNS service) +Import configuration: +```terraform +import { + id = "project_id,zone_id" + to = stackit_dns_zone.zone_resource_example +} + +import { + id = "project_id,zone_id,record_set_id" + to = stackit_dns_record_set.record_set_resource_example +} +``` + +Generated configuration: +```terraform +# __generated__ by Terraform +# Please review these resources and move them into your main configuration files. + +# __generated__ by Terraform from "project_id,zone_id" +resource "stackit_dns_zone" "zone_resource" { + acl = "0.0.0.0/0" + active = true + contact_email = "example@mail.com" + default_ttl = 123 + description = "This is a description" + dns_name = "example.com" + expire_time = 1209600 + is_reverse_zone = false + name = "example-zone" + negative_cache = 60 + primaries = [""] + project_id = "project_id" + refresh_time = 3600 + retry_time = 600 + type = "primary" +} + +# __generated__ by Terraform from "project_id,zone_id,record_set_id" +resource "stackit_dns_record_set" "record_set_resource" { + active = true + comment = "This is a comment" + name = "example.com" + project_id = "project_id" + records = ["1.2.3.4"] + ttl = 123 + type = "A" + zone_id = "zone_id" +} +``` \ No newline at end of file From 5ce4969cdbd00882a6b76f66496707cf411711bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Mon, 11 Sep 2023 13:26:23 +0100 Subject: [PATCH 3/4] Add SKE example --- MIGRATION.md | 81 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 57928989f..5b472df05 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -11,17 +11,18 @@ For existing resources created with the old provider, you'll need to import them Once the configuration is generated, compare the generated file with your existing configuration. Be aware that field names may have changed so you should adapt the configuration accordingly. However, not all attributes from the generated configuration are needed for managing the infrastructure, meaning this set of fields can be reduced to the relevant ones from your previous configuration. Check the Terraform plan for the imported resource to identify any differences. -### Example (DNS service) +### Example (SKE service) Import configuration: ```terraform +# Import import { - id = "project_id,zone_id" - to = stackit_dns_zone.zone_resource_example + id = "project_id" + to = stackit_ske_project.project-example } import { - id = "project_id,zone_id,record_set_id" - to = stackit_dns_record_set.record_set_resource_example + id = "project_id,example-cluster" + to = stackit_ske_cluster.cluster-example } ``` @@ -30,34 +31,52 @@ Generated configuration: # __generated__ by Terraform # Please review these resources and move them into your main configuration files. -# __generated__ by Terraform from "project_id,zone_id" -resource "stackit_dns_zone" "zone_resource" { - acl = "0.0.0.0/0" - active = true - contact_email = "example@mail.com" - default_ttl = 123 - description = "This is a description" - dns_name = "example.com" - expire_time = 1209600 - is_reverse_zone = false - name = "example-zone" - negative_cache = 60 - primaries = [""] - project_id = "project_id" - refresh_time = 3600 - retry_time = 600 - type = "primary" +# __generated__ by Terraform from "project_id" +resource "stackit_ske_project" "project-example" { + project_id = "project_id" } -# __generated__ by Terraform from "project_id,zone_id,record_set_id" -resource "stackit_dns_record_set" "record_set_resource" { - active = true - comment = "This is a comment" - name = "example.com" +# __generated__ by Terraform from "project_id,example-cluster" +resource "stackit_ske_cluster" "cluster-example" { + allow_privileged_containers = null + extensions = null + hibernations = null + kubernetes_version = "1.25" + maintenance = { + enable_kubernetes_version_updates = true + enable_machine_image_version_updates = true + end = "09:47:00Z" + start = "08:47:00Z" + } + name = "example-cluster" + node_pools = [ + { + availability_zones = ["region-a", "region-b"] + cri = "containerd" + labels = { + l1 = "value1" + l2 = "value2" + } + machine_type = "b1.2" + max_surge = 1 + max_unavailable = 1 + maximum = 10 + minimum = 3 + name = "example-np" + os_name = "flatcar" + os_version = "3510.2.3" + taints = [ + { + effect = "PreferNoSchedule" + key = "tk" + value = "tkv" + }, + ] + volume_size = 40 + volume_type = "example-type" + }, + ] project_id = "project_id" - records = ["1.2.3.4"] - ttl = 123 - type = "A" - zone_id = "zone_id" } + ``` \ No newline at end of file From a66d3a517086123e6a14b51445856cff05b261e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Mon, 11 Sep 2023 13:54:43 +0100 Subject: [PATCH 4/4] Add LogMe instance and note for import issue --- MIGRATION.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/MIGRATION.md b/MIGRATION.md index 5b472df05..90513cc8a 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -78,5 +78,44 @@ resource "stackit_ske_cluster" "cluster-example" { ] project_id = "project_id" } +``` + +### Example (LogMe service) + +Import configuration: +```terraform +import { + id = "project_id,instance_id" + to = stackit_logme_instance.example-instance +} + +import { + id = "project_id,instance_id,credentials_id" + to = stackit_logme_credentials.example-credentials +} +``` + +Generated configuration: +```terraform +# __generated__ by Terraform +# Please review these resources and move them into your main configuration files. + +# __generated__ by Terraform +resource "stackit_logme_instance" "example-instance" { + name = "example-instance" + parameters = { + sgw_acl = "0.0.0.0/0" + } + plan_name = null + project_id = "project_id" + version = null +} + +# __generated__ by Terraform from "project_id,instance_id,credentials_id" +resource "stackit_logme_credentials" "example-credentials" { + instance_id = "instance_id" + project_id = "project_id" +} +``` -``` \ No newline at end of file +**_Note:_** Currently, when importing the LogMe (or any other DSA), you will see a `Missing Configuration for Required Attribute` error. This issue refers to the `plan_name` and `version` attributes, which are not returned by the API, and currently are solely used by the TFP to calculate the corresponding `plan_id`. We plan to enhance the provider's functionality soon to perform the reverse operation, generating the `plan_name` and `version` correctly. However, for the time being, you'll need to retrieve these values from an alternative source, e.g., the Portal. \ No newline at end of file