Skip to content

Commit

Permalink
Fix reading security group after create
Browse files Browse the repository at this point in the history
Fix for the bug described in hashicorp#21628
  • Loading branch information
fomichevmi committed Jan 5, 2022
1 parent c4cd6e7 commit 7ac9f80
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions internal/service/ec2/default_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,25 @@ func resourceDefaultSecurityGroupRead(d *schema.ResourceData, meta interface{})
func resourceDefaultSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*conns.AWSClient).EC2Conn

group, err := FindSecurityGroupByID(conn, d.Id())
var group *ec2.SecurityGroup
var err error
err = resource.Retry(15 * time.Second, func() *resource.RetryError {
group, err = FindSecurityGroupByID(conn, d.Id())
if err != nil {
switch err.(type) {
case *resource.NotFoundError:
return resource.RetryableError(err)
default:
return resource.NonRetryableError(err)
}
}
return nil
})
if tfresource.TimedOut(err) {
group, err = FindSecurityGroupByID(conn, d.Id())
}
if err != nil {
return fmt.Errorf("error updating Default Security Group (%s): %w", d.Id(), err)
return fmt.Errorf("error updating Security Group (%s): %w", d.Id(), err)
}

err = resourceSecurityGroupUpdateRules(d, "ingress", meta, group)
Expand Down

0 comments on commit 7ac9f80

Please sign in to comment.