feat: Allow move state on new Observability resources (#593)
* feat: Allow move state on new Observability resources * Extend description to explain how to move a argus resource to observability * Update argus docs with examples how to move a resource to observability --------- Co-authored-by: Marcel Jacek <Marcel.Jacek@stackit.cloud>
This commit is contained in:
parent
fc805d8e1d
commit
1a66887c01
12 changed files with 438 additions and 15 deletions
|
|
@ -5,6 +5,25 @@ subcategory: ""
|
|||
description: |-
|
||||
Argus credential resource schema. Must have a region specified in the provider configuration.
|
||||
!> The stackit_argus_credential resource has been deprecated and will be removed after February 26th 2025. Please use stackit_observability_credential instead, which offers the exact same functionality.
|
||||
Example move
|
||||
Example to move the deprecated stackit_argus_credential resource to the new stackit_observability_credential resource:
|
||||
1. Add a new stackit_observability_credential resource with the same values like your previous stackit_argus_credential resource.
|
||||
1. Add a moved block which reference the stackit_argus_credential and stackit_observability_credential resource.
|
||||
1. Remove your old stackit_argus_credential resource and run $ terraform apply.
|
||||
```terraform
|
||||
resource "stackitarguscredential" "example" {
|
||||
projectid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instanceid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
moved {
|
||||
from = stackitarguscredential.example
|
||||
to = stackitobservabilitycredential.example
|
||||
}
|
||||
resource "stackitobservabilitycredential" "example" {
|
||||
projectid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instanceid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
```
|
||||
---
|
||||
|
||||
# stackit_argus_credential (Resource)
|
||||
|
|
@ -13,6 +32,28 @@ Argus credential resource schema. Must have a `region` specified in the provider
|
|||
|
||||
!> The `stackit_argus_credential` resource has been deprecated and will be removed after February 26th 2025. Please use `stackit_observability_credential` instead, which offers the exact same functionality.
|
||||
|
||||
## Example move
|
||||
Example to move the deprecated `stackit_argus_credential` resource to the new `stackit_observability_credential` resource:
|
||||
1. Add a new `stackit_observability_credential` resource with the same values like your previous `stackit_argus_credential` resource.
|
||||
1. Add a moved block which reference the `stackit_argus_credential` and `stackit_observability_credential` resource.
|
||||
1. Remove your old `stackit_argus_credential` resource and run `$ terraform apply`.
|
||||
```terraform
|
||||
resource "stackit_argus_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
||||
moved {
|
||||
from = stackit_argus_credential.example
|
||||
to = stackit_observability_credential.example
|
||||
}
|
||||
|
||||
resource "stackit_observability_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
```
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
|
|
|
|||
|
|
@ -5,6 +5,35 @@ subcategory: ""
|
|||
description: |-
|
||||
Argus instance resource schema. Must have a region specified in the provider configuration.
|
||||
!> The stackit_argus_instance resource has been deprecated and will be removed after February 26th 2025. Please use stackit_observability_instance instead, which offers the exact same functionality.
|
||||
Example move
|
||||
Example to move the deprecated stackit_argus_instance resource to the newstackit_observability_instance resource:
|
||||
1. Add a new stackit_observability_instance resource with the same values like your previous stackit_argus_instance resource.
|
||||
1. Add a moved block which reference the stackit_argus_instance and stackit_observability_instance resource.
|
||||
1. Remove your old stackit_argus_instance resource and run $ terraform apply.
|
||||
```terraform
|
||||
resource "stackitargusinstance" "example" {
|
||||
projectid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-instance"
|
||||
planname = "Monitoring-Medium-EU01"
|
||||
acl = ["1.1.1.1/32", "2.2.2.2/32"]
|
||||
metricsretentiondays = 7
|
||||
metricsretentiondays5mdownsampling = 30
|
||||
metricsretentiondays1hdownsampling = 365
|
||||
}
|
||||
moved {
|
||||
from = stackitargusinstance.example
|
||||
to = stackitobservabilityinstance.example
|
||||
}
|
||||
resource "stackitobservabilityinstance" "example" {
|
||||
projectid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-instance"
|
||||
planname = "Monitoring-Medium-EU01"
|
||||
acl = ["1.1.1.1/32", "2.2.2.2/32"]
|
||||
metricsretentiondays = 7
|
||||
metricsretentiondays5mdownsampling = 30
|
||||
metricsretentiondays1hdownsampling = 365
|
||||
}
|
||||
```
|
||||
---
|
||||
|
||||
# stackit_argus_instance (Resource)
|
||||
|
|
@ -13,6 +42,38 @@ Argus instance resource schema. Must have a `region` specified in the provider c
|
|||
|
||||
!> The `stackit_argus_instance` resource has been deprecated and will be removed after February 26th 2025. Please use `stackit_observability_instance` instead, which offers the exact same functionality.
|
||||
|
||||
## Example move
|
||||
Example to move the deprecated `stackit_argus_instance` resource to the new`stackit_observability_instance` resource:
|
||||
1. Add a new `stackit_observability_instance` resource with the same values like your previous `stackit_argus_instance` resource.
|
||||
1. Add a moved block which reference the `stackit_argus_instance` and `stackit_observability_instance` resource.
|
||||
1. Remove your old `stackit_argus_instance` resource and run `$ terraform apply`.
|
||||
```terraform
|
||||
resource "stackit_argus_instance" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-instance"
|
||||
plan_name = "Monitoring-Medium-EU01"
|
||||
acl = ["1.1.1.1/32", "2.2.2.2/32"]
|
||||
metrics_retention_days = 7
|
||||
metrics_retention_days_5m_downsampling = 30
|
||||
metrics_retention_days_1h_downsampling = 365
|
||||
}
|
||||
|
||||
moved {
|
||||
from = stackit_argus_instance.example
|
||||
to = stackit_observability_instance.example
|
||||
}
|
||||
|
||||
resource "stackit_observability_instance" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-instance"
|
||||
plan_name = "Monitoring-Medium-EU01"
|
||||
acl = ["1.1.1.1/32", "2.2.2.2/32"]
|
||||
metrics_retention_days = 7
|
||||
metrics_retention_days_5m_downsampling = 30
|
||||
metrics_retention_days_1h_downsampling = 365
|
||||
}
|
||||
```
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
|
|
|
|||
|
|
@ -5,6 +5,35 @@ subcategory: ""
|
|||
description: |-
|
||||
Argus scrape config resource schema. Must have a region specified in the provider configuration.
|
||||
!> The stackit_argus_scrapeconfig resource has been deprecated and will be removed after February 26th 2025. Please use stackit_observability_scrapeconfig instead, which offers the exact same functionality.
|
||||
Example move
|
||||
Example to move the deprecated stackit_argus_scrapeconfig resource to the new stackit_observability_scrapeconfig resource:
|
||||
1. Add a new stackit_observability_scrapeconfig resource with the same values like your previous stackit_argus_scrapeconfig resource.
|
||||
1. Add a moved block which reference the stackit_argus_scrapeconfig and stackit_observability_scrapeconfig resource.
|
||||
1. Remove your old stackit_argus_scrapeconfig resource and run $ terraform apply.
|
||||
```terraform
|
||||
resource "stackitargusscrapeconfig" "example" {
|
||||
projectid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-instance"
|
||||
planname = "Monitoring-Medium-EU01"
|
||||
acl = ["1.1.1.1/32", "2.2.2.2/32"]
|
||||
metricsretentiondays = 7
|
||||
metricsretentiondays5mdownsampling = 30
|
||||
metricsretentiondays1hdownsampling = 365
|
||||
}
|
||||
moved {
|
||||
from = stackitargusscrapeconfig.example
|
||||
to = stackitobservabilityscrapeconfig.example
|
||||
}
|
||||
resource "stackitobservabilityscrapeconfig" "example" {
|
||||
projectid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-instance"
|
||||
planname = "Monitoring-Medium-EU01"
|
||||
acl = ["1.1.1.1/32", "2.2.2.2/32"]
|
||||
metricsretentiondays = 7
|
||||
metricsretentiondays5mdownsampling = 30
|
||||
metricsretentiondays1hdownsampling = 365
|
||||
}
|
||||
```
|
||||
---
|
||||
|
||||
# stackit_argus_scrapeconfig (Resource)
|
||||
|
|
@ -13,6 +42,38 @@ Argus scrape config resource schema. Must have a `region` specified in the provi
|
|||
|
||||
!> The `stackit_argus_scrapeconfig` resource has been deprecated and will be removed after February 26th 2025. Please use `stackit_observability_scrapeconfig` instead, which offers the exact same functionality.
|
||||
|
||||
## Example move
|
||||
Example to move the deprecated `stackit_argus_scrapeconfig` resource to the new `stackit_observability_scrapeconfig` resource:
|
||||
1. Add a new `stackit_observability_scrapeconfig` resource with the same values like your previous `stackit_argus_scrapeconfig` resource.
|
||||
1. Add a moved block which reference the `stackit_argus_scrapeconfig` and `stackit_observability_scrapeconfig` resource.
|
||||
1. Remove your old `stackit_argus_scrapeconfig` resource and run `$ terraform apply`.
|
||||
```terraform
|
||||
resource "stackit_argus_scrapeconfig" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-instance"
|
||||
plan_name = "Monitoring-Medium-EU01"
|
||||
acl = ["1.1.1.1/32", "2.2.2.2/32"]
|
||||
metrics_retention_days = 7
|
||||
metrics_retention_days_5m_downsampling = 30
|
||||
metrics_retention_days_1h_downsampling = 365
|
||||
}
|
||||
|
||||
moved {
|
||||
from = stackit_argus_scrapeconfig.example
|
||||
to = stackit_observability_scrapeconfig.example
|
||||
}
|
||||
|
||||
resource "stackit_observability_scrapeconfig" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-instance"
|
||||
plan_name = "Monitoring-Medium-EU01"
|
||||
acl = ["1.1.1.1/32", "2.2.2.2/32"]
|
||||
metrics_retention_days = 7
|
||||
metrics_retention_days_5m_downsampling = 30
|
||||
metrics_retention_days_1h_downsampling = 365
|
||||
}
|
||||
```
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
|
|
|
|||
24
stackit/internal/services/argus/credential/const.go
Normal file
24
stackit/internal/services/argus/credential/const.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package argus
|
||||
|
||||
const exampleMoveToObservability = "## Example move\n" +
|
||||
"Example to move the deprecated `stackit_argus_credential` resource to the new `stackit_observability_credential` resource:" + "\n" +
|
||||
"1. Add a new `stackit_observability_credential` resource with the same values like your previous `stackit_argus_credential` resource." + "\n" +
|
||||
"1. Add a moved block which reference the `stackit_argus_credential` and `stackit_observability_credential` resource." + "\n" +
|
||||
"1. Remove your old `stackit_argus_credential` resource and run `$ terraform apply`." + "\n" +
|
||||
"```terraform" +
|
||||
`
|
||||
resource "stackit_argus_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
|
||||
moved {
|
||||
from = stackit_argus_credential.example
|
||||
to = stackit_observability_credential.example
|
||||
}
|
||||
|
||||
resource "stackit_observability_credential" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
}
|
||||
` + "```" + "\n"
|
||||
|
|
@ -86,16 +86,17 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu
|
|||
tflog.Info(ctx, "Argus credential client configured")
|
||||
}
|
||||
|
||||
func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
var (
|
||||
descriptions = map[string]string{
|
||||
"main": "Argus credential resource schema. Must have a `region` specified in the provider configuration.",
|
||||
"deprecation_message": "The `stackit_argus_credential` resource has been deprecated and will be removed after February 26th 2025. " +
|
||||
"Please use `stackit_observability_credential` instead, which offers the exact same functionality.",
|
||||
}
|
||||
resp.Schema = schema.Schema{
|
||||
Schema = schema.Schema{
|
||||
Description: fmt.Sprintf("%s\n%s", descriptions["main"], descriptions["deprecation_message"]),
|
||||
MarkdownDescription: fmt.Sprintf("%s\n\n!> %s", descriptions["main"], descriptions["deprecation_message"]),
|
||||
DeprecationMessage: descriptions["deprecation_message"],
|
||||
MarkdownDescription: fmt.Sprintf("%s\n\n!> %s\n\n%s", descriptions["main"], descriptions["deprecation_message"], exampleMoveToObservability),
|
||||
|
||||
DeprecationMessage: descriptions["deprecation_message"],
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"id": schema.StringAttribute{
|
||||
Description: "Terraform's internal resource ID. It is structured as \"`project_id`,`instance_id`,`username`\".",
|
||||
|
|
@ -144,6 +145,10 @@ func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
|
|||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
resp.Schema = Schema
|
||||
}
|
||||
|
||||
// Create creates the resource and sets the initial Terraform state.
|
||||
|
|
|
|||
34
stackit/internal/services/argus/instance/const.go
Normal file
34
stackit/internal/services/argus/instance/const.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package argus
|
||||
|
||||
const exampleMoveToObservability = "## Example move\n" +
|
||||
"Example to move the deprecated `stackit_argus_instance` resource to the new`stackit_observability_instance` resource:" + "\n" +
|
||||
"1. Add a new `stackit_observability_instance` resource with the same values like your previous `stackit_argus_instance` resource." + "\n" +
|
||||
"1. Add a moved block which reference the `stackit_argus_instance` and `stackit_observability_instance` resource." + "\n" +
|
||||
"1. Remove your old `stackit_argus_instance` resource and run `$ terraform apply`." + "\n" +
|
||||
"```terraform" +
|
||||
`
|
||||
resource "stackit_argus_instance" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-instance"
|
||||
plan_name = "Monitoring-Medium-EU01"
|
||||
acl = ["1.1.1.1/32", "2.2.2.2/32"]
|
||||
metrics_retention_days = 7
|
||||
metrics_retention_days_5m_downsampling = 30
|
||||
metrics_retention_days_1h_downsampling = 365
|
||||
}
|
||||
|
||||
moved {
|
||||
from = stackit_argus_instance.example
|
||||
to = stackit_observability_instance.example
|
||||
}
|
||||
|
||||
resource "stackit_observability_instance" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-instance"
|
||||
plan_name = "Monitoring-Medium-EU01"
|
||||
acl = ["1.1.1.1/32", "2.2.2.2/32"]
|
||||
metrics_retention_days = 7
|
||||
metrics_retention_days_5m_downsampling = 30
|
||||
metrics_retention_days_1h_downsampling = 365
|
||||
}
|
||||
` + "```" + "\n"
|
||||
|
|
@ -373,16 +373,15 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
|
|||
tflog.Info(ctx, "Argus instance client configured")
|
||||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
var (
|
||||
descriptions = map[string]string{
|
||||
"main": "Argus instance resource schema. Must have a `region` specified in the provider configuration.",
|
||||
"deprecation_message": "The `stackit_argus_instance` resource has been deprecated and will be removed after February 26th 2025. " +
|
||||
"Please use `stackit_observability_instance` instead, which offers the exact same functionality.",
|
||||
}
|
||||
resp.Schema = schema.Schema{
|
||||
Schema = schema.Schema{
|
||||
Description: fmt.Sprintf("%s\n%s", descriptions["main"], descriptions["deprecation_message"]),
|
||||
MarkdownDescription: fmt.Sprintf("%s\n\n!> %s", descriptions["main"], descriptions["deprecation_message"]),
|
||||
MarkdownDescription: fmt.Sprintf("%s\n\n!> %s\n\n%s", descriptions["main"], descriptions["deprecation_message"], exampleMoveToObservability),
|
||||
DeprecationMessage: descriptions["deprecation_message"],
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"id": schema.StringAttribute{
|
||||
|
|
@ -776,6 +775,11 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
|
|||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
resp.Schema = Schema
|
||||
}
|
||||
|
||||
// Create creates the resource and sets the initial Terraform state.
|
||||
|
|
|
|||
50
stackit/internal/services/argus/scrapeconfig/const.go
Normal file
50
stackit/internal/services/argus/scrapeconfig/const.go
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
package argus
|
||||
|
||||
const exampleMoveToObservability = "## Example move\n" +
|
||||
"Example to move the deprecated `stackit_argus_scrapeconfig` resource to the new `stackit_observability_scrapeconfig` resource:" + "\n" +
|
||||
"1. Add a new `stackit_observability_scrapeconfig` resource with the same values like your previous `stackit_argus_scrapeconfig` resource." + "\n" +
|
||||
"1. Add a moved block which reference the `stackit_argus_scrapeconfig` and `stackit_observability_scrapeconfig` resource." + "\n" +
|
||||
"1. Remove your old `stackit_argus_scrapeconfig` resource and run `$ terraform apply`." + "\n" +
|
||||
"```terraform" +
|
||||
`
|
||||
resource "stackit_argus_scrapeconfig" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-job"
|
||||
metrics_path = "/my-metrics"
|
||||
saml2 = {
|
||||
enable_url_parameters = true
|
||||
}
|
||||
targets = [
|
||||
{
|
||||
urls = ["url1", "urls2"]
|
||||
labels = {
|
||||
"url1" = "dev"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
moved {
|
||||
from = stackit_argus_scrapeconfig.example
|
||||
to = stackit_observability_scrapeconfig.example
|
||||
}
|
||||
|
||||
resource "stackit_observability_scrapeconfig" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-job"
|
||||
metrics_path = "/my-metrics"
|
||||
saml2 = {
|
||||
enable_url_parameters = true
|
||||
}
|
||||
targets = [
|
||||
{
|
||||
urls = ["url1", "urls2"]
|
||||
labels = {
|
||||
"url1" = "dev"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
` + "```" + "\n"
|
||||
|
|
@ -149,16 +149,15 @@ func (r *scrapeConfigResource) Configure(ctx context.Context, req resource.Confi
|
|||
tflog.Info(ctx, "Argus scrape config client configured")
|
||||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *scrapeConfigResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
var (
|
||||
descriptions = map[string]string{
|
||||
"main": "Argus scrape config resource schema. Must have a `region` specified in the provider configuration.",
|
||||
"deprecation_message": "The `stackit_argus_scrapeconfig` resource has been deprecated and will be removed after February 26th 2025. " +
|
||||
"Please use `stackit_observability_scrapeconfig` instead, which offers the exact same functionality.",
|
||||
}
|
||||
resp.Schema = schema.Schema{
|
||||
Schema = schema.Schema{
|
||||
Description: fmt.Sprintf("%s\n%s", descriptions["main"], descriptions["deprecation_message"]),
|
||||
MarkdownDescription: fmt.Sprintf("%s\n\n!> %s", descriptions["main"], descriptions["deprecation_message"]),
|
||||
MarkdownDescription: fmt.Sprintf("%s\n\n!> %s\n\n%s", descriptions["main"], descriptions["deprecation_message"], exampleMoveToObservability),
|
||||
DeprecationMessage: descriptions["deprecation_message"],
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"id": schema.StringAttribute{
|
||||
|
|
@ -317,6 +316,11 @@ func (r *scrapeConfigResource) Schema(_ context.Context, _ resource.SchemaReques
|
|||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *scrapeConfigResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
resp.Schema = Schema
|
||||
}
|
||||
|
||||
// Create creates the resource and sets the initial Terraform state.
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
|
||||
"github.com/stackitcloud/stackit-sdk-go/services/observability"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
|
||||
argusCredentialResource "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/argus/credential"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
|
||||
)
|
||||
|
||||
|
|
@ -25,6 +26,7 @@ import (
|
|||
var (
|
||||
_ resource.Resource = &credentialResource{}
|
||||
_ resource.ResourceWithConfigure = &credentialResource{}
|
||||
_ resource.ResourceWithMoveState = &credentialResource{}
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
|
|
@ -86,6 +88,40 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu
|
|||
tflog.Info(ctx, "Observability credential client configured")
|
||||
}
|
||||
|
||||
func (r *credentialResource) MoveState(_ context.Context) []resource.StateMover {
|
||||
return []resource.StateMover{
|
||||
{
|
||||
SourceSchema: &argusCredentialResource.Schema,
|
||||
StateMover: func(ctx context.Context, req resource.MoveStateRequest, resp *resource.MoveStateResponse) {
|
||||
if req.SourceTypeName != "stackit_argus_credential" {
|
||||
return
|
||||
}
|
||||
|
||||
// Checks source provider
|
||||
if !strings.HasSuffix(req.SourceProviderAddress, "stackitcloud/stackit") {
|
||||
return
|
||||
}
|
||||
|
||||
var sourceStateData argusCredentialResource.Model
|
||||
resp.Diagnostics.Append(req.SourceState.Get(ctx, &sourceStateData)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
targetStateData := Model{
|
||||
Id: sourceStateData.Id,
|
||||
ProjectId: sourceStateData.ProjectId,
|
||||
InstanceId: sourceStateData.InstanceId,
|
||||
Username: sourceStateData.Username,
|
||||
Password: sourceStateData.Password,
|
||||
}
|
||||
|
||||
resp.Diagnostics.Append(resp.TargetState.Set(ctx, targetStateData)...)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
resp.Schema = schema.Schema{
|
||||
Description: "Observability credential resource schema. Must have a `region` specified in the provider configuration.",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/stackitcloud/stackit-sdk-go/services/observability/wait"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
|
||||
argusInstanceResource "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/argus/instance"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
|
||||
)
|
||||
|
||||
|
|
@ -41,6 +42,7 @@ var (
|
|||
_ resource.Resource = &instanceResource{}
|
||||
_ resource.ResourceWithConfigure = &instanceResource{}
|
||||
_ resource.ResourceWithImportState = &instanceResource{}
|
||||
_ resource.ResourceWithMoveState = &instanceResource{}
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
|
|
@ -373,6 +375,64 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
|
|||
tflog.Info(ctx, "Observability instance client configured")
|
||||
}
|
||||
|
||||
// MoveState moves the state of a `stackit_argus_instance` resource to a `stackit_observability_instance` resource.
|
||||
func (r *instanceResource) MoveState(_ context.Context) []resource.StateMover {
|
||||
return []resource.StateMover{
|
||||
{
|
||||
SourceSchema: &argusInstanceResource.Schema,
|
||||
StateMover: func(ctx context.Context, req resource.MoveStateRequest, resp *resource.MoveStateResponse) {
|
||||
if req.SourceTypeName != "stackit_argus_instance" {
|
||||
return
|
||||
}
|
||||
|
||||
// Checks source provider
|
||||
if !strings.HasSuffix(req.SourceProviderAddress, "stackitcloud/stackit") {
|
||||
return
|
||||
}
|
||||
|
||||
var sourceStateData argusInstanceResource.Model
|
||||
resp.Diagnostics.Append(req.SourceState.Get(ctx, &sourceStateData)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
targetStateData := Model{
|
||||
Id: sourceStateData.Id,
|
||||
ProjectId: sourceStateData.ProjectId,
|
||||
InstanceId: sourceStateData.InstanceId,
|
||||
Name: sourceStateData.Name,
|
||||
PlanName: sourceStateData.PlanName,
|
||||
PlanId: sourceStateData.PlanId,
|
||||
Parameters: sourceStateData.Parameters,
|
||||
DashboardURL: sourceStateData.DashboardURL,
|
||||
IsUpdatable: sourceStateData.IsUpdatable,
|
||||
GrafanaURL: sourceStateData.GrafanaURL,
|
||||
GrafanaPublicReadAccess: sourceStateData.GrafanaPublicReadAccess,
|
||||
GrafanaInitialAdminPassword: sourceStateData.GrafanaInitialAdminPassword,
|
||||
GrafanaInitialAdminUser: sourceStateData.GrafanaInitialAdminUser,
|
||||
MetricsRetentionDays: sourceStateData.MetricsRetentionDays,
|
||||
MetricsRetentionDays5mDownsampling: sourceStateData.MetricsRetentionDays5mDownsampling,
|
||||
MetricsRetentionDays1hDownsampling: sourceStateData.MetricsRetentionDays1hDownsampling,
|
||||
MetricsURL: sourceStateData.MetricsURL,
|
||||
MetricsPushURL: sourceStateData.MetricsPushURL,
|
||||
TargetsURL: sourceStateData.TargetsURL,
|
||||
AlertingURL: sourceStateData.AlertingURL,
|
||||
LogsURL: sourceStateData.LogsURL,
|
||||
LogsPushURL: sourceStateData.LogsPushURL,
|
||||
JaegerTracesURL: sourceStateData.JaegerTracesURL,
|
||||
JaegerUIURL: sourceStateData.JaegerUIURL,
|
||||
OtlpTracesURL: sourceStateData.OtlpTracesURL,
|
||||
ZipkinSpansURL: sourceStateData.ZipkinSpansURL,
|
||||
ACL: sourceStateData.ACL,
|
||||
AlertConfig: sourceStateData.AlertConfig,
|
||||
}
|
||||
|
||||
resp.Diagnostics.Append(resp.TargetState.Set(ctx, targetStateData)...)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
resp.Schema = schema.Schema{
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import (
|
|||
"github.com/stackitcloud/stackit-sdk-go/services/observability/wait"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
|
||||
argusScrapeConfigResource "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/argus/scrapeconfig"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
|
||||
)
|
||||
|
||||
|
|
@ -48,6 +49,7 @@ var (
|
|||
_ resource.Resource = &scrapeConfigResource{}
|
||||
_ resource.ResourceWithConfigure = &scrapeConfigResource{}
|
||||
_ resource.ResourceWithImportState = &scrapeConfigResource{}
|
||||
_ resource.ResourceWithMoveState = &scrapeConfigResource{}
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
|
|
@ -149,6 +151,47 @@ func (r *scrapeConfigResource) Configure(ctx context.Context, req resource.Confi
|
|||
tflog.Info(ctx, "Observability scrape config client configured")
|
||||
}
|
||||
|
||||
func (r *scrapeConfigResource) MoveState(_ context.Context) []resource.StateMover {
|
||||
return []resource.StateMover{
|
||||
{
|
||||
SourceSchema: &argusScrapeConfigResource.Schema,
|
||||
StateMover: func(ctx context.Context, req resource.MoveStateRequest, resp *resource.MoveStateResponse) {
|
||||
if req.SourceTypeName != "stackit_argus_scrapeconfig" {
|
||||
return
|
||||
}
|
||||
|
||||
// Checks source provider
|
||||
if !strings.HasSuffix(req.SourceProviderAddress, "stackitcloud/stackit") {
|
||||
return
|
||||
}
|
||||
|
||||
var sourceStateData argusScrapeConfigResource.Model
|
||||
resp.Diagnostics.Append(req.SourceState.Get(ctx, &sourceStateData)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
targetStateData := Model{
|
||||
Id: sourceStateData.Id,
|
||||
ProjectId: sourceStateData.ProjectId,
|
||||
InstanceId: sourceStateData.InstanceId,
|
||||
Name: sourceStateData.Name,
|
||||
MetricsPath: sourceStateData.MetricsPath,
|
||||
Scheme: sourceStateData.Scheme,
|
||||
ScrapeInterval: sourceStateData.ScrapeInterval,
|
||||
ScrapeTimeout: sourceStateData.ScrapeTimeout,
|
||||
SampleLimit: sourceStateData.SampleLimit,
|
||||
SAML2: sourceStateData.SAML2,
|
||||
BasicAuth: sourceStateData.BasicAuth,
|
||||
Targets: sourceStateData.Targets,
|
||||
}
|
||||
|
||||
resp.Diagnostics.Append(resp.TargetState.Set(ctx, targetStateData)...)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
func (r *scrapeConfigResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
resp.Schema = schema.Schema{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue