diff --git a/aws/resource_aws_security_group.go b/aws/resource_aws_security_group.go index 95fc94628b8..4b3ab327ed6 100644 --- a/aws/resource_aws_security_group.go +++ b/aws/resource_aws_security_group.go @@ -446,7 +446,7 @@ func resourceAwsSecurityGroupDelete(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Security Group destroy: %v", d.Id()) - if err := deleteLingeringLambdaENIs(conn, d); err != nil { + if err := deleteLingeringLambdaENIs(conn, d, "group-id"); err != nil { return fmt.Errorf("Failed to delete Lambda ENIs: %s", err) } @@ -1398,12 +1398,12 @@ func sgProtocolIntegers() map[string]int { // The AWS Lambda service creates ENIs behind the scenes and keeps these around for a while // which would prevent SGs attached to such ENIs from being destroyed -func deleteLingeringLambdaENIs(conn *ec2.EC2, d *schema.ResourceData) error { +func deleteLingeringLambdaENIs(conn *ec2.EC2, d *schema.ResourceData, filterName string) error { // Here we carefully find the offenders params := &ec2.DescribeNetworkInterfacesInput{ Filters: []*ec2.Filter{ { - Name: aws.String("group-id"), + Name: aws.String(filterName), Values: []*string{aws.String(d.Id())}, }, { diff --git a/aws/resource_aws_subnet.go b/aws/resource_aws_subnet.go index b356d31b69b..5f36af5d99e 100644 --- a/aws/resource_aws_subnet.go +++ b/aws/resource_aws_subnet.go @@ -23,6 +23,11 @@ func resourceAwsSubnet() *schema.Resource { State: schema.ImportStatePassthrough, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(10 * time.Minute), + Delete: schema.DefaultTimeout(10 * time.Minute), + }, + SchemaVersion: 1, MigrateState: resourceAwsSubnetMigrateState, @@ -303,6 +308,11 @@ func resourceAwsSubnetDelete(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).ec2conn log.Printf("[INFO] Deleting subnet: %s", d.Id()) + + if err := deleteLingeringLambdaENIs(conn, d, "subnet-id"); err != nil { + return fmt.Errorf("Failed to delete Lambda ENIs: %s", err) + } + req := &ec2.DeleteSubnetInput{ SubnetId: aws.String(d.Id()), }