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

fix(instance): fix SG on external rules plan #446

Merged
merged 2 commits into from
Apr 6, 2020
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
6 changes: 3 additions & 3 deletions scaleway/resource_instance_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func resourceScalewayInstanceSecurityGroupCreate(d *schema.ResourceData, m inter

d.SetId(newZonedId(zone, res.SecurityGroup.ID))

if d.Get("external_rules") != nil && d.Get("external_rules").(bool) {
if d.Get("external_rules").(bool) {
return resourceScalewayInstanceSecurityGroupRead(d, m)
} else {
// We call update instead of read as it will take care of creating rules.
Expand Down Expand Up @@ -138,7 +138,7 @@ func resourceScalewayInstanceSecurityGroupRead(d *schema.ResourceData, m interfa
_ = d.Set("inbound_default_policy", res.SecurityGroup.InboundDefaultPolicy.String())
_ = d.Set("outbound_default_policy", res.SecurityGroup.OutboundDefaultPolicy.String())

if d.Get("external_rules").(bool) {
if !d.Get("external_rules").(bool) {
inboundRules, outboundRules, err := getSecurityGroupRules(instanceApi, zone, ID, d)
if err != nil {
return err
Expand Down Expand Up @@ -235,7 +235,7 @@ func resourceScalewayInstanceSecurityGroupUpdate(d *schema.ResourceData, m inter
return err
}

if d.Get("external_rules") == nil || (d.Get("external_rules") != nil && !d.Get("external_rules").(bool)) {
if !d.Get("external_rules").(bool) {
err = updateSecurityGroupeRules(d, zone, ID, instanceApi)
if err != nil {
return err
Expand Down