Merge branch 'main' into alpha

# Conflicts:
#	docs/data-sources/sqlserverflexalpha_user.md
#	docs/index.md
#	docs/resources/postgresflexalpha_instance.md
#	docs/resources/sqlserverflexalpha_user.md
#	examples/data-sources/stackitprivatepreview_postgresflexalpha_database/data-source.tf
#	examples/data-sources/stackitprivatepreview_postgresflexalpha_instance/data-source.tf
#	examples/data-sources/stackitprivatepreview_postgresflexalpha_user/data-source.tf
#	examples/data-sources/stackitprivatepreview_sqlserverflexalpha_instance/data-source.tf
#	examples/data-sources/stackitprivatepreview_sqlserverflexalpha_user/data-source.tf
#	examples/provider/provider.tf
#	examples/resources/stackitprivatepreview_postgresflexalpha_database/resource.tf
#	examples/resources/stackitprivatepreview_postgresflexalpha_instance/resource.tf
#	examples/resources/stackitprivatepreview_postgresflexalpha_user/resource.tf
#	examples/resources/stackitprivatepreview_sqlserverflexalpha_instance/resource.tf
#	examples/resources/stackitprivatepreview_sqlserverflexalpha_user/resource.tf
#	go.mod
#	go.sum
#	golang-ci.yaml
#	main.go
#	scripts/check-docs.sh
#	scripts/lint-golangci-lint.sh
#	scripts/project.sh
#	scripts/replace.sh
#	scripts/tfplugindocs.sh
#	stackit/internal/conversion/conversion.go
#	stackit/internal/conversion/conversion_test.go
#	stackit/internal/core/core.go
#	stackit/internal/core/core_test.go
#	stackit/internal/features/beta.go
#	stackit/internal/features/beta_test.go
#	stackit/internal/features/experiments.go
#	stackit/internal/features/experiments_test.go
#	stackit/internal/services/postgresflexalpha/database/datasource.go.bak
#	stackit/internal/services/postgresflexalpha/database/resource.go.bak
#	stackit/internal/services/postgresflexalpha/database/resource_test.go.bak
#	stackit/internal/services/postgresflexalpha/instance/datasource.go.bak
#	stackit/internal/services/postgresflexalpha/instance/resource.go
#	stackit/internal/services/postgresflexalpha/instance/use_state_for_unknown_if_flavor_unchanged_modifier.go
#	stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go
#	stackit/internal/services/postgresflexalpha/user/datasource.go
#	stackit/internal/services/postgresflexalpha/user/datasource_test.go
#	stackit/internal/services/postgresflexalpha/user/resource.go
#	stackit/internal/services/postgresflexalpha/user/resource_test.go
#	stackit/internal/services/postgresflexalpha/utils/util.go
#	stackit/internal/services/postgresflexalpha/utils/util_test.go
#	stackit/internal/services/sqlserverflexalpha/instance/datasource.go
#	stackit/internal/services/sqlserverflexalpha/instance/resource.go
#	stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go
#	stackit/internal/services/sqlserverflexalpha/testdata/resource-max.tf
#	stackit/internal/services/sqlserverflexalpha/testdata/resource-min.tf
#	stackit/internal/services/sqlserverflexalpha/user/datasource.go
#	stackit/internal/services/sqlserverflexalpha/user/resource.go
#	stackit/internal/services/sqlserverflexalpha/utils/util.go
#	stackit/internal/services/sqlserverflexalpha/utils/util_test.go
#	stackit/internal/testutil/testutil.go
#	stackit/internal/testutil/testutil_test.go
#	stackit/internal/utils/attributes.go
#	stackit/internal/utils/attributes_test.go
#	stackit/internal/utils/headers.go
#	stackit/internal/utils/headers_test.go
#	stackit/internal/utils/regions.go
#	stackit/internal/utils/regions_test.go
#	stackit/internal/utils/use_state_for_unknown_if.go
#	stackit/internal/utils/use_state_for_unknown_if_test.go
#	stackit/internal/utils/utils.go
#	stackit/internal/utils/utils_test.go
#	stackit/internal/validate/validate.go
#	stackit/internal/validate/validate_test.go
#	stackit/provider.go
#	stackit/provider_acc_test.go
#	stackit/testdata/provider-all-attributes.tf
#	stackit/testdata/provider-credentials.tf
#	stackit/testdata/provider-invalid-attribute.tf
This commit is contained in:
Marcel_Henselin 2025-12-19 11:33:29 +01:00
commit 7de63b5b8e
9 changed files with 4 additions and 194 deletions

