Skip to content

Commit

Permalink
Merge pull request #10492 from Ninir/lambda_env_removal
Browse files Browse the repository at this point in the history
provider/aws: Fixed Lambda environment removal
  • Loading branch information
catsby authored Dec 5, 2016
2 parents 7f59e2a + 615da28 commit f8f4634
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions builtin/providers/aws/resource_aws_lambda_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,11 @@ func resourceAwsLambdaFunctionUpdate(d *schema.ResourceData, meta interface{}) e
}
configUpdate = true
}
} else {
configReq.Environment = &lambda.Environment{
Variables: aws.StringMap(map[string]string{}),
}
configUpdate = true
}
}

Expand Down
21 changes: 21 additions & 0 deletions builtin/providers/aws/resource_aws_lambda_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ func TestAccAWSLambdaFunction_envVariables(t *testing.T) {
resource.TestCheckResourceAttr("aws_lambda_function.lambda_function_test", "environment.0.variables.foo1", "bar1"),
),
},
{
Config: testAccAWSLambdaConfigEnvVariablesModifiedWithoutEnvironment(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsLambdaFunctionExists("aws_lambda_function.lambda_function_test", rName, &conf),
testAccCheckAwsLambdaFunctionName(&conf, rName),
testAccCheckAwsLambdaFunctionArnHasSuffix(&conf, ":"+rName),
resource.TestCheckResourceAttr("aws_lambda_function.lambda_function_test", "environment.0.variables.foo", ""),
resource.TestCheckResourceAttr("aws_lambda_function.lambda_function_test", "environment.0.variables.foo1", ""),
),
},
},
})
}
Expand Down Expand Up @@ -648,6 +658,17 @@ resource "aws_lambda_function" "lambda_function_test" {
`, rName)
}

func testAccAWSLambdaConfigEnvVariablesModifiedWithoutEnvironment(rName string) string {
return fmt.Sprintf(baseAccAWSLambdaConfig+`
resource "aws_lambda_function" "lambda_function_test" {
filename = "test-fixtures/lambdatest.zip"
function_name = "%s"
role = "${aws_iam_role.iam_for_lambda.arn}"
handler = "exports.example"
}
`, rName)
}

func testAccAWSLambdaConfigEncryptedEnvVariables(rName string) string {
return fmt.Sprintf(baseAccAWSLambdaConfig+`
resource "aws_kms_key" "foo" {
Expand Down

0 comments on commit f8f4634

Please sign in to comment.