From 721e10a02f2eafbd60758476b4210842c11bb427 Mon Sep 17 00:00:00 2001 From: Alexander Dahmen Date: Fri, 8 Aug 2025 14:03:27 +0200 Subject: [PATCH] chore(examples): Add import examples for all resources (#939) * chore(examples): Add import examples for all resources Signed-off-by: Alexander Dahmen * Add guide: How to import resources Signed-off-by: Alexander Dahmen --------- Signed-off-by: Alexander Dahmen --- docs/guides/import_resources.md | 27 +++++++++++++++++ docs/resources/affinity_group.md | 6 ++++ ...horization_organization_role_assignment.md | 6 ++++ .../authorization_project_role_assignment.md | 6 ++++ docs/resources/cdn_custom_domain.md | 6 ++++ docs/resources/cdn_distribution.md | 8 ++++- docs/resources/dns_record_set.md | 6 ++++ docs/resources/dns_zone.md | 6 ++++ docs/resources/git.md | 6 ++++ docs/resources/image.md | 12 ++++++++ docs/resources/key_pair.md | 14 +++++++++ docs/resources/loadbalancer.md | 6 ++++ .../loadbalancer_observability_credential.md | 6 ++++ docs/resources/logme_credential.md | 6 ++++ docs/resources/logme_instance.md | 6 ++++ docs/resources/mariadb_credential.md | 6 ++++ docs/resources/mariadb_instance.md | 6 ++++ docs/resources/mongodbflex_instance.md | 6 ++++ docs/resources/mongodbflex_user.md | 6 ++++ docs/resources/network.md | 8 +++++ docs/resources/network_area.md | 6 ++++ docs/resources/network_area_route.md | 6 ++++ docs/resources/network_interface.md | 6 ++++ docs/resources/objectstorage_bucket.md | 6 ++++ docs/resources/objectstorage_credential.md | 6 ++++ .../objectstorage_credentials_group.md | 6 ++++ docs/resources/observability_alertgroup.md | 6 ++++ docs/resources/observability_instance.md | 6 ++++ docs/resources/observability_logalertgroup.md | 6 ++++ docs/resources/observability_scrapeconfig.md | 6 ++++ docs/resources/opensearch_credential.md | 6 ++++ docs/resources/opensearch_instance.md | 6 ++++ docs/resources/postgresflex_database.md | 6 ++++ docs/resources/postgresflex_instance.md | 6 ++++ docs/resources/postgresflex_user.md | 6 ++++ docs/resources/public_ip.md | 6 ++++ docs/resources/public_ip_associate.md | 6 ++++ docs/resources/rabbitmq_credential.md | 6 ++++ docs/resources/rabbitmq_instance.md | 6 ++++ docs/resources/redis_credential.md | 6 ++++ docs/resources/redis_instance.md | 6 ++++ docs/resources/resourcemanager_project.md | 8 +++++ docs/resources/routing_table.md | 6 ++++ docs/resources/routing_table_route.md | 6 ++++ docs/resources/secretsmanager_instance.md | 6 ++++ docs/resources/secretsmanager_user.md | 6 ++++ docs/resources/security_group.md | 6 ++++ docs/resources/security_group_rule.md | 8 +++++ docs/resources/server.md | 30 +++++++++++++++++++ docs/resources/server_backup_schedule.md | 6 ++++ .../server_network_interface_attach.md | 6 ++++ .../server_service_account_attach.md | 6 ++++ docs/resources/server_update_schedule.md | 6 ++++ docs/resources/server_volume_attach.md | 6 ++++ docs/resources/service_account.md | 6 ++++ docs/resources/ske_cluster.md | 6 ++++ docs/resources/sqlserverflex_instance.md | 6 ++++ docs/resources/sqlserverflex_user.md | 6 ++++ docs/resources/volume.md | 6 ++++ .../stackit_affinity_group/resource.tf | 6 ++++ .../resource.tf | 6 ++++ .../resource.tf | 6 ++++ .../stackit_cdn_custom_domain/resource.tf | 6 ++++ .../stackit_cdn_distribution/resource.tf | 8 ++++- .../stackit_dns_record_set/resource.tf | 6 ++++ .../resources/stackit_dns_zone/resource.tf | 6 ++++ examples/resources/stackit_git/resource.tf | 6 ++++ examples/resources/stackit_image/resource.tf | 12 ++++++++ .../resources/stackit_key_pair/resource.tf | 11 +++++++ .../stackit_loadbalancer/resource.tf | 8 ++++- .../resource.tf | 6 ++++ .../stackit_logme_credential/resource.tf | 6 ++++ .../stackit_logme_instance/resource.tf | 6 ++++ .../stackit_mariadb_credential/resource.tf | 6 ++++ .../stackit_mariadb_instance/resource.tf | 6 ++++ .../stackit_mongodbflex_instance/resource.tf | 6 ++++ .../stackit_mongodbflex_user/resource.tf | 6 ++++ .../resources/stackit_network/resource.tf | 8 +++++ .../stackit_network_area/resource.tf | 6 ++++ .../stackit_network_area_route/resource.tf | 6 ++++ .../stackit_network_interface/resource.tf | 6 ++++ .../stackit_objectstorage_bucket/resource.tf | 6 ++++ .../resource.tf | 6 ++++ .../resource.tf | 6 ++++ .../resource.tf | 8 ++++- .../resource.tf | 6 ++++ .../resource.tf | 8 ++++- .../resource.tf | 6 ++++ .../stackit_opensearch_credential/resource.tf | 6 ++++ .../stackit_opensearch_instance/resource.tf | 6 ++++ .../stackit_postgresflex_database/resource.tf | 6 ++++ .../stackit_postgresflex_instance/resource.tf | 6 ++++ .../stackit_postgresflex_user/resource.tf | 6 ++++ .../resources/stackit_public_ip/resource.tf | 6 ++++ .../stackit_public_ip_associate/resource.tf | 6 ++++ .../stackit_rabbitmq_credential/resource.tf | 6 ++++ .../stackit_rabbitmq_instance/resource.tf | 6 ++++ .../stackit_redis_credential/resource.tf | 6 ++++ .../stackit_redis_instance/resource.tf | 6 ++++ .../resource.tf | 8 +++++ .../stackit_routing_table/resource.tf | 6 ++++ .../stackit_routing_table_route/resource.tf | 6 ++++ .../resource.tf | 6 ++++ .../stackit_secretsmanager_user/resource.tf | 6 ++++ .../stackit_security_group/resource.tf | 6 ++++ .../stackit_security_group_rule/resource.tf | 8 +++++ examples/resources/stackit_server/resource.tf | 27 +++++++++++++++++ .../resource.tf | 6 ++++ .../resource.tf | 6 ++++ .../resource.tf | 6 ++++ .../resource.tf | 6 ++++ .../stackit_server_volume_attach/resource.tf | 6 ++++ .../stackit_service_account/resource.tf | 6 ++++ .../resources/stackit_ske_cluster/resource.tf | 6 ++++ .../resource.tf | 6 ++++ .../stackit_sqlserverflex_user/resource.tf | 6 ++++ examples/resources/stackit_volume/resource.tf | 6 ++++ templates/guides/import_resources.md | 27 +++++++++++++++++ 118 files changed, 837 insertions(+), 5 deletions(-) create mode 100644 docs/guides/import_resources.md create mode 100644 examples/resources/stackit_key_pair/resource.tf create mode 100644 examples/resources/stackit_server/resource.tf create mode 100644 templates/guides/import_resources.md diff --git a/docs/guides/import_resources.md b/docs/guides/import_resources.md new file mode 100644 index 00000000..6801624b --- /dev/null +++ b/docs/guides/import_resources.md @@ -0,0 +1,27 @@ +--- +page_title: "How to import an existing resources" +--- +# How to import an existing resources? + +## 1. **Create a terraform config file and add an import block for your resource** + +In order to import an existing resources in terraform you need to add an import block for the corresponding resource in a terraform config file. +There is an example for every resource under the [examples](../../examples/) folder. + +E.g. the import statement for a `stackit_volume` looks like the following: + +```terraform +import { + to = stackit_volume.import-example + id = "${var.project_id},${var.volume_id}" +} +``` + +## 2. **Generate the destination resource automatically** + +Run `terraform plan -generate-config-out=generated.tf` to let terraform generate the configuration for you. +In this step the `stackit_volume.import-example` resource is generated and filled with informations of your existing resource. + +## 3. **Finish the import** + +Run `terraform apply` to add your resource to the terraform state. \ No newline at end of file diff --git a/docs/resources/affinity_group.md b/docs/resources/affinity_group.md index bd1470e1..bd4d8bcd 100644 --- a/docs/resources/affinity_group.md +++ b/docs/resources/affinity_group.md @@ -87,6 +87,12 @@ resource "stackit_affinity_group" "example" { name = "example-affinity-group-name" policy = "hard-anti-affinity" } + +# Only use the import statement, if you want to import an existing affinity group +import { + to = stackit_affinity_group.import-example + id = "${var.project_id},${var.affinity_group_id}" +} ``` diff --git a/docs/resources/authorization_organization_role_assignment.md b/docs/resources/authorization_organization_role_assignment.md index a0b54dcd..3d8e0a27 100644 --- a/docs/resources/authorization_organization_role_assignment.md +++ b/docs/resources/authorization_organization_role_assignment.md @@ -21,6 +21,12 @@ resource "stackit_authorization_organization_role_assignment" "example" { role = "owner" subject = "john.doe@stackit.cloud" } + +# Only use the import statement, if you want to import an existing organization role assignment +import { + to = stackit_authorization_organization_role_assignment.import-example + id = "${var.organization_id},${var.org_role_assignment_role},${var.org_role_assignment_subject}" +} ``` diff --git a/docs/resources/authorization_project_role_assignment.md b/docs/resources/authorization_project_role_assignment.md index 82838f78..14164421 100644 --- a/docs/resources/authorization_project_role_assignment.md +++ b/docs/resources/authorization_project_role_assignment.md @@ -21,6 +21,12 @@ resource "stackit_authorization_project_role_assignment" "example" { role = "owner" subject = "john.doe@stackit.cloud" } + +# Only use the import statement, if you want to import an existing project role assignment +import { + to = stackit_authorization_project_role_assignment.import-example + id = "${var.project_id},${var.project_role_assignment_role},${var.project_role_assignment_subject}" +} ``` diff --git a/docs/resources/cdn_custom_domain.md b/docs/resources/cdn_custom_domain.md index 3d43181e..7bd977a2 100644 --- a/docs/resources/cdn_custom_domain.md +++ b/docs/resources/cdn_custom_domain.md @@ -21,6 +21,12 @@ resource "stackit_cdn_custom_domain" "example" { distribution_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "https://xxx.xxx" } + +# Only use the import statement, if you want to import an existing cdn custom domain +import { + to = stackit_cdn_custom_domain.import-example + id = "${var.project_id},${var.distribution_id},${var.custom_domain_name}" +} ``` diff --git a/docs/resources/cdn_distribution.md b/docs/resources/cdn_distribution.md index c9ad2688..4f8de4c1 100644 --- a/docs/resources/cdn_distribution.md +++ b/docs/resources/cdn_distribution.md @@ -21,7 +21,7 @@ resource "stackit_cdn_distribution" "example_distribution" { config = { backend = { type = "http" - origin_url = "mybackend.onstackit.cloud" + origin_url = "https://mybackend.onstackit.cloud" } regions = ["EU", "US", "ASIA", "AF", "SA"] blocked_countries = ["DE", "AT", "CH"] @@ -31,6 +31,12 @@ resource "stackit_cdn_distribution" "example_distribution" { } } } + +# Only use the import statement, if you want to import an existing cdn distribution +import { + to = stackit_cdn_distribution.import-example + id = "${var.project_id},${var.distribution_id}" +} ``` diff --git a/docs/resources/dns_record_set.md b/docs/resources/dns_record_set.md index a2c082ac..b52f7e0d 100644 --- a/docs/resources/dns_record_set.md +++ b/docs/resources/dns_record_set.md @@ -21,6 +21,12 @@ resource "stackit_dns_record_set" "example" { comment = "Example comment" records = ["1.2.3.4"] } + +# Only use the import statement, if you want to import an existing dns record set +import { + to = stackit_dns_record_set.import-example + id = "${var.project_id},${var.zone_id},${var.record_set_id}" +} ``` diff --git a/docs/resources/dns_zone.md b/docs/resources/dns_zone.md index 9a5f6488..e8b31e93 100644 --- a/docs/resources/dns_zone.md +++ b/docs/resources/dns_zone.md @@ -23,6 +23,12 @@ resource "stackit_dns_zone" "example" { description = "Example description" default_ttl = 1230 } + +# Only use the import statement, if you want to import an existing dns zone +import { + to = stackit_dns_zone.import-example + id = "${var.project_id},${var.zone_id}" +} ``` diff --git a/docs/resources/git.md b/docs/resources/git.md index 8ed2cb03..0fb6f2bf 100644 --- a/docs/resources/git.md +++ b/docs/resources/git.md @@ -29,6 +29,12 @@ resource "stackit_git" "git" { ] flavor = "git-100" } + +# Only use the import statement, if you want to import an existing git resource +import { + to = stackit_git.import-example + id = "${var.project_id},${var.git_instance_id}" +} ``` diff --git a/docs/resources/image.md b/docs/resources/image.md index eca41fac..abeeefc2 100644 --- a/docs/resources/image.md +++ b/docs/resources/image.md @@ -21,6 +21,18 @@ resource "stackit_image" "example_image" { min_disk_size = 10 min_ram = 5 } + +# Only use the import statement, if you want to import an existing image +# Must set a configuration value for the local_file_path attribute as the provider has marked it as required. +# Since this attribute is not fetched in general from the API call, after adding it this would replace your image resource after an terraform apply. +# In order to prevent this you need to add: +#lifecycle { +# ignore_changes = [ local_file_path ] +# } +import { + to = stackit_image.import-example + id = "${var.project_id},${var.image_id}" +} ``` diff --git a/docs/resources/key_pair.md b/docs/resources/key_pair.md index 69aaf59d..45925f0f 100644 --- a/docs/resources/key_pair.md +++ b/docs/resources/key_pair.md @@ -53,7 +53,21 @@ resource "stackit_server" "example-server" { ``` +## Example Usage +```terraform +# Create a key pair +resource "stackit_key_pair" "keypair" { + name = "example-key-pair" + public_key = chomp(file("path/to/id_rsa.pub")) +} + +# Only use the import statement, if you want to import an existing key pair +import { + to = stackit_key_pair.import-example + id = var.keypair_name +} +``` ## Schema diff --git a/docs/resources/loadbalancer.md b/docs/resources/loadbalancer.md index 18c15651..ab77a41d 100644 --- a/docs/resources/loadbalancer.md +++ b/docs/resources/loadbalancer.md @@ -109,6 +109,12 @@ resource "stackit_loadbalancer" "example" { private_network_only = false } } + +# Only use the import statement, if you want to import an existing loadbalancer +import { + to = stackit_loadbalancer.import-example + id = "${var.project_id},${var.region},${var.loadbalancer_name}" +} ``` diff --git a/docs/resources/loadbalancer_observability_credential.md b/docs/resources/loadbalancer_observability_credential.md index a4171aa2..3d00c6c3 100644 --- a/docs/resources/loadbalancer_observability_credential.md +++ b/docs/resources/loadbalancer_observability_credential.md @@ -19,6 +19,12 @@ resource "stackit_loadbalancer_observability_credential" "example" { username = "example-user" password = "example-password" } + +# Only use the import statement, if you want to import an existing loadbalancer observability credential +import { + to = stackit_loadbalancer_observability_credential.import-example + id = "${var.project_id},${var.region},${var.credentials_ref}" +} ``` diff --git a/docs/resources/logme_credential.md b/docs/resources/logme_credential.md index ebf0df8d..74a598c6 100644 --- a/docs/resources/logme_credential.md +++ b/docs/resources/logme_credential.md @@ -17,6 +17,12 @@ resource "stackit_logme_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing logme credential +import { + to = stackit_logme_credential.import-example + id = "${var.project_id},${var.logme_instance_id},${var.logme_credentials_id}" +} ``` diff --git a/docs/resources/logme_instance.md b/docs/resources/logme_instance.md index b4b99ea0..74b6f214 100644 --- a/docs/resources/logme_instance.md +++ b/docs/resources/logme_instance.md @@ -22,6 +22,12 @@ resource "stackit_logme_instance" "example" { sgw_acl = "193.148.160.0/19,45.129.40.0/21,45.135.244.0/22" } } + +# Only use the import statement, if you want to import an existing logme instance +import { + to = stackit_logme_instance.import-example + id = "${var.project_id},${var.logme_instance_id}" +} ``` diff --git a/docs/resources/mariadb_credential.md b/docs/resources/mariadb_credential.md index a9d69642..d0ea4d1f 100644 --- a/docs/resources/mariadb_credential.md +++ b/docs/resources/mariadb_credential.md @@ -17,6 +17,12 @@ resource "stackit_mariadb_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing mariadb credential +import { + to = stackit_mariadb_credential.import-example + id = "${var.project_id},${var.mariadb_instance_id},${var.mariadb_credential_id}" +} ``` diff --git a/docs/resources/mariadb_instance.md b/docs/resources/mariadb_instance.md index 65406125..4814286b 100644 --- a/docs/resources/mariadb_instance.md +++ b/docs/resources/mariadb_instance.md @@ -22,6 +22,12 @@ resource "stackit_mariadb_instance" "example" { sgw_acl = "193.148.160.0/19,45.129.40.0/21,45.135.244.0/22" } } + +# Only use the import statement, if you want to import an existing mariadb instance +import { + to = stackit_mariadb_instance.import-example + id = "${var.project_id},${var.mariadb_instance_id}" +} ``` diff --git a/docs/resources/mongodbflex_instance.md b/docs/resources/mongodbflex_instance.md index b09b8ced..27ab7a04 100644 --- a/docs/resources/mongodbflex_instance.md +++ b/docs/resources/mongodbflex_instance.md @@ -34,6 +34,12 @@ resource "stackit_mongodbflex_instance" "example" { } backup_schedule = "0 0 * * *" } + +# Only use the import statement, if you want to import an existing mongodbflex instance +import { + to = stackit_mongodbflex_instance.import-example + id = "${var.project_id},${var.region},${var.instance_id}" +} ``` diff --git a/docs/resources/mongodbflex_user.md b/docs/resources/mongodbflex_user.md index c2a7d234..0e113302 100644 --- a/docs/resources/mongodbflex_user.md +++ b/docs/resources/mongodbflex_user.md @@ -20,6 +20,12 @@ resource "stackit_mongodbflex_user" "example" { roles = ["role"] database = "database" } + +# Only use the import statement, if you want to import an existing mongodbflex user +import { + to = stackit_mongodbflex_user.import-example + id = "${var.project_id},${var.region},${var.instance_id},${user_id}" +} ``` diff --git a/docs/resources/network.md b/docs/resources/network.md index a149519b..089eedaf 100644 --- a/docs/resources/network.md +++ b/docs/resources/network.md @@ -39,6 +39,14 @@ resource "stackit_network" "example_non_routed_network" { } routed = false } + +# Only use the import statement, if you want to import an existing network +# Note: There will be a conflict which needs to be resolved manually. +# These attributes cannot be configured together: [ipv4_prefix,ipv4_prefix_length,ipv4_gateway] +import { + to = stackit_network.import-example + id = "${var.project_id},${var.network_id}" +} ``` diff --git a/docs/resources/network_area.md b/docs/resources/network_area.md index 19be56f1..46c308d3 100644 --- a/docs/resources/network_area.md +++ b/docs/resources/network_area.md @@ -26,6 +26,12 @@ resource "stackit_network_area" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing network area +import { + to = stackit_network_area.import-example + id = "${var.organization_id},${var.network_area_id}" +} ``` diff --git a/docs/resources/network_area_route.md b/docs/resources/network_area_route.md index e9c0693f..a7f05460 100644 --- a/docs/resources/network_area_route.md +++ b/docs/resources/network_area_route.md @@ -22,6 +22,12 @@ resource "stackit_network_area_route" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing network area route +import { + to = stackit_network_area_route.import-example + id = "${var.organization_id},${var.network_area_id},${var.network_area_route_id}" +} ``` diff --git a/docs/resources/network_interface.md b/docs/resources/network_interface.md index 6f264ad2..7d01c9d3 100644 --- a/docs/resources/network_interface.md +++ b/docs/resources/network_interface.md @@ -19,6 +19,12 @@ resource "stackit_network_interface" "example" { allowed_addresses = ["192.168.0.0/24"] security_group_ids = ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"] } + +# Only use the import statement, if you want to import an existing network interface +import { + to = stackit_network_interface.import-example + id = "${var.project_id},${var.network_id},${var.network_interface_id}" +} ``` diff --git a/docs/resources/objectstorage_bucket.md b/docs/resources/objectstorage_bucket.md index 9298ffc5..7abc9dbf 100644 --- a/docs/resources/objectstorage_bucket.md +++ b/docs/resources/objectstorage_bucket.md @@ -17,6 +17,12 @@ resource "stackit_objectstorage_bucket" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "example-bucket" } + +# Only use the import statement, if you want to import an existing objectstorage bucket +import { + to = stackit_objectstorage_bucket.import-example + id = "${var.project_id},${var.region},${var.bucket_name}" +} ``` diff --git a/docs/resources/objectstorage_credential.md b/docs/resources/objectstorage_credential.md index 9d9f5980..037c4a78 100644 --- a/docs/resources/objectstorage_credential.md +++ b/docs/resources/objectstorage_credential.md @@ -18,6 +18,12 @@ resource "stackit_objectstorage_credential" "example" { credentials_group_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" expiration_timestamp = "2027-01-02T03:04:05Z" } + +# Only use the import statement, if you want to import an existing objectstorage credential +import { + to = stackit_objectstorage_credential.import-example + id = "${var.project_id},${var.region},${var.bucket_credentials_group_id},${var.bucket_credential_id}" +} ``` diff --git a/docs/resources/objectstorage_credentials_group.md b/docs/resources/objectstorage_credentials_group.md index 67ec71a6..9115a0c7 100644 --- a/docs/resources/objectstorage_credentials_group.md +++ b/docs/resources/objectstorage_credentials_group.md @@ -17,6 +17,12 @@ resource "stackit_objectstorage_credentials_group" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "example-credentials-group" } + +# Only use the import statement, if you want to import an existing objectstorage credential group +import { + to = stackit_objectstorage_credentials_group.import-example + id = "${var.project_id},${var.region},${var.bucket_credentials_group_id}" +} ``` diff --git a/docs/resources/observability_alertgroup.md b/docs/resources/observability_alertgroup.md index ea16ea94..0502ea64 100644 --- a/docs/resources/observability_alertgroup.md +++ b/docs/resources/observability_alertgroup.md @@ -45,6 +45,12 @@ resource "stackit_observability_alertgroup" "example" { }, ] } + +# Only use the import statement, if you want to import an existing observability alertgroup +import { + to = stackit_observability_alertgroup.import-example + id = "${var.project_id},${var.observability_instance_id},${var.observability_alertgroup_name}" +} ``` diff --git a/docs/resources/observability_instance.md b/docs/resources/observability_instance.md index 3c8cebbd..eda0c5a2 100644 --- a/docs/resources/observability_instance.md +++ b/docs/resources/observability_instance.md @@ -22,6 +22,12 @@ resource "stackit_observability_instance" "example" { metrics_retention_days_5m_downsampling = 10 metrics_retention_days_1h_downsampling = 5 } + +# Only use the import statement, if you want to import an existing observability instance +import { + to = stackit_observability_instance.import-example + id = "${var.project_id},${var.observability_instance_id}" +} ``` diff --git a/docs/resources/observability_logalertgroup.md b/docs/resources/observability_logalertgroup.md index 630e92c2..5b38cf66 100644 --- a/docs/resources/observability_logalertgroup.md +++ b/docs/resources/observability_logalertgroup.md @@ -45,6 +45,12 @@ resource "stackit_observability_logalertgroup" "example" { }, ] } + +# Only use the import statement, if you want to import an existing observability logalertgroup +import { + to = stackit_observability_logalertgroup.import-example + id = "${var.project_id},${var.observability_instance_id},${var.observability_logalertgroup_name}" +} ``` diff --git a/docs/resources/observability_scrapeconfig.md b/docs/resources/observability_scrapeconfig.md index af24708b..9840a2e4 100644 --- a/docs/resources/observability_scrapeconfig.md +++ b/docs/resources/observability_scrapeconfig.md @@ -30,6 +30,12 @@ resource "stackit_observability_scrapeconfig" "example" { } ] } + +# Only use the import statement, if you want to import an existing observability scrapeconfig +import { + to = stackit_observability_scrapeconfig.import-example + id = "${var.project_id},${var.observability_instance_id},${var.observability_scrapeconfig_name}" +} ``` diff --git a/docs/resources/opensearch_credential.md b/docs/resources/opensearch_credential.md index c8fd77f9..113adf91 100644 --- a/docs/resources/opensearch_credential.md +++ b/docs/resources/opensearch_credential.md @@ -17,6 +17,12 @@ resource "stackit_opensearch_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing opensearch credential +import { + to = stackit_opensearch_credential.import-example + id = "${var.project_id},${var.instance_id},${var.credential_id}" +} ``` diff --git a/docs/resources/opensearch_instance.md b/docs/resources/opensearch_instance.md index 14d2adb0..5ca0a8b8 100644 --- a/docs/resources/opensearch_instance.md +++ b/docs/resources/opensearch_instance.md @@ -22,6 +22,12 @@ resource "stackit_opensearch_instance" "example" { sgw_acl = "193.148.160.0/19,45.129.40.0/21,45.135.244.0/22" } } + +# Only use the import statement, if you want to import an existing opensearch instance +import { + to = stackit_opensearch_instance.import-example + id = "${var.project_id},${var.instance_id}" +} ``` diff --git a/docs/resources/postgresflex_database.md b/docs/resources/postgresflex_database.md index e55f60e5..b9363141 100644 --- a/docs/resources/postgresflex_database.md +++ b/docs/resources/postgresflex_database.md @@ -19,6 +19,12 @@ resource "stackit_postgresflex_database" "example" { name = "mydb" owner = "myusername" } + +# Only use the import statement, if you want to import an existing postgresflex database +import { + to = stackit_postgresflex_database.import-example + id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.postgres_database_id}" +} ``` diff --git a/docs/resources/postgresflex_instance.md b/docs/resources/postgresflex_instance.md index e3e38dc6..46dfdbc3 100644 --- a/docs/resources/postgresflex_instance.md +++ b/docs/resources/postgresflex_instance.md @@ -29,6 +29,12 @@ resource "stackit_postgresflex_instance" "example" { } version = 14 } + +# Only use the import statement, if you want to import an existing postgresflex instance +import { + to = stackit_postgresflex_instance.import-example + id = "${var.project_id},${var.region},${var.postgres_instance_id}" +} ``` diff --git a/docs/resources/postgresflex_user.md b/docs/resources/postgresflex_user.md index aa380d9a..1e136013 100644 --- a/docs/resources/postgresflex_user.md +++ b/docs/resources/postgresflex_user.md @@ -19,6 +19,12 @@ resource "stackit_postgresflex_user" "example" { username = "username" roles = ["role"] } + +# Only use the import statement, if you want to import an existing postgresflex user +import { + to = stackit_postgresflex_user.import-example + id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.user_id}" +} ``` diff --git a/docs/resources/public_ip.md b/docs/resources/public_ip.md index ab3e7593..fad2560d 100644 --- a/docs/resources/public_ip.md +++ b/docs/resources/public_ip.md @@ -20,6 +20,12 @@ resource "stackit_public_ip" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing public ip +import { + to = stackit_public_ip.import-example + id = "${var.project_id},${var.public_ip_id}" +} ``` diff --git a/docs/resources/public_ip_associate.md b/docs/resources/public_ip_associate.md index 58285593..098e6ff5 100644 --- a/docs/resources/public_ip_associate.md +++ b/docs/resources/public_ip_associate.md @@ -23,6 +23,12 @@ resource "stackit_public_ip_associate" "example" { public_ip_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" network_interface_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing public ip associate +import { + to = stackit_public_ip_associate.import-example + id = "${var.project_id},${var.public_ip_id},${var.network_interface_id}" +} ``` diff --git a/docs/resources/rabbitmq_credential.md b/docs/resources/rabbitmq_credential.md index 0662fcdb..de60bfb8 100644 --- a/docs/resources/rabbitmq_credential.md +++ b/docs/resources/rabbitmq_credential.md @@ -17,6 +17,12 @@ resource "stackit_rabbitmq_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing rabbitmq credential +import { + to = stackit_rabbitmq_credential.import-example + id = "${var.project_id},${var.rabbitmq_instance_id},${var.rabbitmq_credential_id}" +} ``` diff --git a/docs/resources/rabbitmq_instance.md b/docs/resources/rabbitmq_instance.md index 65a26ba8..40cf2ab0 100644 --- a/docs/resources/rabbitmq_instance.md +++ b/docs/resources/rabbitmq_instance.md @@ -25,6 +25,12 @@ resource "stackit_rabbitmq_instance" "example" { plugins = ["rabbitmq_consistent_hash_exchange", "rabbitmq_federation", "rabbitmq_tracing"] } } + +# Only use the import statement, if you want to import an existing rabbitmq instance +import { + to = stackit_rabbitmq_instance.import-example + id = "${var.project_id},${var.rabbitmq_instance_id}" +} ``` diff --git a/docs/resources/redis_credential.md b/docs/resources/redis_credential.md index 8f5089f0..2e2674a2 100644 --- a/docs/resources/redis_credential.md +++ b/docs/resources/redis_credential.md @@ -17,6 +17,12 @@ resource "stackit_redis_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing redis credential +import { + to = stackit_redis_credential.import-example + id = "${var.project_id},${var.redis_instance_id},${var.redis_credential_id}" +} ``` diff --git a/docs/resources/redis_instance.md b/docs/resources/redis_instance.md index 8c22b860..40f63b81 100644 --- a/docs/resources/redis_instance.md +++ b/docs/resources/redis_instance.md @@ -25,6 +25,12 @@ resource "stackit_redis_instance" "example" { syslog = ["logs4.your-syslog-endpoint.com:54321"] } } + +# Only use the import statement, if you want to import an existing redis instance +import { + to = stackit_redis_instance.import-example + id = "${var.project_id},${var.redis_instance_id}" +} ``` diff --git a/docs/resources/resourcemanager_project.md b/docs/resources/resourcemanager_project.md index cfc1de4f..ce7e3095 100644 --- a/docs/resources/resourcemanager_project.md +++ b/docs/resources/resourcemanager_project.md @@ -25,6 +25,14 @@ resource "stackit_resourcemanager_project" "example" { } owner_email = "john.doe@stackit.cloud" } + +# Only use the import statement, if you want to import an existing resourcemanager project +# Note: There will be a conflict which needs to be resolved manually. +# Must set a configuration value for the owner_email attribute as the provider has marked it as required. +import { + to = stackit_resourcemanager_project.import-example + id = var.container_id +} ``` diff --git a/docs/resources/routing_table.md b/docs/resources/routing_table.md index 54e81c49..ff6e00e3 100644 --- a/docs/resources/routing_table.md +++ b/docs/resources/routing_table.md @@ -24,6 +24,12 @@ resource "stackit_routing_table" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing routing table +import { + to = stackit_routing_table.import-example + id = "${var.organization_id},${var.region},${var.network_area_id},${var.routing_table_id}" +} ``` diff --git a/docs/resources/routing_table_route.md b/docs/resources/routing_table_route.md index 5b37be89..bf02c00b 100644 --- a/docs/resources/routing_table_route.md +++ b/docs/resources/routing_table_route.md @@ -32,6 +32,12 @@ resource "stackit_routing_table_route" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing routing table route +import { + to = stackit_routing_table_route.import-example + id = "${var.organization_id},${var.region},${var.network_area_id},${var.routing_table_id},${var.routing_table_route_id}" +} ``` diff --git a/docs/resources/secretsmanager_instance.md b/docs/resources/secretsmanager_instance.md index 4b9fc20c..8848b37d 100644 --- a/docs/resources/secretsmanager_instance.md +++ b/docs/resources/secretsmanager_instance.md @@ -18,6 +18,12 @@ resource "stackit_secretsmanager_instance" "example" { name = "example-instance" acls = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] } + +# Only use the import statement, if you want to import an existing secretsmanager instance +import { + to = stackit_secretsmanager_instance.import-example + id = "${var.project_id},${var.secret_instance_id}" +} ``` diff --git a/docs/resources/secretsmanager_user.md b/docs/resources/secretsmanager_user.md index 4c79a3d8..6f592222 100644 --- a/docs/resources/secretsmanager_user.md +++ b/docs/resources/secretsmanager_user.md @@ -19,6 +19,12 @@ resource "stackit_secretsmanager_user" "example" { description = "Example user" write_enabled = false } + +# Only use the import statement, if you want to import an existing secretsmanager user +import { + to = stackit_secretsmanager_user.import-example + id = "${var.project_id},${var.secret_instance_id},${var.secret_user_id}" +} ``` diff --git a/docs/resources/security_group.md b/docs/resources/security_group.md index f2b6915b..c4f9d06c 100644 --- a/docs/resources/security_group.md +++ b/docs/resources/security_group.md @@ -20,6 +20,12 @@ resource "stackit_security_group" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing security group +import { + to = stackit_security_group.import-example + id = "${var.project_id},${var.security_group_id}" +} ``` diff --git a/docs/resources/security_group_rule.md b/docs/resources/security_group_rule.md index bf789bf6..0b20ca84 100644 --- a/docs/resources/security_group_rule.md +++ b/docs/resources/security_group_rule.md @@ -25,6 +25,14 @@ resource "stackit_security_group_rule" "example" { name = "icmp" } } + +# Only use the import statement, if you want to import an existing security group rule +# Note: There will be a conflict which needs to be resolved manually. +# Attribute "protocol.number" cannot be specified when "protocol.name" is specified. +import { + to = stackit_security_group_rule.import-example + id = "${var.project_id},${var.security_group_id},${var.security_group_rule_id}" +} ``` diff --git a/docs/resources/server.md b/docs/resources/server.md index f5aefa37..4a0639b0 100644 --- a/docs/resources/server.md +++ b/docs/resources/server.md @@ -360,7 +360,37 @@ resource "stackit_server" "user-data-from-file" { ``` +## Example Usage +```terraform +resource "stackit_server" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + name = "example-server" + boot_volume = { + size = 64 + source_type = "image" + source_id = "59838a89-51b1-4892-b57f-b3caf598ee2f" // Ubuntu 24.04 + } + availability_zone = "xxxx-x" + machine_type = "g1.1" + network_interfaces = [ + stackit_network_interface.example.network_interface_id + ] +} + +# Only use the import statement, if you want to import an existing server +# Note: There will be a conflict which needs to be resolved manually. +# Must set a configuration value for the boot_volume.source_type and boot_volume.source_id attribute as the provider has marked it as required. +# Since those attributes are not fetched in general from the API call, after adding them this would replace your server resource after an terraform apply. +# In order to prevent this you need to add: +# lifecycle { +# ignore_changes = [ boot_volume ] +# } +import { + to = stackit_server.import-example + id = "${var.project_id},${var.server_id}" +} +``` ## Schema diff --git a/docs/resources/server_backup_schedule.md b/docs/resources/server_backup_schedule.md index 0d25b464..80f6fc56 100644 --- a/docs/resources/server_backup_schedule.md +++ b/docs/resources/server_backup_schedule.md @@ -28,6 +28,12 @@ resource "stackit_server_backup_schedule" "example" { volume_ids = null } } + +# Only use the import statement, if you want to import an existing server backup schedule +import { + to = stackit_server_backup_schedule.import-example + id = "${var.project_id},${var.region},${var.server_id},${var.server_backup_schedule_id}" +} ``` diff --git a/docs/resources/server_network_interface_attach.md b/docs/resources/server_network_interface_attach.md index b2cd6b1f..b6c99ce0 100644 --- a/docs/resources/server_network_interface_attach.md +++ b/docs/resources/server_network_interface_attach.md @@ -18,6 +18,12 @@ resource "stackit_server_network_interface_attach" "attached_network_interface" server_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" network_interface_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing server network interface attachment +import { + to = stackit_server_network_interface_attach.import-example + id = "${var.project_id},${var.server_id},${var.network_interface_id}" +} ``` diff --git a/docs/resources/server_service_account_attach.md b/docs/resources/server_service_account_attach.md index 40034417..2b02b074 100644 --- a/docs/resources/server_service_account_attach.md +++ b/docs/resources/server_service_account_attach.md @@ -18,6 +18,12 @@ resource "stackit_server_service_account_attach" "attached_service_account" { server_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" service_account_email = "service-account@stackit.cloud" } + +# Only use the import statement, if you want to import an existing server service account attachment +import { + to = stackit_server_service_account_attach.import-example + id = "${var.project_id},${var.server_id},${var.service_account_email}" +} ``` diff --git a/docs/resources/server_update_schedule.md b/docs/resources/server_update_schedule.md index 8b4fa218..f0c00c88 100644 --- a/docs/resources/server_update_schedule.md +++ b/docs/resources/server_update_schedule.md @@ -24,6 +24,12 @@ resource "stackit_server_update_schedule" "example" { enabled = true maintenance_window = 1 } + +# Only use the import statement, if you want to import an existing server update schedule +import { + to = stackit_server_update_schedule.import-example + id = "${var.project_id},${var.region},${var.server_id},${var.server_update_schedule_id}" +} ``` diff --git a/docs/resources/server_volume_attach.md b/docs/resources/server_volume_attach.md index 8743717d..93c5862e 100644 --- a/docs/resources/server_volume_attach.md +++ b/docs/resources/server_volume_attach.md @@ -18,6 +18,12 @@ resource "stackit_server_volume_attach" "attached_volume" { server_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" volume_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing server volume attachment +import { + to = stackit_server_volume_attach.import-example + id = "${var.project_id},${var.server_id},${var.volume_id}" +} ``` diff --git a/docs/resources/service_account.md b/docs/resources/service_account.md index 3a8c712f..23684418 100644 --- a/docs/resources/service_account.md +++ b/docs/resources/service_account.md @@ -17,6 +17,12 @@ resource "stackit_service_account" "sa" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "sa01" } + +# Only use the import statement, if you want to import an existing service account +import { + to = stackit_service_account.import-example + id = "${var.project_id},${var.service_account_email}" +} ``` diff --git a/docs/resources/ske_cluster.md b/docs/resources/ske_cluster.md index 597064ad..2391def1 100644 --- a/docs/resources/ske_cluster.md +++ b/docs/resources/ske_cluster.md @@ -37,6 +37,12 @@ resource "stackit_ske_cluster" "example" { end = "02:00:00Z" } } + +# Only use the import statement, if you want to import an existing ske cluster +import { + to = stackit_ske_cluster.import-example + id = "${var.project_id},${var.region},${var.ske_name}" +} ``` diff --git a/docs/resources/sqlserverflex_instance.md b/docs/resources/sqlserverflex_instance.md index ee6bf5c7..2d88f429 100644 --- a/docs/resources/sqlserverflex_instance.md +++ b/docs/resources/sqlserverflex_instance.md @@ -28,6 +28,12 @@ resource "stackit_sqlserverflex_instance" "example" { } version = 2022 } + +# Only use the import statement, if you want to import an existing sqlserverflex instance +import { + to = stackit_sqlserverflex_instance.import-example + id = "${var.project_id},${var.region},${var.sql_instance_id}" +} ``` diff --git a/docs/resources/sqlserverflex_user.md b/docs/resources/sqlserverflex_user.md index 38df09d5..e616e272 100644 --- a/docs/resources/sqlserverflex_user.md +++ b/docs/resources/sqlserverflex_user.md @@ -19,6 +19,12 @@ resource "stackit_sqlserverflex_user" "example" { username = "username" roles = ["role"] } + +# Only use the import statement, if you want to import an existing sqlserverflex user +import { + to = stackit_sqlserverflex_user.import-example + id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}" +} ``` diff --git a/docs/resources/volume.md b/docs/resources/volume.md index d3de9cc8..be2b3cdf 100644 --- a/docs/resources/volume.md +++ b/docs/resources/volume.md @@ -22,6 +22,12 @@ resource "stackit_volume" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing volume +import { + to = stackit_volume.import-example + id = "${var.project_id},${var.volume_id}" +} ``` diff --git a/examples/resources/stackit_affinity_group/resource.tf b/examples/resources/stackit_affinity_group/resource.tf index b222dc55..7b4800a8 100644 --- a/examples/resources/stackit_affinity_group/resource.tf +++ b/examples/resources/stackit_affinity_group/resource.tf @@ -2,4 +2,10 @@ resource "stackit_affinity_group" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "example-affinity-group-name" policy = "hard-anti-affinity" +} + +# Only use the import statement, if you want to import an existing affinity group +import { + to = stackit_affinity_group.import-example + id = "${var.project_id},${var.affinity_group_id}" } \ No newline at end of file diff --git a/examples/resources/stackit_authorization_organization_role_assignment/resource.tf b/examples/resources/stackit_authorization_organization_role_assignment/resource.tf index 7875cf7f..f717c334 100644 --- a/examples/resources/stackit_authorization_organization_role_assignment/resource.tf +++ b/examples/resources/stackit_authorization_organization_role_assignment/resource.tf @@ -3,3 +3,9 @@ resource "stackit_authorization_organization_role_assignment" "example" { role = "owner" subject = "john.doe@stackit.cloud" } + +# Only use the import statement, if you want to import an existing organization role assignment +import { + to = stackit_authorization_organization_role_assignment.import-example + id = "${var.organization_id},${var.org_role_assignment_role},${var.org_role_assignment_subject}" +} diff --git a/examples/resources/stackit_authorization_project_role_assignment/resource.tf b/examples/resources/stackit_authorization_project_role_assignment/resource.tf index fc0b9764..a335c5fd 100644 --- a/examples/resources/stackit_authorization_project_role_assignment/resource.tf +++ b/examples/resources/stackit_authorization_project_role_assignment/resource.tf @@ -3,3 +3,9 @@ resource "stackit_authorization_project_role_assignment" "example" { role = "owner" subject = "john.doe@stackit.cloud" } + +# Only use the import statement, if you want to import an existing project role assignment +import { + to = stackit_authorization_project_role_assignment.import-example + id = "${var.project_id},${var.project_role_assignment_role},${var.project_role_assignment_subject}" +} diff --git a/examples/resources/stackit_cdn_custom_domain/resource.tf b/examples/resources/stackit_cdn_custom_domain/resource.tf index 92cfb34d..9f5f6f36 100644 --- a/examples/resources/stackit_cdn_custom_domain/resource.tf +++ b/examples/resources/stackit_cdn_custom_domain/resource.tf @@ -3,3 +3,9 @@ resource "stackit_cdn_custom_domain" "example" { distribution_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "https://xxx.xxx" } + +# Only use the import statement, if you want to import an existing cdn custom domain +import { + to = stackit_cdn_custom_domain.import-example + id = "${var.project_id},${var.distribution_id},${var.custom_domain_name}" +} \ No newline at end of file diff --git a/examples/resources/stackit_cdn_distribution/resource.tf b/examples/resources/stackit_cdn_distribution/resource.tf index ebdae25e..9356ca1e 100644 --- a/examples/resources/stackit_cdn_distribution/resource.tf +++ b/examples/resources/stackit_cdn_distribution/resource.tf @@ -3,7 +3,7 @@ resource "stackit_cdn_distribution" "example_distribution" { config = { backend = { type = "http" - origin_url = "mybackend.onstackit.cloud" + origin_url = "https://mybackend.onstackit.cloud" } regions = ["EU", "US", "ASIA", "AF", "SA"] blocked_countries = ["DE", "AT", "CH"] @@ -13,3 +13,9 @@ resource "stackit_cdn_distribution" "example_distribution" { } } } + +# Only use the import statement, if you want to import an existing cdn distribution +import { + to = stackit_cdn_distribution.import-example + id = "${var.project_id},${var.distribution_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_dns_record_set/resource.tf b/examples/resources/stackit_dns_record_set/resource.tf index 9a910fe5..96fe9443 100644 --- a/examples/resources/stackit_dns_record_set/resource.tf +++ b/examples/resources/stackit_dns_record_set/resource.tf @@ -6,3 +6,9 @@ resource "stackit_dns_record_set" "example" { comment = "Example comment" records = ["1.2.3.4"] } + +# Only use the import statement, if you want to import an existing dns record set +import { + to = stackit_dns_record_set.import-example + id = "${var.project_id},${var.zone_id},${var.record_set_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_dns_zone/resource.tf b/examples/resources/stackit_dns_zone/resource.tf index 7aa30348..431e26b4 100644 --- a/examples/resources/stackit_dns_zone/resource.tf +++ b/examples/resources/stackit_dns_zone/resource.tf @@ -8,3 +8,9 @@ resource "stackit_dns_zone" "example" { description = "Example description" default_ttl = 1230 } + +# Only use the import statement, if you want to import an existing dns zone +import { + to = stackit_dns_zone.import-example + id = "${var.project_id},${var.zone_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_git/resource.tf b/examples/resources/stackit_git/resource.tf index fc5de072..a7e02c82 100644 --- a/examples/resources/stackit_git/resource.tf +++ b/examples/resources/stackit_git/resource.tf @@ -10,4 +10,10 @@ resource "stackit_git" "git" { "0.0.0.0/0" ] flavor = "git-100" +} + +# Only use the import statement, if you want to import an existing git resource +import { + to = stackit_git.import-example + id = "${var.project_id},${var.git_instance_id}" } \ No newline at end of file diff --git a/examples/resources/stackit_image/resource.tf b/examples/resources/stackit_image/resource.tf index de3253b0..a6449223 100644 --- a/examples/resources/stackit_image/resource.tf +++ b/examples/resources/stackit_image/resource.tf @@ -6,3 +6,15 @@ resource "stackit_image" "example_image" { min_disk_size = 10 min_ram = 5 } + +# Only use the import statement, if you want to import an existing image +# Must set a configuration value for the local_file_path attribute as the provider has marked it as required. +# Since this attribute is not fetched in general from the API call, after adding it this would replace your image resource after an terraform apply. +# In order to prevent this you need to add: +#lifecycle { +# ignore_changes = [ local_file_path ] +# } +import { + to = stackit_image.import-example + id = "${var.project_id},${var.image_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_key_pair/resource.tf b/examples/resources/stackit_key_pair/resource.tf new file mode 100644 index 00000000..6f575bfe --- /dev/null +++ b/examples/resources/stackit_key_pair/resource.tf @@ -0,0 +1,11 @@ +# Create a key pair +resource "stackit_key_pair" "keypair" { + name = "example-key-pair" + public_key = chomp(file("path/to/id_rsa.pub")) +} + +# Only use the import statement, if you want to import an existing key pair +import { + to = stackit_key_pair.import-example + id = var.keypair_name +} \ No newline at end of file diff --git a/examples/resources/stackit_loadbalancer/resource.tf b/examples/resources/stackit_loadbalancer/resource.tf index 34dcdf49..fd720c50 100644 --- a/examples/resources/stackit_loadbalancer/resource.tf +++ b/examples/resources/stackit_loadbalancer/resource.tf @@ -89,4 +89,10 @@ resource "stackit_loadbalancer" "example" { options = { private_network_only = false } -} \ No newline at end of file +} + +# Only use the import statement, if you want to import an existing loadbalancer +import { + to = stackit_loadbalancer.import-example + id = "${var.project_id},${var.region},${var.loadbalancer_name}" +} diff --git a/examples/resources/stackit_loadbalancer_observability_credential/resource.tf b/examples/resources/stackit_loadbalancer_observability_credential/resource.tf index 290c5319..7b29fb3b 100644 --- a/examples/resources/stackit_loadbalancer_observability_credential/resource.tf +++ b/examples/resources/stackit_loadbalancer_observability_credential/resource.tf @@ -4,3 +4,9 @@ resource "stackit_loadbalancer_observability_credential" "example" { username = "example-user" password = "example-password" } + +# Only use the import statement, if you want to import an existing loadbalancer observability credential +import { + to = stackit_loadbalancer_observability_credential.import-example + id = "${var.project_id},${var.region},${var.credentials_ref}" +} diff --git a/examples/resources/stackit_logme_credential/resource.tf b/examples/resources/stackit_logme_credential/resource.tf index 94d917f0..c0c0c720 100644 --- a/examples/resources/stackit_logme_credential/resource.tf +++ b/examples/resources/stackit_logme_credential/resource.tf @@ -2,3 +2,9 @@ resource "stackit_logme_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing logme credential +import { + to = stackit_logme_credential.import-example + id = "${var.project_id},${var.logme_instance_id},${var.logme_credentials_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_logme_instance/resource.tf b/examples/resources/stackit_logme_instance/resource.tf index f53f2c6a..e95eeb01 100644 --- a/examples/resources/stackit_logme_instance/resource.tf +++ b/examples/resources/stackit_logme_instance/resource.tf @@ -7,3 +7,9 @@ resource "stackit_logme_instance" "example" { sgw_acl = "193.148.160.0/19,45.129.40.0/21,45.135.244.0/22" } } + +# Only use the import statement, if you want to import an existing logme instance +import { + to = stackit_logme_instance.import-example + id = "${var.project_id},${var.logme_instance_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_mariadb_credential/resource.tf b/examples/resources/stackit_mariadb_credential/resource.tf index 0b6d2c3f..335e8e6a 100644 --- a/examples/resources/stackit_mariadb_credential/resource.tf +++ b/examples/resources/stackit_mariadb_credential/resource.tf @@ -2,3 +2,9 @@ resource "stackit_mariadb_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing mariadb credential +import { + to = stackit_mariadb_credential.import-example + id = "${var.project_id},${var.mariadb_instance_id},${var.mariadb_credential_id}" +} diff --git a/examples/resources/stackit_mariadb_instance/resource.tf b/examples/resources/stackit_mariadb_instance/resource.tf index fe6bafd2..7abe23ff 100644 --- a/examples/resources/stackit_mariadb_instance/resource.tf +++ b/examples/resources/stackit_mariadb_instance/resource.tf @@ -7,3 +7,9 @@ resource "stackit_mariadb_instance" "example" { sgw_acl = "193.148.160.0/19,45.129.40.0/21,45.135.244.0/22" } } + +# Only use the import statement, if you want to import an existing mariadb instance +import { + to = stackit_mariadb_instance.import-example + id = "${var.project_id},${var.mariadb_instance_id}" +} diff --git a/examples/resources/stackit_mongodbflex_instance/resource.tf b/examples/resources/stackit_mongodbflex_instance/resource.tf index f65dcdef..6c62321f 100644 --- a/examples/resources/stackit_mongodbflex_instance/resource.tf +++ b/examples/resources/stackit_mongodbflex_instance/resource.tf @@ -19,3 +19,9 @@ resource "stackit_mongodbflex_instance" "example" { } backup_schedule = "0 0 * * *" } + +# Only use the import statement, if you want to import an existing mongodbflex instance +import { + to = stackit_mongodbflex_instance.import-example + id = "${var.project_id},${var.region},${var.instance_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_mongodbflex_user/resource.tf b/examples/resources/stackit_mongodbflex_user/resource.tf index 71b4b443..df1bfac6 100644 --- a/examples/resources/stackit_mongodbflex_user/resource.tf +++ b/examples/resources/stackit_mongodbflex_user/resource.tf @@ -5,3 +5,9 @@ resource "stackit_mongodbflex_user" "example" { roles = ["role"] database = "database" } + +# Only use the import statement, if you want to import an existing mongodbflex user +import { + to = stackit_mongodbflex_user.import-example + id = "${var.project_id},${var.region},${var.instance_id},${user_id}" +} diff --git a/examples/resources/stackit_network/resource.tf b/examples/resources/stackit_network/resource.tf index 6782b88a..dbf1876d 100644 --- a/examples/resources/stackit_network/resource.tf +++ b/examples/resources/stackit_network/resource.tf @@ -23,4 +23,12 @@ resource "stackit_network" "example_non_routed_network" { "key" = "value" } routed = false +} + +# Only use the import statement, if you want to import an existing network +# Note: There will be a conflict which needs to be resolved manually. +# These attributes cannot be configured together: [ipv4_prefix,ipv4_prefix_length,ipv4_gateway] +import { + to = stackit_network.import-example + id = "${var.project_id},${var.network_id}" } \ No newline at end of file diff --git a/examples/resources/stackit_network_area/resource.tf b/examples/resources/stackit_network_area/resource.tf index 90cf14c0..e1cfbe0c 100644 --- a/examples/resources/stackit_network_area/resource.tf +++ b/examples/resources/stackit_network_area/resource.tf @@ -11,3 +11,9 @@ resource "stackit_network_area" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing network area +import { + to = stackit_network_area.import-example + id = "${var.organization_id},${var.network_area_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_network_area_route/resource.tf b/examples/resources/stackit_network_area_route/resource.tf index b1caeba0..a18d26eb 100644 --- a/examples/resources/stackit_network_area_route/resource.tf +++ b/examples/resources/stackit_network_area_route/resource.tf @@ -7,3 +7,9 @@ resource "stackit_network_area_route" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing network area route +import { + to = stackit_network_area_route.import-example + id = "${var.organization_id},${var.network_area_id},${var.network_area_route_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_network_interface/resource.tf b/examples/resources/stackit_network_interface/resource.tf index 181e63ed..7f0ba90d 100644 --- a/examples/resources/stackit_network_interface/resource.tf +++ b/examples/resources/stackit_network_interface/resource.tf @@ -3,4 +3,10 @@ resource "stackit_network_interface" "example" { network_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" allowed_addresses = ["192.168.0.0/24"] security_group_ids = ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"] +} + +# Only use the import statement, if you want to import an existing network interface +import { + to = stackit_network_interface.import-example + id = "${var.project_id},${var.network_id},${var.network_interface_id}" } \ No newline at end of file diff --git a/examples/resources/stackit_objectstorage_bucket/resource.tf b/examples/resources/stackit_objectstorage_bucket/resource.tf index 0c47f138..e8c1922c 100644 --- a/examples/resources/stackit_objectstorage_bucket/resource.tf +++ b/examples/resources/stackit_objectstorage_bucket/resource.tf @@ -2,3 +2,9 @@ resource "stackit_objectstorage_bucket" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "example-bucket" } + +# Only use the import statement, if you want to import an existing objectstorage bucket +import { + to = stackit_objectstorage_bucket.import-example + id = "${var.project_id},${var.region},${var.bucket_name}" +} diff --git a/examples/resources/stackit_objectstorage_credential/resource.tf b/examples/resources/stackit_objectstorage_credential/resource.tf index 2a75f295..46e11717 100644 --- a/examples/resources/stackit_objectstorage_credential/resource.tf +++ b/examples/resources/stackit_objectstorage_credential/resource.tf @@ -3,3 +3,9 @@ resource "stackit_objectstorage_credential" "example" { credentials_group_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" expiration_timestamp = "2027-01-02T03:04:05Z" } + +# Only use the import statement, if you want to import an existing objectstorage credential +import { + to = stackit_objectstorage_credential.import-example + id = "${var.project_id},${var.region},${var.bucket_credentials_group_id},${var.bucket_credential_id}" +} diff --git a/examples/resources/stackit_objectstorage_credentials_group/resource.tf b/examples/resources/stackit_objectstorage_credentials_group/resource.tf index 33e3cee1..0d6b1e3e 100644 --- a/examples/resources/stackit_objectstorage_credentials_group/resource.tf +++ b/examples/resources/stackit_objectstorage_credentials_group/resource.tf @@ -2,3 +2,9 @@ resource "stackit_objectstorage_credentials_group" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "example-credentials-group" } + +# Only use the import statement, if you want to import an existing objectstorage credential group +import { + to = stackit_objectstorage_credentials_group.import-example + id = "${var.project_id},${var.region},${var.bucket_credentials_group_id}" +} diff --git a/examples/resources/stackit_observability_alertgroup/resource.tf b/examples/resources/stackit_observability_alertgroup/resource.tf index 8f9c6e78..b4ab9cf3 100644 --- a/examples/resources/stackit_observability_alertgroup/resource.tf +++ b/examples/resources/stackit_observability_alertgroup/resource.tf @@ -29,4 +29,10 @@ resource "stackit_observability_alertgroup" "example" { } }, ] -} \ No newline at end of file +} + +# Only use the import statement, if you want to import an existing observability alertgroup +import { + to = stackit_observability_alertgroup.import-example + id = "${var.project_id},${var.observability_instance_id},${var.observability_alertgroup_name}" +} diff --git a/examples/resources/stackit_observability_instance/resource.tf b/examples/resources/stackit_observability_instance/resource.tf index f639359e..21dd0b1b 100644 --- a/examples/resources/stackit_observability_instance/resource.tf +++ b/examples/resources/stackit_observability_instance/resource.tf @@ -7,3 +7,9 @@ resource "stackit_observability_instance" "example" { metrics_retention_days_5m_downsampling = 10 metrics_retention_days_1h_downsampling = 5 } + +# Only use the import statement, if you want to import an existing observability instance +import { + to = stackit_observability_instance.import-example + id = "${var.project_id},${var.observability_instance_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_observability_logalertgroup/resource.tf b/examples/resources/stackit_observability_logalertgroup/resource.tf index b19ab976..d2876a69 100644 --- a/examples/resources/stackit_observability_logalertgroup/resource.tf +++ b/examples/resources/stackit_observability_logalertgroup/resource.tf @@ -29,4 +29,10 @@ resource "stackit_observability_logalertgroup" "example" { } }, ] -} \ No newline at end of file +} + +# Only use the import statement, if you want to import an existing observability logalertgroup +import { + to = stackit_observability_logalertgroup.import-example + id = "${var.project_id},${var.observability_instance_id},${var.observability_logalertgroup_name}" +} diff --git a/examples/resources/stackit_observability_scrapeconfig/resource.tf b/examples/resources/stackit_observability_scrapeconfig/resource.tf index 71f20da1..f0866184 100644 --- a/examples/resources/stackit_observability_scrapeconfig/resource.tf +++ b/examples/resources/stackit_observability_scrapeconfig/resource.tf @@ -15,3 +15,9 @@ resource "stackit_observability_scrapeconfig" "example" { } ] } + +# Only use the import statement, if you want to import an existing observability scrapeconfig +import { + to = stackit_observability_scrapeconfig.import-example + id = "${var.project_id},${var.observability_instance_id},${var.observability_scrapeconfig_name}" +} diff --git a/examples/resources/stackit_opensearch_credential/resource.tf b/examples/resources/stackit_opensearch_credential/resource.tf index 24d75424..c9e6dcc5 100644 --- a/examples/resources/stackit_opensearch_credential/resource.tf +++ b/examples/resources/stackit_opensearch_credential/resource.tf @@ -2,3 +2,9 @@ resource "stackit_opensearch_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing opensearch credential +import { + to = stackit_opensearch_credential.import-example + id = "${var.project_id},${var.instance_id},${var.credential_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_opensearch_instance/resource.tf b/examples/resources/stackit_opensearch_instance/resource.tf index 85ab9273..043f7154 100644 --- a/examples/resources/stackit_opensearch_instance/resource.tf +++ b/examples/resources/stackit_opensearch_instance/resource.tf @@ -7,3 +7,9 @@ resource "stackit_opensearch_instance" "example" { sgw_acl = "193.148.160.0/19,45.129.40.0/21,45.135.244.0/22" } } + +# Only use the import statement, if you want to import an existing opensearch instance +import { + to = stackit_opensearch_instance.import-example + id = "${var.project_id},${var.instance_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_postgresflex_database/resource.tf b/examples/resources/stackit_postgresflex_database/resource.tf index ac4c1b20..5388e1a2 100644 --- a/examples/resources/stackit_postgresflex_database/resource.tf +++ b/examples/resources/stackit_postgresflex_database/resource.tf @@ -4,3 +4,9 @@ resource "stackit_postgresflex_database" "example" { name = "mydb" owner = "myusername" } + +# Only use the import statement, if you want to import an existing postgresflex database +import { + to = stackit_postgresflex_database.import-example + id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.postgres_database_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_postgresflex_instance/resource.tf b/examples/resources/stackit_postgresflex_instance/resource.tf index 61a1540d..46a8d051 100644 --- a/examples/resources/stackit_postgresflex_instance/resource.tf +++ b/examples/resources/stackit_postgresflex_instance/resource.tf @@ -14,3 +14,9 @@ resource "stackit_postgresflex_instance" "example" { } version = 14 } + +# Only use the import statement, if you want to import an existing postgresflex instance +import { + to = stackit_postgresflex_instance.import-example + id = "${var.project_id},${var.region},${var.postgres_instance_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_postgresflex_user/resource.tf b/examples/resources/stackit_postgresflex_user/resource.tf index 3fe0dbe7..1521fa45 100644 --- a/examples/resources/stackit_postgresflex_user/resource.tf +++ b/examples/resources/stackit_postgresflex_user/resource.tf @@ -4,3 +4,9 @@ resource "stackit_postgresflex_user" "example" { username = "username" roles = ["role"] } + +# Only use the import statement, if you want to import an existing postgresflex user +import { + to = stackit_postgresflex_user.import-example + id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.user_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_public_ip/resource.tf b/examples/resources/stackit_public_ip/resource.tf index b7f3f5de..ec63a744 100644 --- a/examples/resources/stackit_public_ip/resource.tf +++ b/examples/resources/stackit_public_ip/resource.tf @@ -5,3 +5,9 @@ resource "stackit_public_ip" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing public ip +import { + to = stackit_public_ip.import-example + id = "${var.project_id},${var.public_ip_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_public_ip_associate/resource.tf b/examples/resources/stackit_public_ip_associate/resource.tf index 280f60fe..08f7c219 100644 --- a/examples/resources/stackit_public_ip_associate/resource.tf +++ b/examples/resources/stackit_public_ip_associate/resource.tf @@ -3,3 +3,9 @@ resource "stackit_public_ip_associate" "example" { public_ip_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" network_interface_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing public ip associate +import { + to = stackit_public_ip_associate.import-example + id = "${var.project_id},${var.public_ip_id},${var.network_interface_id}" +} diff --git a/examples/resources/stackit_rabbitmq_credential/resource.tf b/examples/resources/stackit_rabbitmq_credential/resource.tf index 7c860c8e..cef13a72 100644 --- a/examples/resources/stackit_rabbitmq_credential/resource.tf +++ b/examples/resources/stackit_rabbitmq_credential/resource.tf @@ -2,3 +2,9 @@ resource "stackit_rabbitmq_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing rabbitmq credential +import { + to = stackit_rabbitmq_credential.import-example + id = "${var.project_id},${var.rabbitmq_instance_id},${var.rabbitmq_credential_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_rabbitmq_instance/resource.tf b/examples/resources/stackit_rabbitmq_instance/resource.tf index 7894f80a..c559de44 100644 --- a/examples/resources/stackit_rabbitmq_instance/resource.tf +++ b/examples/resources/stackit_rabbitmq_instance/resource.tf @@ -10,3 +10,9 @@ resource "stackit_rabbitmq_instance" "example" { plugins = ["rabbitmq_consistent_hash_exchange", "rabbitmq_federation", "rabbitmq_tracing"] } } + +# Only use the import statement, if you want to import an existing rabbitmq instance +import { + to = stackit_rabbitmq_instance.import-example + id = "${var.project_id},${var.rabbitmq_instance_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_redis_credential/resource.tf b/examples/resources/stackit_redis_credential/resource.tf index c39d45e9..8c535cc8 100644 --- a/examples/resources/stackit_redis_credential/resource.tf +++ b/examples/resources/stackit_redis_credential/resource.tf @@ -2,3 +2,9 @@ resource "stackit_redis_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing redis credential +import { + to = stackit_redis_credential.import-example + id = "${var.project_id},${var.redis_instance_id},${var.redis_credential_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_redis_instance/resource.tf b/examples/resources/stackit_redis_instance/resource.tf index 6fbc60b1..6ccb7728 100644 --- a/examples/resources/stackit_redis_instance/resource.tf +++ b/examples/resources/stackit_redis_instance/resource.tf @@ -10,3 +10,9 @@ resource "stackit_redis_instance" "example" { syslog = ["logs4.your-syslog-endpoint.com:54321"] } } + +# Only use the import statement, if you want to import an existing redis instance +import { + to = stackit_redis_instance.import-example + id = "${var.project_id},${var.redis_instance_id}" +} diff --git a/examples/resources/stackit_resourcemanager_project/resource.tf b/examples/resources/stackit_resourcemanager_project/resource.tf index ae2a0d58..37bcc4c0 100644 --- a/examples/resources/stackit_resourcemanager_project/resource.tf +++ b/examples/resources/stackit_resourcemanager_project/resource.tf @@ -7,3 +7,11 @@ resource "stackit_resourcemanager_project" "example" { } owner_email = "john.doe@stackit.cloud" } + +# Only use the import statement, if you want to import an existing resourcemanager project +# Note: There will be a conflict which needs to be resolved manually. +# Must set a configuration value for the owner_email attribute as the provider has marked it as required. +import { + to = stackit_resourcemanager_project.import-example + id = var.container_id +} diff --git a/examples/resources/stackit_routing_table/resource.tf b/examples/resources/stackit_routing_table/resource.tf index 8841401f..18059992 100644 --- a/examples/resources/stackit_routing_table/resource.tf +++ b/examples/resources/stackit_routing_table/resource.tf @@ -6,3 +6,9 @@ resource "stackit_routing_table" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing routing table +import { + to = stackit_routing_table.import-example + id = "${var.organization_id},${var.region},${var.network_area_id},${var.routing_table_id}" +} diff --git a/examples/resources/stackit_routing_table_route/resource.tf b/examples/resources/stackit_routing_table_route/resource.tf index 820da292..78ff9832 100644 --- a/examples/resources/stackit_routing_table_route/resource.tf +++ b/examples/resources/stackit_routing_table_route/resource.tf @@ -13,4 +13,10 @@ resource "stackit_routing_table_route" "example" { labels = { "key" = "value" } +} + +# Only use the import statement, if you want to import an existing routing table route +import { + to = stackit_routing_table_route.import-example + id = "${var.organization_id},${var.region},${var.network_area_id},${var.routing_table_id},${var.routing_table_route_id}" } \ No newline at end of file diff --git a/examples/resources/stackit_secretsmanager_instance/resource.tf b/examples/resources/stackit_secretsmanager_instance/resource.tf index 0dc2f578..1ece81cc 100644 --- a/examples/resources/stackit_secretsmanager_instance/resource.tf +++ b/examples/resources/stackit_secretsmanager_instance/resource.tf @@ -3,3 +3,9 @@ resource "stackit_secretsmanager_instance" "example" { name = "example-instance" acls = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] } + +# Only use the import statement, if you want to import an existing secretsmanager instance +import { + to = stackit_secretsmanager_instance.import-example + id = "${var.project_id},${var.secret_instance_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_secretsmanager_user/resource.tf b/examples/resources/stackit_secretsmanager_user/resource.tf index e15ee8ac..ec6b642b 100644 --- a/examples/resources/stackit_secretsmanager_user/resource.tf +++ b/examples/resources/stackit_secretsmanager_user/resource.tf @@ -4,3 +4,9 @@ resource "stackit_secretsmanager_user" "example" { description = "Example user" write_enabled = false } + +# Only use the import statement, if you want to import an existing secretsmanager user +import { + to = stackit_secretsmanager_user.import-example + id = "${var.project_id},${var.secret_instance_id},${var.secret_user_id}" +} diff --git a/examples/resources/stackit_security_group/resource.tf b/examples/resources/stackit_security_group/resource.tf index a67ea42d..131cf639 100644 --- a/examples/resources/stackit_security_group/resource.tf +++ b/examples/resources/stackit_security_group/resource.tf @@ -5,3 +5,9 @@ resource "stackit_security_group" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing security group +import { + to = stackit_security_group.import-example + id = "${var.project_id},${var.security_group_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_security_group_rule/resource.tf b/examples/resources/stackit_security_group_rule/resource.tf index 0e308bd3..6844d1ea 100644 --- a/examples/resources/stackit_security_group_rule/resource.tf +++ b/examples/resources/stackit_security_group_rule/resource.tf @@ -10,3 +10,11 @@ resource "stackit_security_group_rule" "example" { name = "icmp" } } + +# Only use the import statement, if you want to import an existing security group rule +# Note: There will be a conflict which needs to be resolved manually. +# Attribute "protocol.number" cannot be specified when "protocol.name" is specified. +import { + to = stackit_security_group_rule.import-example + id = "${var.project_id},${var.security_group_id},${var.security_group_rule_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_server/resource.tf b/examples/resources/stackit_server/resource.tf new file mode 100644 index 00000000..2f2d172e --- /dev/null +++ b/examples/resources/stackit_server/resource.tf @@ -0,0 +1,27 @@ +resource "stackit_server" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + name = "example-server" + boot_volume = { + size = 64 + source_type = "image" + source_id = "59838a89-51b1-4892-b57f-b3caf598ee2f" // Ubuntu 24.04 + } + availability_zone = "xxxx-x" + machine_type = "g1.1" + network_interfaces = [ + stackit_network_interface.example.network_interface_id + ] +} + +# Only use the import statement, if you want to import an existing server +# Note: There will be a conflict which needs to be resolved manually. +# Must set a configuration value for the boot_volume.source_type and boot_volume.source_id attribute as the provider has marked it as required. +# Since those attributes are not fetched in general from the API call, after adding them this would replace your server resource after an terraform apply. +# In order to prevent this you need to add: +# lifecycle { +# ignore_changes = [ boot_volume ] +# } +import { + to = stackit_server.import-example + id = "${var.project_id},${var.server_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_server_backup_schedule/resource.tf b/examples/resources/stackit_server_backup_schedule/resource.tf index 7406a9a0..5e2ec0c6 100644 --- a/examples/resources/stackit_server_backup_schedule/resource.tf +++ b/examples/resources/stackit_server_backup_schedule/resource.tf @@ -10,3 +10,9 @@ resource "stackit_server_backup_schedule" "example" { volume_ids = null } } + +# Only use the import statement, if you want to import an existing server backup schedule +import { + to = stackit_server_backup_schedule.import-example + id = "${var.project_id},${var.region},${var.server_id},${var.server_backup_schedule_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_server_network_interface_attach/resource.tf b/examples/resources/stackit_server_network_interface_attach/resource.tf index aaf85d18..30b13c2b 100644 --- a/examples/resources/stackit_server_network_interface_attach/resource.tf +++ b/examples/resources/stackit_server_network_interface_attach/resource.tf @@ -3,3 +3,9 @@ resource "stackit_server_network_interface_attach" "attached_network_interface" server_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" network_interface_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing server network interface attachment +import { + to = stackit_server_network_interface_attach.import-example + id = "${var.project_id},${var.server_id},${var.network_interface_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_server_service_account_attach/resource.tf b/examples/resources/stackit_server_service_account_attach/resource.tf index dbe7fa0b..1860dc4b 100644 --- a/examples/resources/stackit_server_service_account_attach/resource.tf +++ b/examples/resources/stackit_server_service_account_attach/resource.tf @@ -3,3 +3,9 @@ resource "stackit_server_service_account_attach" "attached_service_account" { server_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" service_account_email = "service-account@stackit.cloud" } + +# Only use the import statement, if you want to import an existing server service account attachment +import { + to = stackit_server_service_account_attach.import-example + id = "${var.project_id},${var.server_id},${var.service_account_email}" +} \ No newline at end of file diff --git a/examples/resources/stackit_server_update_schedule/resource.tf b/examples/resources/stackit_server_update_schedule/resource.tf index 05731ecf..bfc86d7b 100644 --- a/examples/resources/stackit_server_update_schedule/resource.tf +++ b/examples/resources/stackit_server_update_schedule/resource.tf @@ -6,3 +6,9 @@ resource "stackit_server_update_schedule" "example" { enabled = true maintenance_window = 1 } + +# Only use the import statement, if you want to import an existing server update schedule +import { + to = stackit_server_update_schedule.import-example + id = "${var.project_id},${var.region},${var.server_id},${var.server_update_schedule_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_server_volume_attach/resource.tf b/examples/resources/stackit_server_volume_attach/resource.tf index dadb093d..0fae0fbe 100644 --- a/examples/resources/stackit_server_volume_attach/resource.tf +++ b/examples/resources/stackit_server_volume_attach/resource.tf @@ -3,3 +3,9 @@ resource "stackit_server_volume_attach" "attached_volume" { server_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" volume_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } + +# Only use the import statement, if you want to import an existing server volume attachment +import { + to = stackit_server_volume_attach.import-example + id = "${var.project_id},${var.server_id},${var.volume_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_service_account/resource.tf b/examples/resources/stackit_service_account/resource.tf index 633e4de1..988cf345 100644 --- a/examples/resources/stackit_service_account/resource.tf +++ b/examples/resources/stackit_service_account/resource.tf @@ -2,3 +2,9 @@ resource "stackit_service_account" "sa" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "sa01" } + +# Only use the import statement, if you want to import an existing service account +import { + to = stackit_service_account.import-example + id = "${var.project_id},${var.service_account_email}" +} \ No newline at end of file diff --git a/examples/resources/stackit_ske_cluster/resource.tf b/examples/resources/stackit_ske_cluster/resource.tf index 0ffbee5b..cabf801a 100644 --- a/examples/resources/stackit_ske_cluster/resource.tf +++ b/examples/resources/stackit_ske_cluster/resource.tf @@ -19,3 +19,9 @@ resource "stackit_ske_cluster" "example" { end = "02:00:00Z" } } + +# Only use the import statement, if you want to import an existing ske cluster +import { + to = stackit_ske_cluster.import-example + id = "${var.project_id},${var.region},${var.ske_name}" +} \ No newline at end of file diff --git a/examples/resources/stackit_sqlserverflex_instance/resource.tf b/examples/resources/stackit_sqlserverflex_instance/resource.tf index 3ba3f01a..f18f9b12 100644 --- a/examples/resources/stackit_sqlserverflex_instance/resource.tf +++ b/examples/resources/stackit_sqlserverflex_instance/resource.tf @@ -13,3 +13,9 @@ resource "stackit_sqlserverflex_instance" "example" { } version = 2022 } + +# Only use the import statement, if you want to import an existing sqlserverflex instance +import { + to = stackit_sqlserverflex_instance.import-example + id = "${var.project_id},${var.region},${var.sql_instance_id}" +} diff --git a/examples/resources/stackit_sqlserverflex_user/resource.tf b/examples/resources/stackit_sqlserverflex_user/resource.tf index 4a9ec538..98ebcfab 100644 --- a/examples/resources/stackit_sqlserverflex_user/resource.tf +++ b/examples/resources/stackit_sqlserverflex_user/resource.tf @@ -4,3 +4,9 @@ resource "stackit_sqlserverflex_user" "example" { username = "username" roles = ["role"] } + +# Only use the import statement, if you want to import an existing sqlserverflex user +import { + to = stackit_sqlserverflex_user.import-example + id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}" +} \ No newline at end of file diff --git a/examples/resources/stackit_volume/resource.tf b/examples/resources/stackit_volume/resource.tf index ef88623b..6bfd61f9 100644 --- a/examples/resources/stackit_volume/resource.tf +++ b/examples/resources/stackit_volume/resource.tf @@ -7,3 +7,9 @@ resource "stackit_volume" "example" { "key" = "value" } } + +# Only use the import statement, if you want to import an existing volume +import { + to = stackit_volume.import-example + id = "${var.project_id},${var.volume_id}" +} \ No newline at end of file diff --git a/templates/guides/import_resources.md b/templates/guides/import_resources.md new file mode 100644 index 00000000..6801624b --- /dev/null +++ b/templates/guides/import_resources.md @@ -0,0 +1,27 @@ +--- +page_title: "How to import an existing resources" +--- +# How to import an existing resources? + +## 1. **Create a terraform config file and add an import block for your resource** + +In order to import an existing resources in terraform you need to add an import block for the corresponding resource in a terraform config file. +There is an example for every resource under the [examples](../../examples/) folder. + +E.g. the import statement for a `stackit_volume` looks like the following: + +```terraform +import { + to = stackit_volume.import-example + id = "${var.project_id},${var.volume_id}" +} +``` + +## 2. **Generate the destination resource automatically** + +Run `terraform plan -generate-config-out=generated.tf` to let terraform generate the configuration for you. +In this step the `stackit_volume.import-example` resource is generated and filled with informations of your existing resource. + +## 3. **Finish the import** + +Run `terraform apply` to add your resource to the terraform state. \ No newline at end of file