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 May 30, 2023
1 parent 1420f5e commit 16ee0d1
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 @@ -494,7 +494,14 @@ func resourceDirectoryRead(d *schema.ResourceData, meta interface{}) error {
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)
}
}

tags, err := ListTags(conn, d.Id())
Expand Down

0 comments on commit 16ee0d1

Please sign in to comment.