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:
João Palet 2025-01-20 08:54:30 +00:00 committed by GitHub
parent fc805d8e1d
commit 1a66887c01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 438 additions and 15 deletions

View 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"

View file

@ -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.