Fix internet_protocol/routing_mode case mismatch causing perpetual replace on cloudstack_vpc_offering - #330
Merged
sureshanaparti merged 1 commit intoSep 2, 2026
Conversation
…place on cloudstack_vpc_offering CloudStack's API normalizes these ForceNew fields' casing on write (e.g. ipv4 -> IPv4, static -> Static), which produced a permanent diff and proposed a destroy/recreate on every subsequent plan. Add a case-insensitive DiffSuppressFunc to both fields. network_mode is unaffected: the API rejects incorrect casing outright instead of silently normalizing it, so no fix is needed there.
Contributor
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds case-insensitive diff suppression for CloudStack-normalized ForceNew fields to prevent perpetual plan diffs and unnecessary VPC offering replacements.
Changes:
- Add
DiffSuppressFuncusing case-insensitive comparison forinternet_protocol. - Add
DiffSuppressFuncusing case-insensitive comparison forrouting_mode. - Import
stringsto supportstrings.EqualFold.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| import ( | ||
| "fmt" | ||
| "log" | ||
| "strings" |
Comment on lines
+86
to
+88
| DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { | ||
| return strings.EqualFold(old, new) | ||
| }, |
Comment on lines
+103
to
+105
| DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { | ||
| return strings.EqualFold(old, new) | ||
| }, |
kiranchavala
approved these changes
Sep 1, 2026
kiranchavala
left a comment
Member
There was a problem hiding this comment.
LGTM, Tested manually
resource "cloudstack_vpc_offering" "example" {
name = "example-vpc-offering"
display_text = "Example VPC Offering"
enable = true
supported_services = ["Dhcp", "Dns", "SourceNat", "PortForwarding", "Lb", "UserData", "StaticNat", "NetworkACL"]
service_provider_list = {
Dhcp = "VpcVirtualRouter"
Dns = "VpcVirtualRouter"
SourceNat = "VpcVirtualRouter"
PortForwarding = "VpcVirtualRouter"
Lb = "VpcVirtualRouter"
UserData = "VpcVirtualRouter"
StaticNat = "VpcVirtualRouter"
NetworkACL = "VpcVirtualRouter"
}
}
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:
# cloudstack_vpc_offering.example will be created
+ resource "cloudstack_vpc_offering" "example" {
+ display_text = "Example VPC Offering"
+ enable = true
+ id = (known after apply)
+ internet_protocol = (known after apply)
+ is_default = (known after apply)
+ name = "example-vpc-offering"
+ network_mode = (known after apply)
+ routing_mode = (known after apply)
+ service_provider_list = {
+ "Dhcp" = "VpcVirtualRouter"
+ "Dns" = "VpcVirtualRouter"
+ "Lb" = "VpcVirtualRouter"
+ "NetworkACL" = "VpcVirtualRouter"
+ "PortForwarding" = "VpcVirtualRouter"
+ "SourceNat" = "VpcVirtualRouter"
+ "StaticNat" = "VpcVirtualRouter"
+ "UserData" = "VpcVirtualRouter"
}
+ supported_services = [
+ "Dhcp",
+ "Dns",
+ "Lb",
+ "NetworkACL",
+ "PortForwarding",
+ "SourceNat",
+ "StaticNat",
+ "UserData",
]
+ service_capability_list (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
cloudstack_vpc_offering.example: Creating...
cloudstack_vpc_offering.example: Creation complete after 0s [id=a133e483-e5df-4464-9eca-01a04df1d0ff]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
terraform destroy
cloudstack_vpc_offering.example: Refreshing state... [id=a133e483-e5df-4464-9eca-01a04df1d0ff]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated
with the following symbols:
- destroy
Terraform will perform the following actions:
# cloudstack_vpc_offering.example will be destroyed
- resource "cloudstack_vpc_offering" "example" {
- display_text = "Example VPC Offering" -> null
- enable = true -> null
- for_nsx = false -> null
- id = "a133e483-e5df-4464-9eca-01a04df1d0ff" -> null
- internet_protocol = "IPv4" -> null
- is_default = false -> null
- name = "example-vpc-offering" -> null
- service_provider_list = {
- "Dhcp" = "VpcVirtualRouter"
- "Dns" = "VpcVirtualRouter"
- "Lb" = "VpcVirtualRouter"
- "NetworkACL" = "VpcVirtualRouter"
- "PortForwarding" = "VpcVirtualRouter"
- "SourceNat" = "VpcVirtualRouter"
- "StaticNat" = "VpcVirtualRouter"
- "UserData" = "VpcVirtualRouter"
} -> null
- specify_as_number = false -> null
- supported_services = [
- "Dhcp",
- "Dns",
- "Lb",
- "NetworkACL",
- "PortForwarding",
- "SourceNat",
- "StaticNat",
- "UserData",
] -> null
}
Plan: 0 to add, 0 to change, 1 to destroy.
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
cloudstack_vpc_offering.example: Destroying... [id=a133e483-e5df-4464-9eca-01a04df1d0ff]
cloudstack_vpc_offering.example: Destruction complete after 1s
Destroy complete! Resources: 1 destroyed.
sureshanaparti
deleted the
fix/vpc-offering-case-insensitive-forcenew-fields
branch
September 2, 2026 04:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CloudStack's API normalizes these ForceNew fields' casing on write (e.g. ipv4 -> IPv4, static -> Static), which produced a permanent diff and proposed a destroy/recreate on every subsequent plan. Add a case-insensitive DiffSuppressFunc to both fields.
network_mode is unaffected: the API rejects incorrect casing outright instead of silently normalizing it, so no fix is needed there.