Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sql db instance recreate when going private -> public #3882

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ func resourceSqlDatabaseInstance() *schema.Resource {
},

CustomizeDiff: customdiff.All(
customdiff.ForceNewIfChange("settings.0.disk_size", isDiskShrinkage)),
customdiff.ForceNewIfChange("settings.0.disk_size", isDiskShrinkage),
privateNetworkCustomizeDiff),

Schema: map[string]*schema.Schema{
"region": {
Expand Down Expand Up @@ -615,6 +616,18 @@ func isFirstGen(d *schema.ResourceData) bool {
return !regexp.MustCompile("db*").Match([]byte(tier))
}

// Makes private_network ForceNew if it is changing from set to nil. The API returns an error
// if this change is attempted in-place.
func privateNetworkCustomizeDiff(d *schema.ResourceDiff, meta interface{}) error {
old, new := d.GetChange("settings.0.ip_configuration.0.private_network")

if old != "" && new == "" {
Copy link
Member

@rileykarson rileykarson Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd normally need to check if the new value was known or unknown before knowing if this comparison was safe, but it's unlikely that it would be unknown given that this is a block (and the field itself isn't one we expect to be interpolated).

d.ForceNew("settings.0.ip_configuration.0.private_network")
}

return nil
}

func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

Expand Down