Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
38 changes: 38 additions & 0 deletions builtin/providers/aws/resource_aws_lambda_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions builtin/providers/aws/resource_aws_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -1117,10 +1117,6 @@ func deleteLingeringLambdaENIs(conn *ec2.EC2, d *schema.ResourceData) error {
Name: aws.String("description"),
Values: []*string{aws.String("AWS Lambda VPC ENI: *")},
},
{
Name: aws.String("requester-id"),
Values: []*string{aws.String("*:awslambda_*")},
},
},
}
networkInterfaceResp, err := conn.DescribeNetworkInterfaces(params)
Expand Down