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

B: leaking vpc related resources issue fix #39748

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions internal/service/ec2/vpc_network_acl_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ func resourceNetworkACLRuleCreate(ctx context.Context, d *schema.ResourceData, m
log.Printf("[DEBUG] Creating EC2 Network ACL Rule: %#v", input)
_, err = conn.CreateNetworkAclEntry(ctx, input)

d.SetId(networkACLRuleCreateResourceID(naclID, ruleNumber, egress, protocol))

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating EC2 Network ACL (%s) Rule (egress: %t)(%d): %s", naclID, egress, ruleNumber, err)
}

d.SetId(networkACLRuleCreateResourceID(naclID, ruleNumber, egress, protocol))

return append(diags, resourceNetworkACLRuleRead(ctx, d, meta)...)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/service/ec2/vpc_security_group_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ func resourceSecurityGroupRuleCreate(ctx context.Context, d *schema.ResourceData
ruleType := securityGroupRuleType(d.Get(names.AttrType).(string))
id := securityGroupRuleCreateID(securityGroupID, string(ruleType), &ipPermission)

d.SetId(id)

switch ruleType {
case securityGroupRuleTypeIngress:
input := &ec2.AuthorizeSecurityGroupIngressInput{
Expand Down Expand Up @@ -250,8 +252,6 @@ information and instructions for recovery. Error: %s`, securityGroupID, err)
return sdkdiag.AppendErrorf(diags, "waiting for Security Group (%s) Rule (%s) create: %s", securityGroupID, id, err)
}

d.SetId(id)

return diags
}

Expand Down
4 changes: 2 additions & 2 deletions internal/service/ec2/vpc_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ func resourceSubnetCreate(ctx context.Context, d *schema.ResourceData, meta inte

output, err := conn.CreateSubnet(ctx, input)

d.SetId(aws.ToString(output.Subnet.SubnetId))

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating EC2 Subnet: %s", err)
}

d.SetId(aws.ToString(output.Subnet.SubnetId))

subnet, err := waitSubnetAvailable(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate))

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/service/ec2/vpc_subnet_cidr_reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ func resourceSubnetCIDRReservationCreate(ctx context.Context, d *schema.Resource
log.Printf("[DEBUG] Creating EC2 Subnet CIDR Reservation: %s", aws.ToString(input.SubnetId))
output, err := conn.CreateSubnetCidrReservation(ctx, input)

d.SetId(aws.ToString(output.SubnetCidrReservation.SubnetCidrReservationId))

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating EC2 Subnet CIDR Reservation: %s", err)
}

d.SetId(aws.ToString(output.SubnetCidrReservation.SubnetCidrReservationId))

return append(diags, resourceSubnetCIDRReservationRead(ctx, d, meta)...)
}

Expand Down