View file

@ -213,7 +213,7 @@ func (r *barResource) Create(ctx context.Context, req resource.CreateRequest, re
// only in case the create bar API call is asynchronous (Make sure to include *ALL* fields which are part of the
// internal terraform resource id! And please include the comment below in your code):
// Write id attributes to state before polling via the wait handler - just in case anything goes wrong during the wait handler
utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{
ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{
"project_id": projectId,
"region": region,
"bar_id": resp.BarId,
@ -337,7 +337,7 @@ func (r *barResource) ImportState(ctx context.Context, req resource.ImportStateR
return
}
utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{
ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{
"project_id": idParts[0],
"region": idParts[1],
"bar_id": idParts[2],

View file

@ -11,6 +11,7 @@ on:
env:
DAYS_BEFORE_PR_STALE: 7
DAYS_BEFORE_PR_CLOSE: 7
EXEMPT_PR_LABELS: "ignore-stale"
permissions:
issues: write
@ -30,6 +31,7 @@ jobs:
close-pr-message: "This PR was closed automatically because it has been stalled for ${{ env.DAYS_BEFORE_PR_CLOSE }} days with no activity. Feel free to re-open it at any time."
days-before-pr-stale: ${{ env.DAYS_BEFORE_PR_STALE }}
days-before-pr-close: ${{ env.DAYS_BEFORE_PR_CLOSE }}
exempt-pr-labels: ${{ env.EXEMPT_PR_LABELS }}
# never mark issues as stale or close them
days-before-issue-stale: -1
days-before-issue-close: -1

View file

@ -1,27 +0,0 @@
---
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.

View file

@ -1 +0,0 @@
"not json"

View file

@ -1,3 +0,0 @@
{
"STACKIT_SERVICE_ACCOUNT_TOKEN": "foo_token"
}

View file

@ -1 +0,0 @@
I am a test file

View file

@ -1,27 +0,0 @@
---
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.

View file

@ -1,125 +0,0 @@
# {{ .ProviderShortName | upper }} Terraform Provider
The STACKIT Terraform provider is the official Terraform provider to integrate all the resources developed by [STACKIT](https://www.stackit.de/en/).
## Example Usage
{{ tffile "examples/provider/provider.tf" }}
## Authentication
To authenticate, you will need a [service account](https://docs.stackit.cloud/platform/access-and-identity/service-accounts/). Create it in the [STACKIT Portal](https://portal.stackit.cloud/) and assign the necessary permissions to it, e.g. `project.owner`. There are multiple ways to authenticate:
- Key flow (recommended)
- Token flow (is scheduled for deprecation and will be removed on December 17, 2025)
When setting up authentication, the provider will always try to use the key flow first and search for credentials in several locations, following a specific order:
1. Explicit configuration, e.g. by setting the field `service_account_key_path` in the provider block (see example below)
2. Environment variable, e.g. by setting `STACKIT_SERVICE_ACCOUNT_KEY_PATH`
3. Credentials file
The provider will check the credentials file located in the path defined by the `STACKIT_CREDENTIALS_PATH` env var, if specified,
or in `$HOME/.stackit/credentials.json` as a fallback.
The credentials should be set using the same name as the environment variables. Example:
```json
{
"STACKIT_SERVICE_ACCOUNT_TOKEN": "foo_token",
"STACKIT_SERVICE_ACCOUNT_KEY_PATH": "path/to/sa_key.json",
"STACKIT_PRIVATE_KEY_PATH": "path/to/private_key.pem"
}
```
### Key flow
The following instructions assume that you have created a service account and assigned the necessary permissions to it, e.g. `project.owner`.
To use the key flow, you need to have a service account key, which must have an RSA key-pair attached to it.
When creating the service account key, a new pair can be created automatically, which will be included in the service account key. This will make it much easier to configure the key flow authentication in the [STACKIT Terraform Provider](https://github.com/stackitcloud/terraform-provider-stackit), by just providing the service account key.
**Optionally**, you can provide your own private key when creating the service account key, which will then require you to also provide it explicitly to the [STACKIT Terraform Provider](https://github.com/stackitcloud/terraform-provider-stackit), additionally to the service account key. Check the STACKIT Docs for an [example of how to create your own key-pair](https://docs.stackit.cloud/platform/access-and-identity/service-accounts/how-tos/manage-service-account-keys/).
To configure the key flow, follow this steps:
1. Create a service account key:
- Use the [STACKIT Portal](https://portal.stackit.cloud/): go to the `Service Accounts` tab, choose a `Service Account` and go to `Service Account Keys` to create a key. For more details, see [Create a service account key](https://docs.stackit.cloud/platform/access-and-identity/service-accounts/how-tos/manage-service-account-keys/)
2. Save the content of the service account key by copying it and saving it in a JSON file.
The expected format of the service account key is a **JSON** with the following structure:
```json
{
"id": "uuid",
"publicKey": "public key",
"createdAt": "2023-08-24T14:15:22Z",
"validUntil": "2023-08-24T14:15:22Z",
"keyType": "USER_MANAGED",
"keyOrigin": "USER_PROVIDED",
"keyAlgorithm": "RSA_2048",
"active": true,
"credentials": {
"kid": "string",
"iss": "my-sa@sa.stackit.cloud",
"sub": "uuid",
"aud": "string",
(optional) "privateKey": "private key when generated by the SA service"
}
}
```
3. Configure the service account key for authentication in the provider by following one of the alternatives below:
- setting the fields in the provider block: `service_account_key` or `service_account_key_path`
- setting the environment variable: `STACKIT_SERVICE_ACCOUNT_KEY_PATH`
- setting `STACKIT_SERVICE_ACCOUNT_KEY_PATH` in the credentials file (see above)
> **Optionally, only if you have provided your own RSA key-pair when creating the service account key**, you also need to configure your private key (takes precedence over the one included in the service account key, if present). **The private key must be PEM encoded** and can be provided using one of the options below:
>
> - setting the field in the provider block: `private_key` or `private_key_path`
> - setting the environment variable: `STACKIT_PRIVATE_KEY_PATH`
> - setting `STACKIT_PRIVATE_KEY_PATH` in the credentials file (see above)
### Token flow
> Is scheduled for deprecation and will be removed on December 17, 2025.
Using this flow is less secure since the token is long-lived. You can provide the token in several ways:
1. Setting the field `service_account_token` in the provider
2. Setting the environment variable `STACKIT_SERVICE_ACCOUNT_TOKEN`
3. Setting it in the credentials file (see above)
# Backend configuration
To keep track of your terraform state, you can configure an [S3 backend](https://developer.hashicorp.com/terraform/language/settings/backends/s3) using [STACKIT Object Storage](https://docs.stackit.cloud/products/storage/object-storage).
To do so, you need an Object Storage [S3 bucket](https://docs.stackit.cloud/products/storage/object-storage/basics/concepts/#buckets) and [credentials](https://docs.stackit.cloud/products/storage/object-storage/basics/concepts/#credentials) to access it. If you need to create them, check [Create and delete Object Storage buckets](https://docs.stackit.cloud/products/storage/object-storage/how-tos/create-and-manage-object-storage-buckets/) and [Create and delete Object Storage credentials](https://docs.stackit.cloud/products/storage/object-storage/how-tos/create-and-delete-object-storage-credentials/).
Once you have everything setup, you can configure the backend by adding the following block to your terraform configuration:
```
terraform {
backend "s3" {
bucket = "BUCKET_NAME"
key = "path/to/key"
endpoints = {
s3 = "https://object.storage.eu01.onstackit.cloud"
}
region = "eu01"
skip_credentials_validation = true
skip_region_validation = true
skip_s3_checksum = true
skip_requesting_account_id = true
secret_key = "SECRET_KEY"
access_key = "ACCESS_KEY"
}
}
```
Note: AWS specific checks must be skipped as they do not work on STACKIT. For details on what those validations do, see [here](https://developer.hashicorp.com/terraform/language/settings/backends/s3#configuration).
{{ .SchemaMarkdown | trimspace }}

View file

@ -1,8 +0,0 @@
{
"version": 1,
"metadata": {
"protocol_versions": [
"6.0"
]
}
}