Skip to content

Commit

Permalink
fix: prevent panic on nil VpcSettings in ds/directory.go (CLOUD-1547) (
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj-luminal authored and Evan Nemerson committed Apr 29, 2024
1 parent 9efea4e commit 0ae2587
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/service/ds/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,14 @@ func resourceDirectoryRead(ctx context.Context, d *schema.ResourceData, meta int
if aws.StringValue(dir.Type) == directoryservice.DirectoryTypeAdconnector {
d.Set("security_group_id", dir.ConnectSettings.SecurityGroupId)
} else {
d.Set("security_group_id", dir.VpcSettings.SecurityGroupId)
/* CLOUD-1547: we encountered environments where VpcSettings was nil.
* In this case, `ConnectSettings.SecurityGroupId` _was_ set, so in
* order to read the attribute we just try both but check for nil first. */
if dir.VpcSettings != nil {
d.Set("security_group_id", dir.VpcSettings.SecurityGroupId)
} else if dir.ConnectSettings != nil {
d.Set("security_group_id", dir.ConnectSettings.SecurityGroupId)
}
}
d.Set("short_name", dir.ShortName)
d.Set("size", dir.Size)
Expand Down

0 comments on commit 0ae2587

Please sign in to comment.