Skip to content

fix: Issue #2305 - Fix diff recognition for removal of network security group IDs in oci_apigateway_gateway #2307

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 8 additions & 10 deletions internal/service/apigateway/apigateway_gateway_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,17 @@ func (s *ApigatewayGatewayResourceCrud) Create() error {
request.FreeformTags = tfresource.ObjectMapToStringMap(freeformTags.(map[string]interface{}))
}

if networkSecurityGroupIds, ok := s.D.GetOkExists("network_security_group_ids"); ok {
set := networkSecurityGroupIds.(*schema.Set)
// Always set network security group IDs if provided, even if empty.
if v, ok := s.D.GetOk("network_security_group_ids"); ok {
set := v.(*schema.Set)
interfaces := set.List()
tmp := make([]string, len(interfaces))
for i := range interfaces {
if interfaces[i] != nil {
tmp[i] = interfaces[i].(string)
}
}
if len(tmp) != 0 || s.D.HasChange("network_security_group_ids") {
request.NetworkSecurityGroupIds = tmp
}
request.NetworkSecurityGroupIds = tmp
}

if responseCacheDetails, ok := s.D.GetOkExists("response_cache_details"); ok {
Expand Down Expand Up @@ -611,18 +610,17 @@ func (s *ApigatewayGatewayResourceCrud) Update() error {
tmp := s.D.Id()
request.GatewayId = &tmp

if networkSecurityGroupIds, ok := s.D.GetOkExists("network_security_group_ids"); ok {
set := networkSecurityGroupIds.(*schema.Set)
// Always update the network security group IDs if there is a change—even when removing all NSGs.
if s.D.HasChange("network_security_group_ids") {
set := s.D.Get("network_security_group_ids").(*schema.Set)
interfaces := set.List()
tmp := make([]string, len(interfaces))
for i := range interfaces {
if interfaces[i] != nil {
tmp[i] = interfaces[i].(string)
}
}
if len(tmp) != 0 || s.D.HasChange("network_security_group_ids") {
request.NetworkSecurityGroupIds = tmp
}
request.NetworkSecurityGroupIds = tmp
}

if responseCacheDetails, ok := s.D.GetOkExists("response_cache_details"); ok {
Expand Down