opslevel_filters can have an optional list of predicate { ... } blocks. The logic handling the list of blocks did not take into account importing an opslevel_filter into state. These updates fix that.
[X] List your changes here
[X] Make a changie entry
Tophatting
With this Terraform config
resource "opslevel_filter" "test" {
name = "Filter with three predicates"
predicate {
key = "language"
type = "equals"
value = "JavaScript"
case_sensitive = true
}
predicate {
key = "language"
type = "equals"
value = "Node.js"
case_insensitive = true
}
predicate {
key = "product"
type = "exists"
}
}
Create opslevel_filter with 3 predicate blocks, terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# opslevel_filter.test will be created
+ resource "opslevel_filter" "test" {
+ id = (known after apply)
+ name = "Filter with three predicates"
+ predicate {
+ case_insensitive = (known after apply)
+ case_sensitive = true
+ key = "language"
+ type = "equals"
+ value = "JavaScript"
}
+ predicate {
+ case_insensitive = true
+ case_sensitive = (known after apply)
+ key = "language"
+ type = "equals"
+ value = "Node.js"
}
+ predicate {
+ case_insensitive = (known after apply)
+ case_sensitive = (known after apply)
+ key = "product"
+ type = "exists"
}
}
Plan: 1 to add, 0 to change, 0 to destroy.
opslevel_filter.test: Creating...
opslevel_filter.test: Creation complete after 0s [id=Z2lkOi8vb3BzbGV2ZWwvRmlsdGVyLzQ5ODY]
╷
│ Warning: Attribute Deprecated
│
│ with opslevel_filter.test,
│ on main.tf line 14, in resource "opslevel_filter" "test":
│ 14: case_insensitive = true
│
│ The 'case_insensitive' field is deprecated. Please use 'case_sensitive' only.
│
│ (and 2 more similar warnings elsewhere)
╵
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
opslevel_filter.test: Importing from ID "Z2lkOi8vb3BzbGV2ZWwvRmlsdGVyLzQ5ODY"...
opslevel_filter.test: Import prepared!
Prepared opslevel_filter for import
opslevel_filter.test: Refreshing state... [id=Z2lkOi8vb3BzbGV2ZWwvRmlsdGVyLzQ5ODY]
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
Print Terraform state terraform show
# opslevel_filter.test:
resource "opslevel_filter" "test" {
id = "Z2lkOi8vb3BzbGV2ZWwvRmlsdGVyLzQ5ODY"
name = "Filter with three predicates"
predicate {
case_sensitive = true
key = "language"
type = "equals"
value = "JavaScript"
}
predicate {
case_sensitive = false
key = "language"
type = "equals"
value = "Node.js"
}
predicate {
key = "product"
type = "exists"
}
}
Update Terraform config, drop one predicate + update name
resource "opslevel_filter" "test" {
name = "Filter with two predicates"
predicate {
key = "language"
type = "equals"
value = "JavaScript"
case_sensitive = false
}
predicate {
key = "language"
type = "equals"
value = "Node.js"
case_insensitive = false
}
# predicate {
# key = "product"
# type = "exists"
# }
}
Update opslevel_filter, terraform apply
opslevel_filter.test: Refreshing state... [id=Z2lkOi8vb3BzbGV2ZWwvRmlsdGVyLzQ5ODY]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# opslevel_filter.test will be updated in-place
~ resource "opslevel_filter" "test" {
id = "Z2lkOi8vb3BzbGV2ZWwvRmlsdGVyLzQ5ODY"
~ name = "Filter with three predicates" -> "Filter with two predicates"
~ predicate {
+ case_insensitive = (known after apply)
~ case_sensitive = true -> false
# (3 unchanged attributes hidden)
}
~ predicate {
+ case_insensitive = false
~ case_sensitive = false -> (known after apply)
# (3 unchanged attributes hidden)
}
- predicate {
- key = "product" -> null
- type = "exists" -> null
}
}
Plan: 0 to add, 1 to change, 0 to destroy.
opslevel_filter.test: Modifying... [id=Z2lkOi8vb3BzbGV2ZWwvRmlsdGVyLzQ5ODY]
opslevel_filter.test: Modifications complete after 1s [id=Z2lkOi8vb3BzbGV2ZWwvRmlsdGVyLzQ5ODY]
╷
│ Warning: Attribute Deprecated
│
│ with opslevel_filter.test,
│ on main.tf line 14, in resource "opslevel_filter" "test":
│ 14: case_insensitive = false
│
│ The 'case_insensitive' field is deprecated. Please use 'case_sensitive' only.
│
│ (and 2 more similar warnings elsewhere)
╵
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
Issues
Changelog
opslevel_filter
s can have an optional list ofpredicate { ... }
blocks. The logic handling the list of blocks did not take into account importing anopslevel_filter
into state. These updates fix that.changie
entryTophatting
With this Terraform config
Create
opslevel_filter
with 3 predicate blocks,terraform apply
Delete Terraform state ✅
Import
opslevel_filter
into Terraform statePrint Terraform state
terraform show
Update Terraform config, drop one predicate + update
name
Update
opslevel_filter
,terraform apply
Destroy
opslevel_filter
,terraform destroy
✅