Rename DSA credentials to credential (#76)
* Rename in LogMe * Rename in other DSA * Rename examples * Rename folder names * Rename in error messages
This commit is contained in:
parent
bd286d3c2d
commit
fee47a6400
59 changed files with 561 additions and 544 deletions
|
|
@ -98,7 +98,7 @@ import {
|
|||
|
||||
import {
|
||||
id = "project_id,instance_id,credentials_id"
|
||||
to = stackit_logme_credentials.example-credentials
|
||||
to = stackit_logme_credential.example-credential
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ resource "stackit_logme_instance" "example-instance" {
|
|||
}
|
||||
|
||||
# __generated__ by Terraform from "project_id,instance_id,credentials_id"
|
||||
resource "stackit_logme_credentials" "example-credentials" {
|
||||
resource "stackit_logme_credential" "example-credential" {
|
||||
instance_id = "instance_id"
|
||||
project_id = "project_id"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_logme_credentials Data Source - stackit"
|
||||
page_title: "stackit_logme_credential Data Source - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
LogMe credentials data source schema.
|
||||
LogMe credential data source schema.
|
||||
---
|
||||
|
||||
# stackit_logme_credentials (Data Source)
|
||||
# stackit_logme_credential (Data Source)
|
||||
|
||||
LogMe credentials data source schema.
|
||||
LogMe credential data source schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
data "stackit_logme_credentials" "example" {
|
||||
data "stackit_logme_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_mariadb_credentials Data Source - stackit"
|
||||
page_title: "stackit_mariadb_credential Data Source - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
MariaDB credentials data source schema.
|
||||
MariaDB credential data source schema.
|
||||
---
|
||||
|
||||
# stackit_mariadb_credentials (Data Source)
|
||||
# stackit_mariadb_credential (Data Source)
|
||||
|
||||
MariaDB credentials data source schema.
|
||||
MariaDB credential data source schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
data "stackit_mariadb_credentials" "example" {
|
||||
data "stackit_mariadb_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
|
@ -3,12 +3,12 @@
|
|||
page_title: "stackit_objectstorage_bucket Data Source - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
ObjectStorage credentials data source schema.
|
||||
ObjectStorage credential data source schema.
|
||||
---
|
||||
|
||||
# stackit_objectstorage_bucket (Data Source)
|
||||
|
||||
ObjectStorage credentials data source schema.
|
||||
ObjectStorage credential data source schema.
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_opensearch_credentials Data Source - stackit"
|
||||
page_title: "stackit_opensearch_credential Data Source - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
OpenSearch credentials data source schema.
|
||||
OpenSearch credential data source schema.
|
||||
---
|
||||
|
||||
# stackit_opensearch_credentials (Data Source)
|
||||
# stackit_opensearch_credential (Data Source)
|
||||
|
||||
OpenSearch credentials data source schema.
|
||||
OpenSearch credential data source schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
data "stackit_opensearch_credentials" "example" {
|
||||
data "stackit_opensearch_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_postgresql_credentials Data Source - stackit"
|
||||
page_title: "stackit_postgresql_credential Data Source - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
PostgreSQL credentials data source schema.
|
||||
PostgreSQL credential data source schema.
|
||||
---
|
||||
|
||||
# stackit_postgresql_credentials (Data Source)
|
||||
# stackit_postgresql_credential (Data Source)
|
||||
|
||||
PostgreSQL credentials data source schema.
|
||||
PostgreSQL credential data source schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
data "stackit_postgresql_credentials" "example" {
|
||||
data "stackit_postgresql_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_rabbitmq_credentials Data Source - stackit"
|
||||
page_title: "stackit_rabbitmq_credential Data Source - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
RabbitMQ credentials data source schema.
|
||||
RabbitMQ credential data source schema.
|
||||
---
|
||||
|
||||
# stackit_rabbitmq_credentials (Data Source)
|
||||
# stackit_rabbitmq_credential (Data Source)
|
||||
|
||||
RabbitMQ credentials data source schema.
|
||||
RabbitMQ credential data source schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
data "stackit_rabbitmq_credentials" "example" {
|
||||
data "stackit_rabbitmq_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_redis_credentials Data Source - stackit"
|
||||
page_title: "stackit_redis_credential Data Source - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
Redis credentials data source schema.
|
||||
Redis credential data source schema.
|
||||
---
|
||||
|
||||
# stackit_redis_credentials (Data Source)
|
||||
# stackit_redis_credential (Data Source)
|
||||
|
||||
Redis credentials data source schema.
|
||||
Redis credential data source schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
data "stackit_redis_credentials" "example" {
|
||||
data "stackit_redis_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
|
@ -41,13 +41,13 @@ To authenticate, you will need a [service account](https://docs.stackit.cloud/st
|
|||
|
||||
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 seting the fiel `stackit_service_account_key_path` in the provider block (see example below)
|
||||
1. Explicit configuration, e.g. by seting the field `stackit_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 SDK 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 environmnet variables. Example:
|
||||
The credentials should be set using the same name as the environment variables. Example:
|
||||
|
||||
```json
|
||||
{
|
||||
|
|
@ -64,32 +64,42 @@ To configure it, follow this steps:
|
|||
|
||||
The following instructions assume that you have created a service account and assigned it the necessary permissions, e.g. project.owner.
|
||||
|
||||
1. In the Portal, go to `Service Account -> Service Account Keys` and create a key.
|
||||
- You can create your own RSA key-pair or have the Portal generate one for you.
|
||||
2. Save the content of the service account key and the corresponding private key by copying them or saving them in a file. The expected format of the service account key is the following:
|
||||
```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"
|
||||
}
|
||||
}
|
||||
```
|
||||
1. In the Portal, go to the `Service Accounts` tab, choose a `Service Account` and go to `Service Account Keys` to create a key.
|
||||
|
||||
- You can create your own RSA key-pair or have the Portal generate one for you.
|
||||
|
||||
**Disclaimer:** as of now, creation of a service account key in the Portal is only available in DEV and QA environments. You can use this flow in these environments by setting the fields `token_custom_endpoint` and `jwks_custom_endpoint` to the corresponding endpoints in the provider block.
|
||||
|
||||
2. Save the content of the service account key and the corresponding private key by copying them or saving them in a file.
|
||||
|
||||
**Hint:** If you have generated the RSA key-pair using the Portal, you can save the private key in a PEM encoded file by downloading the service account key as a PEM file and using `openssl storeutl -keys <path/to/sa_key_pem_file> > private.key` to extract the private key from the service account key.
|
||||
|
||||
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 and private key for authentication in the SDK:
|
||||
- setting the fiels in the provider block: `service_account_key` or `service_account_key_path`, `private_key` or `private_key_path`
|
||||
- setting environment variables: `STACKIT_SERVICE_ACCOUNT_KEY_PATH` and `STACKIT_PRIVATE_KEY_PATH`
|
||||
- setting them in the credentials file (see above)
|
||||
- setting `STACKIT_SERVICE_ACCOUNT_KEY_PATH` and `STACKIT_PRIVATE_KEY_PATH` in the credentials file (see above)
|
||||
|
||||
### Token flow
|
||||
|
||||
|
|
|
|||
41
docs/resources/logme_credential.md
Normal file
41
docs/resources/logme_credential.md
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_logme_credential Resource - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
LogMe credential resource schema.
|
||||
---
|
||||
|
||||
# stackit_logme_credential (Resource)
|
||||
|
||||
LogMe credential resource schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
resource "stackit_logme_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
```
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `instance_id` (String) ID of the LogMe instance.
|
||||
- `project_id` (String) STACKIT Project ID to which the instance is associated.
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `credentials_id` (String) The credentials ID.
|
||||
- `host` (String)
|
||||
- `hosts` (List of String)
|
||||
- `http_api_uri` (String)
|
||||
- `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`instance_id`,`credentials_id`".
|
||||
- `name` (String)
|
||||
- `password` (String, Sensitive)
|
||||
- `port` (Number)
|
||||
- `uri` (String)
|
||||
- `username` (String)
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_logme_credentials Resource - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
LogMe credentials resource schema.
|
||||
---
|
||||
|
||||
# stackit_logme_credentials (Resource)
|
||||
|
||||
LogMe credentials resource schema.
|
||||
|
||||
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `instance_id` (String) ID of the LogMe instance.
|
||||
- `project_id` (String) STACKIT Project ID to which the instance is associated.
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `credentials_id` (String) The credentials ID.
|
||||
- `host` (String)
|
||||
- `hosts` (List of String)
|
||||
- `http_api_uri` (String)
|
||||
- `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`instance_id`,`credentials_id`".
|
||||
- `name` (String)
|
||||
- `password` (String, Sensitive)
|
||||
- `port` (Number)
|
||||
- `uri` (String)
|
||||
- `username` (String)
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_mariadb_credentials Resource - stackit"
|
||||
page_title: "stackit_mariadb_credential Resource - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
MariaDB credentials resource schema.
|
||||
MariaDB credential resource schema.
|
||||
---
|
||||
|
||||
# stackit_mariadb_credentials (Resource)
|
||||
# stackit_mariadb_credential (Resource)
|
||||
|
||||
MariaDB credentials resource schema.
|
||||
MariaDB credential resource schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
resource "stackit_mariadb_credentials" "example" {
|
||||
resource "stackit_mariadb_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_opensearch_credentials Resource - stackit"
|
||||
page_title: "stackit_opensearch_credential Resource - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
OpenSearch credentials resource schema.
|
||||
OpenSearch credential resource schema.
|
||||
---
|
||||
|
||||
# stackit_opensearch_credentials (Resource)
|
||||
# stackit_opensearch_credential (Resource)
|
||||
|
||||
OpenSearch credentials resource schema.
|
||||
OpenSearch credential resource schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
resource "stackit_opensearch_credentials" "example" {
|
||||
resource "stackit_opensearch_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_postgresql_credentials Resource - stackit"
|
||||
page_title: "stackit_postgresql_credential Resource - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
PostgreSQL credentials resource schema.
|
||||
PostgreSQL credential resource schema.
|
||||
---
|
||||
|
||||
# stackit_postgresql_credentials (Resource)
|
||||
# stackit_postgresql_credential (Resource)
|
||||
|
||||
PostgreSQL credentials resource schema.
|
||||
PostgreSQL credential resource schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
resource "stackit_postgresql_credentials" "example" {
|
||||
resource "stackit_postgresql_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_rabbitmq_credentials Resource - stackit"
|
||||
page_title: "stackit_rabbitmq_credential Resource - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
RabbitMQ credentials resource schema.
|
||||
RabbitMQ credential resource schema.
|
||||
---
|
||||
|
||||
# stackit_rabbitmq_credentials (Resource)
|
||||
# stackit_rabbitmq_credential (Resource)
|
||||
|
||||
RabbitMQ credentials resource schema.
|
||||
RabbitMQ credential resource schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
resource "stackit_rabbitmq_credentials" "example" {
|
||||
resource "stackit_rabbitmq_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_redis_credentials Resource - stackit"
|
||||
page_title: "stackit_redis_credential Resource - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
Redis credentials resource schema.
|
||||
Redis credential resource schema.
|
||||
---
|
||||
|
||||
# stackit_redis_credentials (Resource)
|
||||
# stackit_redis_credential (Resource)
|
||||
|
||||
Redis credentials resource schema.
|
||||
Redis credential resource schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
resource "stackit_redis_credentials" "example" {
|
||||
resource "stackit_redis_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
data "stackit_logme_credentials" "example" {
|
||||
data "stackit_logme_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
data "stackit_mariadb_credentials" "example" {
|
||||
data "stackit_mariadb_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
data "stackit_opensearch_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
data "stackit_opensearch_credentials" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
data "stackit_postgresql_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
data "stackit_postgresql_credentials" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
data "stackit_rabbitmq_credentials" "example" {
|
||||
data "stackit_rabbitmq_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
data "stackit_redis_credentials" "example" {
|
||||
data "stackit_redis_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
resource "stackit_logme_credentials" "example" {
|
||||
resource "stackit_logme_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
resource "stackit_mariadb_credentials" "example" {
|
||||
resource "stackit_mariadb_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
resource "stackit_opensearch_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
resource "stackit_opensearch_credentials" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
resource "stackit_postgresql_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
resource "stackit_postgresql_credentials" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
resource "stackit_rabbitmq_credentials" "example" {
|
||||
resource "stackit_rabbitmq_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
resource "stackit_redis_credentials" "example" {
|
||||
resource "stackit_redis_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ var scrapeConfigResource = map[string]string{
|
|||
"saml2_enable_url_parameters": "false",
|
||||
}
|
||||
|
||||
var credentialsResource = map[string]string{
|
||||
var credentialResource = map[string]string{
|
||||
"project_id": testutil.ProjectId,
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ func TestAccResource(t *testing.T) {
|
|||
resource.TestCheckResourceAttr("stackit_argus_scrapeconfig.scrapeconfig", "saml2.enable_url_parameters", scrapeConfigResource["saml2_enable_url_parameters"]),
|
||||
|
||||
// credentials
|
||||
resource.TestCheckResourceAttr("stackit_argus_credential.credential", "project_id", credentialsResource["project_id"]),
|
||||
resource.TestCheckResourceAttr("stackit_argus_credential.credential", "project_id", credentialResource["project_id"]),
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_argus_instance.instance", "instance_id",
|
||||
"stackit_argus_credential.credential", "instance_id",
|
||||
|
|
|
|||
|
|
@ -18,26 +18,26 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ datasource.DataSource = &credentialsDataSource{}
|
||||
_ datasource.DataSource = &credentialDataSource{}
|
||||
)
|
||||
|
||||
// NewCredentialsDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsDataSource() datasource.DataSource {
|
||||
return &credentialsDataSource{}
|
||||
// NewCredentialDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialDataSource() datasource.DataSource {
|
||||
return &credentialDataSource{}
|
||||
}
|
||||
|
||||
// credentialsDataSource is the data source implementation.
|
||||
type credentialsDataSource struct {
|
||||
// credentialDataSource is the data source implementation.
|
||||
type credentialDataSource struct {
|
||||
client *logme.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the data source type name.
|
||||
func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_logme_credentials"
|
||||
func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_logme_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the data source.
|
||||
func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -73,9 +73,9 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co
|
|||
}
|
||||
|
||||
// Schema defines the schema for the data source.
|
||||
func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "LogMe credentials data source schema.",
|
||||
"main": "LogMe credential data source schema.",
|
||||
"id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the LogMe instance.",
|
||||
|
|
@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Config.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -160,14 +160,14 @@ func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadReq
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -26,9 +26,9 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ resource.Resource = &credentialsResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialsResource{}
|
||||
_ resource.ResourceWithImportState = &credentialsResource{}
|
||||
_ resource.Resource = &credentialResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialResource{}
|
||||
_ resource.ResourceWithImportState = &credentialResource{}
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
|
|
@ -46,23 +46,23 @@ type Model struct {
|
|||
Username types.String `tfsdk:"username"`
|
||||
}
|
||||
|
||||
// NewCredentialsResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsResource() resource.Resource {
|
||||
return &credentialsResource{}
|
||||
// NewCredentialResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialResource() resource.Resource {
|
||||
return &credentialResource{}
|
||||
}
|
||||
|
||||
// credentialsResource is the resource implementation.
|
||||
type credentialsResource struct {
|
||||
// credentialResource is the resource implementation.
|
||||
type credentialResource struct {
|
||||
client *logme.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the resource type name.
|
||||
func (r *credentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_logme_credentials"
|
||||
func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_logme_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the resource.
|
||||
func (r *credentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -98,9 +98,9 @@ func (r *credentialsResource) Configure(ctx context.Context, req resource.Config
|
|||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "LogMe credentials resource schema.",
|
||||
"main": "LogMe credential resource schema.",
|
||||
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the LogMe instance.",
|
||||
|
|
@ -183,7 +183,7 @@ func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest
|
|||
}
|
||||
|
||||
// Create creates the resource and sets the initial Terraform state.
|
||||
func (r *credentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Plan.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -198,11 +198,11 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
// Create new recordset
|
||||
credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
if credentialsResp.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id")
|
||||
return
|
||||
}
|
||||
credentialsId := *credentialsResp.Id
|
||||
|
|
@ -210,19 +210,19 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
|
||||
wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
return
|
||||
}
|
||||
got, ok := wr.(*logme.CredentialsResponse)
|
||||
if !ok {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(got, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
diags = resp.State.Set(ctx, model)
|
||||
|
|
@ -234,7 +234,7 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -250,14 +250,14 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -271,13 +271,13 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
}
|
||||
|
||||
// Update updates the resource and sets the updated Terraform state on success.
|
||||
func (r *credentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
// Update shouldn't be called
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated")
|
||||
}
|
||||
|
||||
// Delete deletes the resource and removes the Terraform state on success.
|
||||
func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -295,11 +295,11 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
// Delete existing record set
|
||||
err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
_, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "LogMe credentials deleted")
|
||||
|
|
@ -307,11 +307,11 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
|
||||
// ImportState imports a resource into the Terraform state on success.
|
||||
// The expected format of the resource import identifier is: project_id,instance_id,credentials_id
|
||||
func (r *credentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
idParts := strings.Split(req.ID, core.Separator)
|
||||
if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics,
|
||||
"Error importing credentials",
|
||||
"Error importing credential",
|
||||
fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID),
|
||||
)
|
||||
return
|
||||
|
|
@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) {
|
|||
false,
|
||||
},
|
||||
{
|
||||
"nil_raw_credentials",
|
||||
"nil_raw_credential",
|
||||
&logme.CredentialsResponse{
|
||||
Id: utils.Ptr("cid"),
|
||||
},
|
||||
|
|
@ -41,7 +41,7 @@ func resourceConfig(acls string) string {
|
|||
}
|
||||
}
|
||||
|
||||
resource "stackit_logme_credentials" "credentials" {
|
||||
resource "stackit_logme_credential" "credentials" {
|
||||
project_id = stackit_logme_instance.instance.project_id
|
||||
instance_id = stackit_logme_instance.instance.instance_id
|
||||
}
|
||||
|
|
@ -75,15 +75,15 @@ func TestAccLogMeResource(t *testing.T) {
|
|||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_logme_credentials.credentials", "project_id",
|
||||
"stackit_logme_credential.credentials", "project_id",
|
||||
"stackit_logme_instance.instance", "project_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_logme_credentials.credentials", "instance_id",
|
||||
"stackit_logme_credential.credentials", "instance_id",
|
||||
"stackit_logme_instance.instance", "instance_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrSet("stackit_logme_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_logme_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("stackit_logme_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_logme_credential.credentials", "host"),
|
||||
),
|
||||
},
|
||||
// Data source
|
||||
|
|
@ -96,10 +96,10 @@ func TestAccLogMeResource(t *testing.T) {
|
|||
instance_id = stackit_logme_instance.instance.instance_id
|
||||
}
|
||||
|
||||
data "stackit_logme_credentials" "credentials" {
|
||||
project_id = stackit_logme_credentials.credentials.project_id
|
||||
instance_id = stackit_logme_credentials.credentials.instance_id
|
||||
credentials_id = stackit_logme_credentials.credentials.credentials_id
|
||||
data "stackit_logme_credential" "credentials" {
|
||||
project_id = stackit_logme_credential.credentials.project_id
|
||||
instance_id = stackit_logme_credential.credentials.instance_id
|
||||
credentials_id = stackit_logme_credential.credentials.credentials_id
|
||||
}`,
|
||||
resourceConfig(instanceResource["sgw_acl-1"]),
|
||||
),
|
||||
|
|
@ -109,18 +109,18 @@ func TestAccLogMeResource(t *testing.T) {
|
|||
|
||||
resource.TestCheckResourceAttrPair("stackit_logme_instance.instance", "instance_id",
|
||||
"data.stackit_logme_instance.instance", "instance_id"),
|
||||
resource.TestCheckResourceAttrPair("stackit_logme_credentials.credentials", "credentials_id",
|
||||
"data.stackit_logme_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrPair("stackit_logme_credential.credentials", "credentials_id",
|
||||
"data.stackit_logme_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttr("data.stackit_logme_instance.instance", "plan_id", instanceResource["plan_id"]),
|
||||
resource.TestCheckResourceAttr("data.stackit_logme_instance.instance", "name", instanceResource["name"]),
|
||||
resource.TestCheckResourceAttr("data.stackit_logme_instance.instance", "parameters.sgw_acl", instanceResource["sgw_acl-1"]),
|
||||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttr("data.stackit_logme_credentials.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_logme_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_logme_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_logme_credentials.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_logme_credentials.credentials", "uri"),
|
||||
resource.TestCheckResourceAttr("data.stackit_logme_credential.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_logme_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_logme_credential.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_logme_credential.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_logme_credential.credentials", "uri"),
|
||||
),
|
||||
},
|
||||
// Import
|
||||
|
|
@ -141,11 +141,11 @@ func TestAccLogMeResource(t *testing.T) {
|
|||
ImportStateVerify: true,
|
||||
},
|
||||
{
|
||||
ResourceName: "stackit_logme_credentials.credentials",
|
||||
ResourceName: "stackit_logme_credential.credentials",
|
||||
ImportStateIdFunc: func(s *terraform.State) (string, error) {
|
||||
r, ok := s.RootModule().Resources["stackit_logme_credentials.credentials"]
|
||||
r, ok := s.RootModule().Resources["stackit_logme_credential.credentials"]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("couldn't find resource stackit_logme_credentials.credentials")
|
||||
return "", fmt.Errorf("couldn't find resource stackit_logme_credential.credentials")
|
||||
}
|
||||
instanceId, ok := r.Primary.Attributes["instance_id"]
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -18,26 +18,26 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ datasource.DataSource = &credentialsDataSource{}
|
||||
_ datasource.DataSource = &credentialDataSource{}
|
||||
)
|
||||
|
||||
// NewCredentialsDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsDataSource() datasource.DataSource {
|
||||
return &credentialsDataSource{}
|
||||
// NewCredentialDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialDataSource() datasource.DataSource {
|
||||
return &credentialDataSource{}
|
||||
}
|
||||
|
||||
// credentialsDataSource is the data source implementation.
|
||||
type credentialsDataSource struct {
|
||||
// credentialDataSource is the data source implementation.
|
||||
type credentialDataSource struct {
|
||||
client *mariadb.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the data source type name.
|
||||
func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_mariadb_credentials"
|
||||
func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_mariadb_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the data source.
|
||||
func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -73,9 +73,9 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co
|
|||
}
|
||||
|
||||
// Schema defines the schema for the data source.
|
||||
func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "MariaDB credentials data source schema.",
|
||||
"main": "MariaDB credential data source schema.",
|
||||
"id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the MariaDB instance.",
|
||||
|
|
@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Config.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -160,14 +160,14 @@ func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadReq
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -26,9 +26,9 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ resource.Resource = &credentialsResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialsResource{}
|
||||
_ resource.ResourceWithImportState = &credentialsResource{}
|
||||
_ resource.Resource = &credentialResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialResource{}
|
||||
_ resource.ResourceWithImportState = &credentialResource{}
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
|
|
@ -46,23 +46,23 @@ type Model struct {
|
|||
Username types.String `tfsdk:"username"`
|
||||
}
|
||||
|
||||
// NewCredentialsResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsResource() resource.Resource {
|
||||
return &credentialsResource{}
|
||||
// NewCredentialResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialResource() resource.Resource {
|
||||
return &credentialResource{}
|
||||
}
|
||||
|
||||
// credentialsResource is the resource implementation.
|
||||
type credentialsResource struct {
|
||||
// credentialResource is the resource implementation.
|
||||
type credentialResource struct {
|
||||
client *mariadb.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the resource type name.
|
||||
func (r *credentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_mariadb_credentials"
|
||||
func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_mariadb_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the resource.
|
||||
func (r *credentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -98,9 +98,9 @@ func (r *credentialsResource) Configure(ctx context.Context, req resource.Config
|
|||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "MariaDB credentials resource schema.",
|
||||
"main": "MariaDB credential resource schema.",
|
||||
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the MariaDB instance.",
|
||||
|
|
@ -183,7 +183,7 @@ func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest
|
|||
}
|
||||
|
||||
// Create creates the resource and sets the initial Terraform state.
|
||||
func (r *credentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Plan.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -198,11 +198,11 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
// Create new recordset
|
||||
credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
if credentialsResp.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id")
|
||||
return
|
||||
}
|
||||
credentialsId := *credentialsResp.Id
|
||||
|
|
@ -210,19 +210,19 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
|
||||
wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
return
|
||||
}
|
||||
got, ok := wr.(*mariadb.CredentialsResponse)
|
||||
if !ok {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(got, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
diags = resp.State.Set(ctx, model)
|
||||
|
|
@ -234,7 +234,7 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -250,14 +250,14 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -271,13 +271,13 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
}
|
||||
|
||||
// Update updates the resource and sets the updated Terraform state on success.
|
||||
func (r *credentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
// Update shouldn't be called
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated")
|
||||
}
|
||||
|
||||
// Delete deletes the resource and removes the Terraform state on success.
|
||||
func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -295,11 +295,11 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
// Delete existing record set
|
||||
err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
_, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "MariaDB credentials deleted")
|
||||
|
|
@ -307,11 +307,11 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
|
||||
// ImportState imports a resource into the Terraform state on success.
|
||||
// The expected format of the resource import identifier is: project_id,instance_id,credentials_id
|
||||
func (r *credentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
idParts := strings.Split(req.ID, core.Separator)
|
||||
if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics,
|
||||
"Error importing credentials",
|
||||
"Error importing credential",
|
||||
fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID),
|
||||
)
|
||||
return
|
||||
|
|
@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) {
|
|||
false,
|
||||
},
|
||||
{
|
||||
"nil_raw_credentials",
|
||||
"nil_raw_credential",
|
||||
&mariadb.CredentialsResponse{
|
||||
Id: utils.Ptr("cid"),
|
||||
},
|
||||
|
|
@ -41,7 +41,7 @@ func resourceConfig(acls string) string {
|
|||
}
|
||||
}
|
||||
|
||||
resource "stackit_mariadb_credentials" "credentials" {
|
||||
resource "stackit_mariadb_credential" "credentials" {
|
||||
project_id = stackit_mariadb_instance.instance.project_id
|
||||
instance_id = stackit_mariadb_instance.instance.instance_id
|
||||
}
|
||||
|
|
@ -75,15 +75,15 @@ func TestAccMariaDBResource(t *testing.T) {
|
|||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_mariadb_credentials.credentials", "project_id",
|
||||
"stackit_mariadb_credential.credentials", "project_id",
|
||||
"stackit_mariadb_instance.instance", "project_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_mariadb_credentials.credentials", "instance_id",
|
||||
"stackit_mariadb_credential.credentials", "instance_id",
|
||||
"stackit_mariadb_instance.instance", "instance_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrSet("stackit_mariadb_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_mariadb_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("stackit_mariadb_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_mariadb_credential.credentials", "host"),
|
||||
),
|
||||
},
|
||||
// Data source
|
||||
|
|
@ -96,10 +96,10 @@ func TestAccMariaDBResource(t *testing.T) {
|
|||
instance_id = stackit_mariadb_instance.instance.instance_id
|
||||
}
|
||||
|
||||
data "stackit_mariadb_credentials" "credentials" {
|
||||
project_id = stackit_mariadb_credentials.credentials.project_id
|
||||
instance_id = stackit_mariadb_credentials.credentials.instance_id
|
||||
credentials_id = stackit_mariadb_credentials.credentials.credentials_id
|
||||
data "stackit_mariadb_credential" "credentials" {
|
||||
project_id = stackit_mariadb_credential.credentials.project_id
|
||||
instance_id = stackit_mariadb_credential.credentials.instance_id
|
||||
credentials_id = stackit_mariadb_credential.credentials.credentials_id
|
||||
}`,
|
||||
resourceConfig(instanceResource["sgw_acl-1"]),
|
||||
),
|
||||
|
|
@ -108,18 +108,18 @@ func TestAccMariaDBResource(t *testing.T) {
|
|||
resource.TestCheckResourceAttr("data.stackit_mariadb_instance.instance", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrPair("stackit_mariadb_instance.instance", "instance_id",
|
||||
"data.stackit_mariadb_instance.instance", "instance_id"),
|
||||
resource.TestCheckResourceAttrPair("stackit_mariadb_credentials.credentials", "credentials_id",
|
||||
"data.stackit_mariadb_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrPair("stackit_mariadb_credential.credentials", "credentials_id",
|
||||
"data.stackit_mariadb_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttr("data.stackit_mariadb_instance.instance", "plan_id", instanceResource["plan_id"]),
|
||||
resource.TestCheckResourceAttr("data.stackit_mariadb_instance.instance", "name", instanceResource["name"]),
|
||||
resource.TestCheckResourceAttr("data.stackit_mariadb_instance.instance", "parameters.sgw_acl", instanceResource["sgw_acl-1"]),
|
||||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttr("data.stackit_mariadb_credentials.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_mariadb_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_mariadb_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_mariadb_credentials.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_mariadb_credentials.credentials", "uri"),
|
||||
resource.TestCheckResourceAttr("data.stackit_mariadb_credential.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_mariadb_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_mariadb_credential.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_mariadb_credential.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_mariadb_credential.credentials", "uri"),
|
||||
),
|
||||
},
|
||||
// Import
|
||||
|
|
@ -140,11 +140,11 @@ func TestAccMariaDBResource(t *testing.T) {
|
|||
ImportStateVerify: true,
|
||||
},
|
||||
{
|
||||
ResourceName: "stackit_mariadb_credentials.credentials",
|
||||
ResourceName: "stackit_mariadb_credential.credentials",
|
||||
ImportStateIdFunc: func(s *terraform.State) (string, error) {
|
||||
r, ok := s.RootModule().Resources["stackit_mariadb_credentials.credentials"]
|
||||
r, ok := s.RootModule().Resources["stackit_mariadb_credential.credentials"]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("couldn't find resource stackit_mariadb_credentials.credentials")
|
||||
return "", fmt.Errorf("couldn't find resource stackit_mariadb_credential.credentials")
|
||||
}
|
||||
instanceId, ok := r.Primary.Attributes["instance_id"]
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func (r *bucketDataSource) Configure(ctx context.Context, req datasource.Configu
|
|||
// Schema defines the schema for the data source.
|
||||
func (r *bucketDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "ObjectStorage credentials data source schema.",
|
||||
"main": "ObjectStorage credential data source schema.",
|
||||
"id": "Terraform's internal data source identifier. It is structured as \"`project_id`,`bucket_name`\".",
|
||||
"bucket_name": "The bucket name. It must be DNS conform.",
|
||||
"project_id": "STACKIT Project ID to which the bucket is associated.",
|
||||
|
|
|
|||
|
|
@ -18,26 +18,26 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ datasource.DataSource = &credentialsDataSource{}
|
||||
_ datasource.DataSource = &credentialDataSource{}
|
||||
)
|
||||
|
||||
// NewCredentialsDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsDataSource() datasource.DataSource {
|
||||
return &credentialsDataSource{}
|
||||
// NewCredentialDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialDataSource() datasource.DataSource {
|
||||
return &credentialDataSource{}
|
||||
}
|
||||
|
||||
// credentialsDataSource is the data source implementation.
|
||||
type credentialsDataSource struct {
|
||||
// credentialDataSource is the data source implementation.
|
||||
type credentialDataSource struct {
|
||||
client *opensearch.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the data source type name.
|
||||
func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_opensearch_credentials"
|
||||
func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_opensearch_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the data source.
|
||||
func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -73,9 +73,9 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co
|
|||
}
|
||||
|
||||
// Schema defines the schema for the data source.
|
||||
func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "OpenSearch credentials data source schema.",
|
||||
"main": "OpenSearch credential data source schema.",
|
||||
"id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the OpenSearch instance.",
|
||||
|
|
@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Config.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -160,14 +160,14 @@ func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadReq
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -26,9 +26,9 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ resource.Resource = &credentialsResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialsResource{}
|
||||
_ resource.ResourceWithImportState = &credentialsResource{}
|
||||
_ resource.Resource = &credentialResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialResource{}
|
||||
_ resource.ResourceWithImportState = &credentialResource{}
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
|
|
@ -46,23 +46,23 @@ type Model struct {
|
|||
Username types.String `tfsdk:"username"`
|
||||
}
|
||||
|
||||
// NewCredentialsResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsResource() resource.Resource {
|
||||
return &credentialsResource{}
|
||||
// NewCredentialResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialResource() resource.Resource {
|
||||
return &credentialResource{}
|
||||
}
|
||||
|
||||
// credentialsResource is the resource implementation.
|
||||
type credentialsResource struct {
|
||||
// credentialResource is the resource implementation.
|
||||
type credentialResource struct {
|
||||
client *opensearch.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the resource type name.
|
||||
func (r *credentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_opensearch_credentials"
|
||||
func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_opensearch_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the resource.
|
||||
func (r *credentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -98,9 +98,9 @@ func (r *credentialsResource) Configure(ctx context.Context, req resource.Config
|
|||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "OpenSearch credentials resource schema.",
|
||||
"main": "OpenSearch credential resource schema.",
|
||||
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the OpenSearch instance.",
|
||||
|
|
@ -183,7 +183,7 @@ func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest
|
|||
}
|
||||
|
||||
// Create creates the resource and sets the initial Terraform state.
|
||||
func (r *credentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Plan.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -198,11 +198,11 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
// Create new recordset
|
||||
credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
if credentialsResp.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id")
|
||||
return
|
||||
}
|
||||
credentialsId := *credentialsResp.Id
|
||||
|
|
@ -210,19 +210,19 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
|
||||
wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
return
|
||||
}
|
||||
got, ok := wr.(*opensearch.CredentialsResponse)
|
||||
if !ok {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(got, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
diags = resp.State.Set(ctx, model)
|
||||
|
|
@ -234,7 +234,7 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -250,14 +250,14 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -271,13 +271,13 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
}
|
||||
|
||||
// Update updates the resource and sets the updated Terraform state on success.
|
||||
func (r *credentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
// Update shouldn't be called
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated")
|
||||
}
|
||||
|
||||
// Delete deletes the resource and removes the Terraform state on success.
|
||||
func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -295,11 +295,11 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
// Delete existing record set
|
||||
err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
_, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "OpenSearch credentials deleted")
|
||||
|
|
@ -307,11 +307,11 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
|
||||
// ImportState imports a resource into the Terraform state on success.
|
||||
// The expected format of the resource import identifier is: project_id,instance_id,credentials_id
|
||||
func (r *credentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
idParts := strings.Split(req.ID, core.Separator)
|
||||
if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics,
|
||||
"Error importing credentials",
|
||||
"Error importing credential",
|
||||
fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID),
|
||||
)
|
||||
return
|
||||
|
|
@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) {
|
|||
false,
|
||||
},
|
||||
{
|
||||
"nil_raw_credentials",
|
||||
"nil_raw_credential",
|
||||
&opensearch.CredentialsResponse{
|
||||
Id: utils.Ptr("cid"),
|
||||
},
|
||||
|
|
@ -37,7 +37,7 @@ func resourceConfig() string {
|
|||
version = "%s"
|
||||
}
|
||||
|
||||
resource "stackit_opensearch_credentials" "credentials" {
|
||||
resource "stackit_opensearch_credential" "credentials" {
|
||||
project_id = stackit_opensearch_instance.instance.project_id
|
||||
instance_id = stackit_opensearch_instance.instance.instance_id
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ func resourceConfigUpdate() string {
|
|||
}
|
||||
}
|
||||
|
||||
resource "stackit_opensearch_credentials" "credentials" {
|
||||
resource "stackit_opensearch_credential" "credentials" {
|
||||
project_id = stackit_opensearch_instance.instance.project_id
|
||||
instance_id = stackit_opensearch_instance.instance.instance_id
|
||||
}
|
||||
|
|
@ -99,15 +99,15 @@ func TestAccOpenSearchResource(t *testing.T) {
|
|||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_opensearch_credentials.credentials", "project_id",
|
||||
"stackit_opensearch_credential.credentials", "project_id",
|
||||
"stackit_opensearch_instance.instance", "project_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_opensearch_credentials.credentials", "instance_id",
|
||||
"stackit_opensearch_credential.credentials", "instance_id",
|
||||
"stackit_opensearch_instance.instance", "instance_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrSet("stackit_opensearch_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_opensearch_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("stackit_opensearch_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_opensearch_credential.credentials", "host"),
|
||||
),
|
||||
},
|
||||
// Data source
|
||||
|
|
@ -120,10 +120,10 @@ func TestAccOpenSearchResource(t *testing.T) {
|
|||
instance_id = stackit_opensearch_instance.instance.instance_id
|
||||
}
|
||||
|
||||
data "stackit_opensearch_credentials" "credentials" {
|
||||
project_id = stackit_opensearch_credentials.credentials.project_id
|
||||
instance_id = stackit_opensearch_credentials.credentials.instance_id
|
||||
credentials_id = stackit_opensearch_credentials.credentials.credentials_id
|
||||
data "stackit_opensearch_credential" "credentials" {
|
||||
project_id = stackit_opensearch_credential.credentials.project_id
|
||||
instance_id = stackit_opensearch_credential.credentials.instance_id
|
||||
credentials_id = stackit_opensearch_credential.credentials.credentials_id
|
||||
}`,
|
||||
resourceConfig(),
|
||||
),
|
||||
|
|
@ -132,18 +132,18 @@ func TestAccOpenSearchResource(t *testing.T) {
|
|||
resource.TestCheckResourceAttr("data.stackit_opensearch_instance.instance", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrPair("stackit_opensearch_instance.instance", "instance_id",
|
||||
"data.stackit_opensearch_instance.instance", "instance_id"),
|
||||
resource.TestCheckResourceAttrPair("stackit_opensearch_credentials.credentials", "credentials_id",
|
||||
"data.stackit_opensearch_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrPair("stackit_opensearch_credential.credentials", "credentials_id",
|
||||
"data.stackit_opensearch_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttr("data.stackit_opensearch_instance.instance", "plan_id", instanceResource["plan_id"]),
|
||||
resource.TestCheckResourceAttr("data.stackit_opensearch_instance.instance", "name", instanceResource["name"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_opensearch_instance.instance", "parameters.sgw_acl"),
|
||||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttr("data.stackit_opensearch_credentials.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_opensearch_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_opensearch_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_opensearch_credentials.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_opensearch_credentials.credentials", "uri"),
|
||||
resource.TestCheckResourceAttr("data.stackit_opensearch_credential.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_opensearch_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_opensearch_credential.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_opensearch_credential.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_opensearch_credential.credentials", "uri"),
|
||||
),
|
||||
},
|
||||
// Import
|
||||
|
|
@ -165,11 +165,11 @@ func TestAccOpenSearchResource(t *testing.T) {
|
|||
ImportStateVerify: true,
|
||||
},
|
||||
{
|
||||
ResourceName: "stackit_opensearch_credentials.credentials",
|
||||
ResourceName: "stackit_opensearch_credential.credentials",
|
||||
ImportStateIdFunc: func(s *terraform.State) (string, error) {
|
||||
r, ok := s.RootModule().Resources["stackit_opensearch_credentials.credentials"]
|
||||
r, ok := s.RootModule().Resources["stackit_opensearch_credential.credentials"]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("couldn't find resource stackit_opensearch_credentials.credentials")
|
||||
return "", fmt.Errorf("couldn't find resource stackit_opensearch_credential.credentials")
|
||||
}
|
||||
instanceId, ok := r.Primary.Attributes["instance_id"]
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -18,26 +18,26 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ datasource.DataSource = &credentialsDataSource{}
|
||||
_ datasource.DataSource = &credentialDataSource{}
|
||||
)
|
||||
|
||||
// NewCredentialsDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsDataSource() datasource.DataSource {
|
||||
return &credentialsDataSource{}
|
||||
// NewCredentialDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialDataSource() datasource.DataSource {
|
||||
return &credentialDataSource{}
|
||||
}
|
||||
|
||||
// credentialsDataSource is the data source implementation.
|
||||
type credentialsDataSource struct {
|
||||
// credentialDataSource is the data source implementation.
|
||||
type credentialDataSource struct {
|
||||
client *postgresql.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the data source type name.
|
||||
func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_postgresql_credentials"
|
||||
func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_postgresql_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the data source.
|
||||
func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -73,9 +73,9 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co
|
|||
}
|
||||
|
||||
// Schema defines the schema for the data source.
|
||||
func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "PostgreSQL credentials data source schema.",
|
||||
"main": "PostgreSQL credential data source schema.",
|
||||
"id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the PostgreSQL instance.",
|
||||
|
|
@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Config.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -160,14 +160,14 @@ func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadReq
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -26,9 +26,9 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ resource.Resource = &credentialsResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialsResource{}
|
||||
_ resource.ResourceWithImportState = &credentialsResource{}
|
||||
_ resource.Resource = &credentialResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialResource{}
|
||||
_ resource.ResourceWithImportState = &credentialResource{}
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
|
|
@ -46,23 +46,23 @@ type Model struct {
|
|||
Username types.String `tfsdk:"username"`
|
||||
}
|
||||
|
||||
// NewCredentialsResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsResource() resource.Resource {
|
||||
return &credentialsResource{}
|
||||
// NewCredentialResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialResource() resource.Resource {
|
||||
return &credentialResource{}
|
||||
}
|
||||
|
||||
// credentialsResource is the resource implementation.
|
||||
type credentialsResource struct {
|
||||
// credentialResource is the resource implementation.
|
||||
type credentialResource struct {
|
||||
client *postgresql.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the resource type name.
|
||||
func (r *credentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_postgresql_credentials"
|
||||
func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_postgresql_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the resource.
|
||||
func (r *credentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -98,9 +98,9 @@ func (r *credentialsResource) Configure(ctx context.Context, req resource.Config
|
|||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "PostgreSQL credentials resource schema.",
|
||||
"main": "PostgreSQL credential resource schema.",
|
||||
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the PostgreSQL instance.",
|
||||
|
|
@ -183,7 +183,7 @@ func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest
|
|||
}
|
||||
|
||||
// Create creates the resource and sets the initial Terraform state.
|
||||
func (r *credentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Plan.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -198,11 +198,11 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
// Create new recordset
|
||||
credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
if credentialsResp.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id")
|
||||
return
|
||||
}
|
||||
credentialsId := *credentialsResp.Id
|
||||
|
|
@ -210,19 +210,19 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
|
||||
wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
return
|
||||
}
|
||||
got, ok := wr.(*postgresql.CredentialsResponse)
|
||||
if !ok {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(got, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
diags = resp.State.Set(ctx, model)
|
||||
|
|
@ -234,7 +234,7 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -250,14 +250,14 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -271,13 +271,13 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
}
|
||||
|
||||
// Update updates the resource and sets the updated Terraform state on success.
|
||||
func (r *credentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
// Update shouldn't be called
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated")
|
||||
}
|
||||
|
||||
// Delete deletes the resource and removes the Terraform state on success.
|
||||
func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -295,11 +295,11 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
// Delete existing record set
|
||||
err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
_, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "PostgreSQL credentials deleted")
|
||||
|
|
@ -307,11 +307,11 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
|
||||
// ImportState imports a resource into the Terraform state on success.
|
||||
// The expected format of the resource import identifier is: project_id,instance_id,credentials_id
|
||||
func (r *credentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
idParts := strings.Split(req.ID, core.Separator)
|
||||
if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics,
|
||||
"Error importing credentials",
|
||||
"Error importing credential",
|
||||
fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID),
|
||||
)
|
||||
return
|
||||
|
|
@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) {
|
|||
false,
|
||||
},
|
||||
{
|
||||
"nil_raw_credentials",
|
||||
"nil_raw_credential",
|
||||
&postgresql.CredentialsResponse{
|
||||
Id: utils.Ptr("cid"),
|
||||
},
|
||||
|
|
@ -47,7 +47,7 @@ func resourceConfig(acls, frequency, plugins string) string {
|
|||
}
|
||||
}
|
||||
|
||||
resource "stackit_postgresql_credentials" "credentials" {
|
||||
resource "stackit_postgresql_credential" "credentials" {
|
||||
project_id = stackit_postgresql_instance.instance.project_id
|
||||
instance_id = stackit_postgresql_instance.instance.instance_id
|
||||
}
|
||||
|
|
@ -83,15 +83,15 @@ func TestAccPostgreSQLResource(t *testing.T) {
|
|||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_postgresql_credentials.credentials", "project_id",
|
||||
"stackit_postgresql_credential.credentials", "project_id",
|
||||
"stackit_postgresql_instance.instance", "project_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_postgresql_credentials.credentials", "instance_id",
|
||||
"stackit_postgresql_credential.credentials", "instance_id",
|
||||
"stackit_postgresql_instance.instance", "instance_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrSet("stackit_postgresql_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_postgresql_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("stackit_postgresql_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_postgresql_credential.credentials", "host"),
|
||||
),
|
||||
},
|
||||
{ // Data source
|
||||
|
|
@ -103,10 +103,10 @@ func TestAccPostgreSQLResource(t *testing.T) {
|
|||
instance_id = stackit_postgresql_instance.instance.instance_id
|
||||
}
|
||||
|
||||
data "stackit_postgresql_credentials" "credentials" {
|
||||
project_id = stackit_postgresql_credentials.credentials.project_id
|
||||
instance_id = stackit_postgresql_credentials.credentials.instance_id
|
||||
credentials_id = stackit_postgresql_credentials.credentials.credentials_id
|
||||
data "stackit_postgresql_credential" "credentials" {
|
||||
project_id = stackit_postgresql_credential.credentials.project_id
|
||||
instance_id = stackit_postgresql_credential.credentials.instance_id
|
||||
credentials_id = stackit_postgresql_credential.credentials.credentials_id
|
||||
}`,
|
||||
resourceConfig(instanceResource["sgw_acl"], instanceResource["metrics_frequency"], instanceResource["plugins"]),
|
||||
),
|
||||
|
|
@ -115,8 +115,8 @@ func TestAccPostgreSQLResource(t *testing.T) {
|
|||
resource.TestCheckResourceAttr("data.stackit_postgresql_instance.instance", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrPair("stackit_postgresql_instance.instance", "instance_id",
|
||||
"data.stackit_postgresql_instance.instance", "instance_id"),
|
||||
resource.TestCheckResourceAttrPair("stackit_postgresql_credentials.credentials", "credentials_id",
|
||||
"data.stackit_postgresql_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrPair("stackit_postgresql_credential.credentials", "credentials_id",
|
||||
"data.stackit_postgresql_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttr("data.stackit_postgresql_instance.instance", "plan_id", instanceResource["plan_id"]),
|
||||
resource.TestCheckResourceAttr("data.stackit_postgresql_instance.instance", "name", instanceResource["name"]),
|
||||
resource.TestCheckResourceAttr("data.stackit_postgresql_instance.instance", "parameters.sgw_acl", instanceResource["sgw_acl"]),
|
||||
|
|
@ -124,11 +124,11 @@ func TestAccPostgreSQLResource(t *testing.T) {
|
|||
resource.TestCheckResourceAttr("data.stackit_postgresql_instance.instance", "parameters.plugins.0", instanceResource["plugins"]),
|
||||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttr("data.stackit_postgresql_credentials.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_postgresql_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_postgresql_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_postgresql_credentials.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_postgresql_credentials.credentials", "uri"),
|
||||
resource.TestCheckResourceAttr("data.stackit_postgresql_credential.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_postgresql_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_postgresql_credential.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_postgresql_credential.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_postgresql_credential.credentials", "uri"),
|
||||
),
|
||||
},
|
||||
// Import
|
||||
|
|
@ -149,11 +149,11 @@ func TestAccPostgreSQLResource(t *testing.T) {
|
|||
ImportStateVerify: true,
|
||||
},
|
||||
{
|
||||
ResourceName: "stackit_postgresql_credentials.credentials",
|
||||
ResourceName: "stackit_postgresql_credential.credentials",
|
||||
ImportStateIdFunc: func(s *terraform.State) (string, error) {
|
||||
r, ok := s.RootModule().Resources["stackit_postgresql_credentials.credentials"]
|
||||
r, ok := s.RootModule().Resources["stackit_postgresql_credential.credentials"]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("couldn't find resource stackit_postgresql_credentials.credentials")
|
||||
return "", fmt.Errorf("couldn't find resource stackit_postgresql_credential.credentials")
|
||||
}
|
||||
instanceId, ok := r.Primary.Attributes["instance_id"]
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -18,26 +18,26 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ datasource.DataSource = &credentialsDataSource{}
|
||||
_ datasource.DataSource = &credentialDataSource{}
|
||||
)
|
||||
|
||||
// NewCredentialsDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsDataSource() datasource.DataSource {
|
||||
return &credentialsDataSource{}
|
||||
// NewCredentialDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialDataSource() datasource.DataSource {
|
||||
return &credentialDataSource{}
|
||||
}
|
||||
|
||||
// credentialsDataSource is the data source implementation.
|
||||
type credentialsDataSource struct {
|
||||
// credentialDataSource is the data source implementation.
|
||||
type credentialDataSource struct {
|
||||
client *rabbitmq.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the data source type name.
|
||||
func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_rabbitmq_credentials"
|
||||
func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_rabbitmq_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the data source.
|
||||
func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -73,9 +73,9 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co
|
|||
}
|
||||
|
||||
// Schema defines the schema for the data source.
|
||||
func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "RabbitMQ credentials data source schema.",
|
||||
"main": "RabbitMQ credential data source schema.",
|
||||
"id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the RabbitMQ instance.",
|
||||
|
|
@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Config.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -160,14 +160,14 @@ func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadReq
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -26,9 +26,9 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ resource.Resource = &credentialsResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialsResource{}
|
||||
_ resource.ResourceWithImportState = &credentialsResource{}
|
||||
_ resource.Resource = &credentialResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialResource{}
|
||||
_ resource.ResourceWithImportState = &credentialResource{}
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
|
|
@ -46,23 +46,23 @@ type Model struct {
|
|||
Username types.String `tfsdk:"username"`
|
||||
}
|
||||
|
||||
// NewCredentialsResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsResource() resource.Resource {
|
||||
return &credentialsResource{}
|
||||
// NewCredentialResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialResource() resource.Resource {
|
||||
return &credentialResource{}
|
||||
}
|
||||
|
||||
// credentialsResource is the resource implementation.
|
||||
type credentialsResource struct {
|
||||
// credentialResource is the resource implementation.
|
||||
type credentialResource struct {
|
||||
client *rabbitmq.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the resource type name.
|
||||
func (r *credentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_rabbitmq_credentials"
|
||||
func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_rabbitmq_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the resource.
|
||||
func (r *credentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -98,9 +98,9 @@ func (r *credentialsResource) Configure(ctx context.Context, req resource.Config
|
|||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "RabbitMQ credentials resource schema.",
|
||||
"main": "RabbitMQ credential resource schema.",
|
||||
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the RabbitMQ instance.",
|
||||
|
|
@ -183,7 +183,7 @@ func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest
|
|||
}
|
||||
|
||||
// Create creates the resource and sets the initial Terraform state.
|
||||
func (r *credentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Plan.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -198,11 +198,11 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
// Create new recordset
|
||||
credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
if credentialsResp.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id")
|
||||
return
|
||||
}
|
||||
credentialsId := *credentialsResp.Id
|
||||
|
|
@ -210,19 +210,19 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
|
||||
wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
return
|
||||
}
|
||||
got, ok := wr.(*rabbitmq.CredentialsResponse)
|
||||
if !ok {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(got, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
diags = resp.State.Set(ctx, model)
|
||||
|
|
@ -234,7 +234,7 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -250,14 +250,14 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -271,13 +271,13 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
}
|
||||
|
||||
// Update updates the resource and sets the updated Terraform state on success.
|
||||
func (r *credentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
// Update shouldn't be called
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated")
|
||||
}
|
||||
|
||||
// Delete deletes the resource and removes the Terraform state on success.
|
||||
func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -295,11 +295,11 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
// Delete existing record set
|
||||
err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
_, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "RabbitMQ credentials deleted")
|
||||
|
|
@ -307,11 +307,11 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
|
||||
// ImportState imports a resource into the Terraform state on success.
|
||||
// The expected format of the resource import identifier is: project_id,instance_id,credentials_id
|
||||
func (r *credentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
idParts := strings.Split(req.ID, core.Separator)
|
||||
if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics,
|
||||
"Error importing credentials",
|
||||
"Error importing credential",
|
||||
fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID),
|
||||
)
|
||||
return
|
||||
|
|
@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) {
|
|||
false,
|
||||
},
|
||||
{
|
||||
"nil_raw_credentials",
|
||||
"nil_raw_credential",
|
||||
&rabbitmq.CredentialsResponse{
|
||||
Id: utils.Ptr("cid"),
|
||||
},
|
||||
|
|
@ -88,7 +88,7 @@ func resourceConfigWithUpdate() string {
|
|||
|
||||
func resourceConfigCredentials() string {
|
||||
return `
|
||||
resource "stackit_rabbitmq_credentials" "credentials" {
|
||||
resource "stackit_rabbitmq_credential" "credentials" {
|
||||
project_id = stackit_rabbitmq_instance.instance.project_id
|
||||
instance_id = stackit_rabbitmq_instance.instance.instance_id
|
||||
}
|
||||
|
|
@ -121,15 +121,15 @@ func TestAccRabbitMQResource(t *testing.T) {
|
|||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_rabbitmq_credentials.credentials", "project_id",
|
||||
"stackit_rabbitmq_credential.credentials", "project_id",
|
||||
"stackit_rabbitmq_instance.instance", "project_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_rabbitmq_credentials.credentials", "instance_id",
|
||||
"stackit_rabbitmq_credential.credentials", "instance_id",
|
||||
"stackit_rabbitmq_instance.instance", "instance_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrSet("stackit_rabbitmq_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_rabbitmq_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("stackit_rabbitmq_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_rabbitmq_credential.credentials", "host"),
|
||||
),
|
||||
},
|
||||
// data source
|
||||
|
|
@ -142,10 +142,10 @@ func TestAccRabbitMQResource(t *testing.T) {
|
|||
instance_id = stackit_rabbitmq_instance.instance.instance_id
|
||||
}
|
||||
|
||||
data "stackit_rabbitmq_credentials" "credentials" {
|
||||
project_id = stackit_rabbitmq_credentials.credentials.project_id
|
||||
instance_id = stackit_rabbitmq_credentials.credentials.instance_id
|
||||
credentials_id = stackit_rabbitmq_credentials.credentials.credentials_id
|
||||
data "stackit_rabbitmq_credential" "credentials" {
|
||||
project_id = stackit_rabbitmq_credential.credentials.project_id
|
||||
instance_id = stackit_rabbitmq_credential.credentials.instance_id
|
||||
credentials_id = stackit_rabbitmq_credential.credentials.credentials_id
|
||||
}`,
|
||||
resourceConfig(nil),
|
||||
),
|
||||
|
|
@ -153,19 +153,19 @@ func TestAccRabbitMQResource(t *testing.T) {
|
|||
// Instance data
|
||||
resource.TestCheckResourceAttr("data.stackit_rabbitmq_instance.instance", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrPair("stackit_rabbitmq_instance.instance", "instance_id",
|
||||
"data.stackit_rabbitmq_credentials.credentials", "instance_id"),
|
||||
"data.stackit_rabbitmq_credential.credentials", "instance_id"),
|
||||
resource.TestCheckResourceAttrPair("data.stackit_rabbitmq_instance.instance", "instance_id",
|
||||
"data.stackit_rabbitmq_credentials.credentials", "instance_id"),
|
||||
"data.stackit_rabbitmq_credential.credentials", "instance_id"),
|
||||
resource.TestCheckResourceAttr("data.stackit_rabbitmq_instance.instance", "plan_id", instanceResource["plan_id"]),
|
||||
resource.TestCheckResourceAttr("data.stackit_rabbitmq_instance.instance", "name", instanceResource["name"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_instance.instance", "parameters.sgw_acl"),
|
||||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttr("data.stackit_rabbitmq_credentials.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credentials.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credentials.credentials", "uri"),
|
||||
resource.TestCheckResourceAttr("data.stackit_rabbitmq_credential.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credentials", "uri"),
|
||||
),
|
||||
},
|
||||
// Import
|
||||
|
|
@ -186,11 +186,11 @@ func TestAccRabbitMQResource(t *testing.T) {
|
|||
ImportStateVerify: true,
|
||||
},
|
||||
{
|
||||
ResourceName: "stackit_rabbitmq_credentials.credentials",
|
||||
ResourceName: "stackit_rabbitmq_credential.credentials",
|
||||
ImportStateIdFunc: func(s *terraform.State) (string, error) {
|
||||
r, ok := s.RootModule().Resources["stackit_rabbitmq_credentials.credentials"]
|
||||
r, ok := s.RootModule().Resources["stackit_rabbitmq_credential.credentials"]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("couldn't find resource stackit_rabbitmq_credentials.credentials")
|
||||
return "", fmt.Errorf("couldn't find resource stackit_rabbitmq_credential.credentials")
|
||||
}
|
||||
instanceId, ok := r.Primary.Attributes["instance_id"]
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -18,26 +18,26 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ datasource.DataSource = &credentialsDataSource{}
|
||||
_ datasource.DataSource = &credentialDataSource{}
|
||||
)
|
||||
|
||||
// NewCredentialsDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsDataSource() datasource.DataSource {
|
||||
return &credentialsDataSource{}
|
||||
// NewCredentialDataSource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialDataSource() datasource.DataSource {
|
||||
return &credentialDataSource{}
|
||||
}
|
||||
|
||||
// credentialsDataSource is the data source implementation.
|
||||
type credentialsDataSource struct {
|
||||
// credentialDataSource is the data source implementation.
|
||||
type credentialDataSource struct {
|
||||
client *redis.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the data source type name.
|
||||
func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_redis_credentials"
|
||||
func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_redis_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the data source.
|
||||
func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -73,9 +73,9 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co
|
|||
}
|
||||
|
||||
// Schema defines the schema for the data source.
|
||||
func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "Redis credentials data source schema.",
|
||||
"main": "Redis credential data source schema.",
|
||||
"id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the Redis instance.",
|
||||
|
|
@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Config.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -160,14 +160,14 @@ func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadReq
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -26,9 +26,9 @@ import (
|
|||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
var (
|
||||
_ resource.Resource = &redisCredentialsResource{}
|
||||
_ resource.ResourceWithConfigure = &redisCredentialsResource{}
|
||||
_ resource.ResourceWithImportState = &redisCredentialsResource{}
|
||||
_ resource.Resource = &credentialResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialResource{}
|
||||
_ resource.ResourceWithImportState = &credentialResource{}
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
|
|
@ -46,23 +46,23 @@ type Model struct {
|
|||
Username types.String `tfsdk:"username"`
|
||||
}
|
||||
|
||||
// NewCredentialsResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialsResource() resource.Resource {
|
||||
return &redisCredentialsResource{}
|
||||
// NewCredentialResource is a helper function to simplify the provider implementation.
|
||||
func NewCredentialResource() resource.Resource {
|
||||
return &credentialResource{}
|
||||
}
|
||||
|
||||
// credentialsResource is the resource implementation.
|
||||
type redisCredentialsResource struct {
|
||||
// credentialResource is the resource implementation.
|
||||
type credentialResource struct {
|
||||
client *redis.APIClient
|
||||
}
|
||||
|
||||
// Metadata returns the resource type name.
|
||||
func (r *redisCredentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_redis_credentials"
|
||||
func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_redis_credential"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the resource.
|
||||
func (r *redisCredentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
|
||||
// Prevent panic if the provider has not been configured.
|
||||
if req.ProviderData == nil {
|
||||
return
|
||||
|
|
@ -98,9 +98,9 @@ func (r *redisCredentialsResource) Configure(ctx context.Context, req resource.C
|
|||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *redisCredentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "Redis credentials resource schema.",
|
||||
"main": "Redis credential resource schema.",
|
||||
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".",
|
||||
"credentials_id": "The credentials ID.",
|
||||
"instance_id": "ID of the Redis instance.",
|
||||
|
|
@ -183,7 +183,7 @@ func (r *redisCredentialsResource) Schema(_ context.Context, _ resource.SchemaRe
|
|||
}
|
||||
|
||||
// Create creates the resource and sets the initial Terraform state.
|
||||
func (r *redisCredentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.Plan.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -198,11 +198,11 @@ func (r *redisCredentialsResource) Create(ctx context.Context, req resource.Crea
|
|||
// Create new recordset
|
||||
credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
if credentialsResp.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id")
|
||||
return
|
||||
}
|
||||
credentialsId := *credentialsResp.Id
|
||||
|
|
@ -210,19 +210,19 @@ func (r *redisCredentialsResource) Create(ctx context.Context, req resource.Crea
|
|||
|
||||
wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err))
|
||||
return
|
||||
}
|
||||
got, ok := wr.(*redis.CredentialsResponse)
|
||||
if !ok {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(got, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
diags = resp.State.Set(ctx, model)
|
||||
|
|
@ -234,7 +234,7 @@ func (r *redisCredentialsResource) Create(ctx context.Context, req resource.Crea
|
|||
}
|
||||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *redisCredentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -250,14 +250,14 @@ func (r *redisCredentialsResource) Read(ctx context.Context, req resource.ReadRe
|
|||
|
||||
recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -271,13 +271,13 @@ func (r *redisCredentialsResource) Read(ctx context.Context, req resource.ReadRe
|
|||
}
|
||||
|
||||
// Update updates the resource and sets the updated Terraform state on success.
|
||||
func (r *redisCredentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
// Update shouldn't be called
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated")
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated")
|
||||
}
|
||||
|
||||
// Delete deletes the resource and removes the Terraform state on success.
|
||||
func (r *redisCredentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -295,11 +295,11 @@ func (r *redisCredentialsResource) Delete(ctx context.Context, req resource.Dele
|
|||
// Delete existing record set
|
||||
err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
_, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "Redis credentials deleted")
|
||||
|
|
@ -307,11 +307,11 @@ func (r *redisCredentialsResource) Delete(ctx context.Context, req resource.Dele
|
|||
|
||||
// ImportState imports a resource into the Terraform state on success.
|
||||
// The expected format of the resource import identifier is: project_id,instance_id,credentials_id
|
||||
func (r *redisCredentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
|
||||
idParts := strings.Split(req.ID, core.Separator)
|
||||
if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics,
|
||||
"Error importing credentials",
|
||||
"Error importing credential",
|
||||
fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID),
|
||||
)
|
||||
return
|
||||
|
|
@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) {
|
|||
false,
|
||||
},
|
||||
{
|
||||
"nil_raw_credentials",
|
||||
"nil_raw_credential",
|
||||
&redis.CredentialsResponse{
|
||||
Id: utils.Ptr("cid"),
|
||||
},
|
||||
|
|
@ -88,7 +88,7 @@ func resourceConfigWithUpdate() string {
|
|||
|
||||
func resourceConfigCredentials() string {
|
||||
return `
|
||||
resource "stackit_redis_credentials" "credentials" {
|
||||
resource "stackit_redis_credential" "credentials" {
|
||||
project_id = stackit_redis_instance.instance.project_id
|
||||
instance_id = stackit_redis_instance.instance.instance_id
|
||||
}
|
||||
|
|
@ -121,15 +121,15 @@ func TestAccRedisResource(t *testing.T) {
|
|||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_redis_credentials.credentials", "project_id",
|
||||
"stackit_redis_credential.credentials", "project_id",
|
||||
"stackit_redis_instance.instance", "project_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrPair(
|
||||
"stackit_redis_credentials.credentials", "instance_id",
|
||||
"stackit_redis_credential.credentials", "instance_id",
|
||||
"stackit_redis_instance.instance", "instance_id",
|
||||
),
|
||||
resource.TestCheckResourceAttrSet("stackit_redis_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_redis_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("stackit_redis_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("stackit_redis_credential.credentials", "host"),
|
||||
),
|
||||
},
|
||||
// data source
|
||||
|
|
@ -142,10 +142,10 @@ func TestAccRedisResource(t *testing.T) {
|
|||
instance_id = stackit_redis_instance.instance.instance_id
|
||||
}
|
||||
|
||||
data "stackit_redis_credentials" "credentials" {
|
||||
project_id = stackit_redis_credentials.credentials.project_id
|
||||
instance_id = stackit_redis_credentials.credentials.instance_id
|
||||
credentials_id = stackit_redis_credentials.credentials.credentials_id
|
||||
data "stackit_redis_credential" "credentials" {
|
||||
project_id = stackit_redis_credential.credentials.project_id
|
||||
instance_id = stackit_redis_credential.credentials.instance_id
|
||||
credentials_id = stackit_redis_credential.credentials.credentials_id
|
||||
}`,
|
||||
resourceConfig(nil),
|
||||
),
|
||||
|
|
@ -153,19 +153,19 @@ func TestAccRedisResource(t *testing.T) {
|
|||
// Instance data
|
||||
resource.TestCheckResourceAttr("data.stackit_redis_instance.instance", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrPair("stackit_redis_instance.instance", "instance_id",
|
||||
"data.stackit_redis_credentials.credentials", "instance_id"),
|
||||
"data.stackit_redis_credential.credentials", "instance_id"),
|
||||
resource.TestCheckResourceAttrPair("data.stackit_redis_instance.instance", "instance_id",
|
||||
"data.stackit_redis_credentials.credentials", "instance_id"),
|
||||
"data.stackit_redis_credential.credentials", "instance_id"),
|
||||
resource.TestCheckResourceAttr("data.stackit_redis_instance.instance", "plan_id", instanceResource["plan_id"]),
|
||||
resource.TestCheckResourceAttr("data.stackit_redis_instance.instance", "name", instanceResource["name"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_redis_instance.instance", "parameters.sgw_acl"),
|
||||
|
||||
// Credentials data
|
||||
resource.TestCheckResourceAttr("data.stackit_redis_credentials.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_redis_credentials.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_redis_credentials.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_redis_credentials.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_redis_credentials.credentials", "uri"),
|
||||
resource.TestCheckResourceAttr("data.stackit_redis_credential.credentials", "project_id", instanceResource["project_id"]),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credentials", "credentials_id"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credentials", "host"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credentials", "port"),
|
||||
resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credentials", "uri"),
|
||||
),
|
||||
},
|
||||
// Import
|
||||
|
|
@ -186,11 +186,11 @@ func TestAccRedisResource(t *testing.T) {
|
|||
ImportStateVerify: true,
|
||||
},
|
||||
{
|
||||
ResourceName: "stackit_redis_credentials.credentials",
|
||||
ResourceName: "stackit_redis_credential.credentials",
|
||||
ImportStateIdFunc: func(s *terraform.State) (string, error) {
|
||||
r, ok := s.RootModule().Resources["stackit_redis_credentials.credentials"]
|
||||
r, ok := s.RootModule().Resources["stackit_redis_credential.credentials"]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("couldn't find resource stackit_redis_credentials.credentials")
|
||||
return "", fmt.Errorf("couldn't find resource stackit_redis_credential.credentials")
|
||||
}
|
||||
instanceId, ok := r.Primary.Attributes["instance_id"]
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -14,20 +14,20 @@ import (
|
|||
argusScrapeConfig "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/argus/scrapeconfig"
|
||||
dnsRecordSet "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/dns/recordset"
|
||||
dnsZone "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/dns/zone"
|
||||
logMeCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/logme/credentials"
|
||||
logMeCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/logme/credential"
|
||||
logMeInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/logme/instance"
|
||||
mariaDBCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/mariadb/credentials"
|
||||
mariaDBCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/mariadb/credential"
|
||||
mariaDBInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/mariadb/instance"
|
||||
objectStorageBucket "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/objectstorage/bucket"
|
||||
openSearchCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/opensearch/credentials"
|
||||
openSearchCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/opensearch/credential"
|
||||
openSearchInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/opensearch/instance"
|
||||
postgresFlexInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflex/instance"
|
||||
postgresFlexUser "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflex/user"
|
||||
postgresCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresql/credentials"
|
||||
postgresCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresql/credential"
|
||||
postgresInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresql/instance"
|
||||
rabbitMQCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/rabbitmq/credentials"
|
||||
rabbitMQCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/rabbitmq/credential"
|
||||
rabbitMQInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/rabbitmq/instance"
|
||||
redisCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/redis/credentials"
|
||||
redisCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/redis/credential"
|
||||
redisInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/redis/instance"
|
||||
resourceManagerProject "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/resourcemanager/project"
|
||||
skeCluster "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/ske/cluster"
|
||||
|
|
@ -307,18 +307,18 @@ func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource
|
|||
dnsZone.NewZoneDataSource,
|
||||
dnsRecordSet.NewRecordSetDataSource,
|
||||
postgresInstance.NewInstanceDataSource,
|
||||
postgresCredentials.NewCredentialsDataSource,
|
||||
postgresCredential.NewCredentialDataSource,
|
||||
logMeInstance.NewInstanceDataSource,
|
||||
logMeCredentials.NewCredentialsDataSource,
|
||||
logMeCredential.NewCredentialDataSource,
|
||||
mariaDBInstance.NewInstanceDataSource,
|
||||
mariaDBCredentials.NewCredentialsDataSource,
|
||||
mariaDBCredential.NewCredentialDataSource,
|
||||
objectStorageBucket.NewBucketDataSource,
|
||||
openSearchInstance.NewInstanceDataSource,
|
||||
openSearchCredentials.NewCredentialsDataSource,
|
||||
openSearchCredential.NewCredentialDataSource,
|
||||
rabbitMQInstance.NewInstanceDataSource,
|
||||
rabbitMQCredentials.NewCredentialsDataSource,
|
||||
rabbitMQCredential.NewCredentialDataSource,
|
||||
redisInstance.NewInstanceDataSource,
|
||||
redisCredentials.NewCredentialsDataSource,
|
||||
redisCredential.NewCredentialDataSource,
|
||||
argusInstance.NewInstanceDataSource,
|
||||
argusScrapeConfig.NewScrapeConfigDataSource,
|
||||
resourceManagerProject.NewProjectDataSource,
|
||||
|
|
@ -335,18 +335,18 @@ func (p *Provider) Resources(_ context.Context) []func() resource.Resource {
|
|||
dnsZone.NewZoneResource,
|
||||
dnsRecordSet.NewRecordSetResource,
|
||||
postgresInstance.NewInstanceResource,
|
||||
postgresCredentials.NewCredentialsResource,
|
||||
postgresCredential.NewCredentialResource,
|
||||
logMeInstance.NewInstanceResource,
|
||||
logMeCredentials.NewCredentialsResource,
|
||||
logMeCredential.NewCredentialResource,
|
||||
mariaDBInstance.NewInstanceResource,
|
||||
mariaDBCredentials.NewCredentialsResource,
|
||||
mariaDBCredential.NewCredentialResource,
|
||||
objectStorageBucket.NewBucketResource,
|
||||
openSearchInstance.NewInstanceResource,
|
||||
openSearchCredentials.NewCredentialsResource,
|
||||
openSearchCredential.NewCredentialResource,
|
||||
rabbitMQInstance.NewInstanceResource,
|
||||
rabbitMQCredentials.NewCredentialsResource,
|
||||
rabbitMQCredential.NewCredentialResource,
|
||||
redisInstance.NewInstanceResource,
|
||||
redisCredentials.NewCredentialsResource,
|
||||
redisCredential.NewCredentialResource,
|
||||
argusInstance.NewInstanceResource,
|
||||
argusScrapeConfig.NewScrapeConfigResource,
|
||||
resourceManagerProject.NewProjectResource,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue