From c45a9916d17db667d3b9c8cb84f1473b25b6bf64 Mon Sep 17 00:00:00 2001 From: Alex Gray Date: Fri, 10 Feb 2017 07:29:47 -0500 Subject: [PATCH 1/2] ISSUE-10272 Lets not look at the requestor id. --- builtin/providers/aws/resource_aws_security_group.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/builtin/providers/aws/resource_aws_security_group.go b/builtin/providers/aws/resource_aws_security_group.go index 4c34fea967b1..d8cb3f2d1375 100644 --- a/builtin/providers/aws/resource_aws_security_group.go +++ b/builtin/providers/aws/resource_aws_security_group.go @@ -1011,10 +1011,6 @@ func deleteLingeringLambdaENIs(conn *ec2.EC2, d *schema.ResourceData) error { Name: aws.String("description"), Values: []*string{aws.String("AWS Lambda VPC ENI: *")}, }, - &ec2.Filter{ - Name: aws.String("requester-id"), - Values: []*string{aws.String("*:awslambda_*")}, - }, }, } networkInterfaceResp, err := conn.DescribeNetworkInterfaces(params) From 9a04205881a2f7d0c26d16501fef05e7baaf49af Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Tue, 6 Jun 2017 08:36:06 +0100 Subject: [PATCH 2/2] provider/aws: Add test for VPC-enabled lambda w/ invocation --- .../aws/resource_aws_lambda_function_test.go | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/builtin/providers/aws/resource_aws_lambda_function_test.go b/builtin/providers/aws/resource_aws_lambda_function_test.go index ce00164c48f7..aac56e21637f 100644 --- a/builtin/providers/aws/resource_aws_lambda_function_test.go +++ b/builtin/providers/aws/resource_aws_lambda_function_test.go @@ -260,6 +260,30 @@ func TestAccAWSLambdaFunction_VPC(t *testing.T) { }) } +// See https://github.com/hashicorp/terraform/issues/5767 +// and https://github.com/hashicorp/terraform/issues/10272 +func TestAccAWSLambdaFunction_VPC_withInvocation(t *testing.T) { + var conf lambda.GetFunctionOutput + + rSt := acctest.RandString(5) + rName := fmt.Sprintf("tf_test_%s", rSt) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckLambdaFunctionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSLambdaConfigWithVPC(rName, rSt), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsLambdaFunctionExists("aws_lambda_function.lambda_function_test", rName, &conf), + testAccAwsInvokeLambdaFunction(&conf), + ), + }, + }, + }) +} + func TestAccAWSLambdaFunction_s3(t *testing.T) { var conf lambda.GetFunctionOutput rSt := acctest.RandString(5) @@ -630,6 +654,20 @@ func testAccCheckAwsLambdaFunctionExists(res, funcName string, function *lambda. } } +func testAccAwsInvokeLambdaFunction(function *lambda.GetFunctionOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + f := function.Configuration + conn := testAccProvider.Meta().(*AWSClient).lambdaconn + + // If the function is VPC-enabled this will create ENI automatically + _, err := conn.Invoke(&lambda.InvokeInput{ + FunctionName: f.FunctionName, + }) + + return err + } +} + func testAccCheckAwsLambdaFunctionName(function *lambda.GetFunctionOutput, expectedName string) resource.TestCheckFunc { return func(s *terraform.State) error { c := function.Configuration