-
Notifications
You must be signed in to change notification settings - Fork 16
Changing only memo of a service/role causes recreation of itself #230
Copy link
Copy link
Open
Description
Problem
If you change memo attribute of a service, it is destroyed and recreated.
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with
the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
# mackerel_service.foo must be replaced
-/+ resource "mackerel_service" "foo" {
~ id = "foo" -> (known after apply)
+ memo = "aa" # forces replacement
name = "foo"
}
Plan: 1 to add, 0 to change, 1 to destroy.
At this time, information associated with the service such as roles and monitor rule options will be lost. This specification is almost always inconvenient.
Role memo has the same problem.
-/+ destroy and then create replacement
Terraform will perform the following actions:
# mackerel_role.bar must be replaced
-/+ resource "mackerel_role" "bar" {
~ id = "foo:bar" -> (known after apply)
~ memo = "foo:bar is managed by Terraform" -> "foo:bar is managed by Terraform 2" # forces replacement
name = "bar"
# (1 unchanged attribute hidden)
}
Plan: 1 to add, 0 to change, 1 to destroy.
Solution
terraform-provider-mackerel/mackerel/resource_mackerel_service.go
Lines 21 to 37 in 780e445
| Schema: map[string]*schema.Schema{ | |
| "name": { | |
| Type: schema.TypeString, | |
| Required: true, | |
| ForceNew: true, | |
| ValidateFunc: validation.All( | |
| validation.StringLenBetween(2, 63), | |
| validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9-_]+$`), | |
| "must include only alphabets, numbers, hyphen and underscore, and it can not begin a hyphen or underscore"), | |
| ), | |
| }, | |
| "memo": { | |
| Type: schema.TypeString, | |
| Optional: true, | |
| ForceNew: true, | |
| }, | |
| }, |
It would seem that erasing ForceNew: true in memo would solve the problem.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels