|
|
|
|
@ -292,6 +292,8 @@ func TestAccAWSLambdaFunction_localUpdate(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
defer os.Remove(path)
|
|
|
|
|
|
|
|
|
|
rInt := acctest.RandInt()
|
|
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
|
Providers: testAccProviders,
|
|
|
|
|
@ -301,7 +303,7 @@ func TestAccAWSLambdaFunction_localUpdate(t *testing.T) {
|
|
|
|
|
PreConfig: func() {
|
|
|
|
|
testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func.js": "lambda.js"}, zipFile)
|
|
|
|
|
},
|
|
|
|
|
Config: genAWSLambdaFunctionConfig_local(path),
|
|
|
|
|
Config: genAWSLambdaFunctionConfig_local(path, rInt),
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
testAccCheckAwsLambdaFunctionExists("aws_lambda_function.lambda_function_local", "tf_acc_lambda_name_local", &conf),
|
|
|
|
|
testAccCheckAwsLambdaFunctionName(&conf, "tf_acc_lambda_name_local"),
|
|
|
|
|
@ -313,7 +315,7 @@ func TestAccAWSLambdaFunction_localUpdate(t *testing.T) {
|
|
|
|
|
PreConfig: func() {
|
|
|
|
|
testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func_modified.js": "lambda.js"}, zipFile)
|
|
|
|
|
},
|
|
|
|
|
Config: genAWSLambdaFunctionConfig_local(path),
|
|
|
|
|
Config: genAWSLambdaFunctionConfig_local(path, rInt),
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
testAccCheckAwsLambdaFunctionExists("aws_lambda_function.lambda_function_local", "tf_acc_lambda_name_local", &conf),
|
|
|
|
|
testAccCheckAwsLambdaFunctionName(&conf, "tf_acc_lambda_name_local"),
|
|
|
|
|
@ -387,6 +389,8 @@ func TestAccAWSLambdaFunction_s3Update(t *testing.T) {
|
|
|
|
|
bucketName := fmt.Sprintf("tf-acc-lambda-s3-deployments-%d", randomInteger)
|
|
|
|
|
key := "lambda-func.zip"
|
|
|
|
|
|
|
|
|
|
rInt := acctest.RandInt()
|
|
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
|
Providers: testAccProviders,
|
|
|
|
|
@ -397,7 +401,7 @@ func TestAccAWSLambdaFunction_s3Update(t *testing.T) {
|
|
|
|
|
// Upload 1st version
|
|
|
|
|
testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func.js": "lambda.js"}, zipFile)
|
|
|
|
|
},
|
|
|
|
|
Config: genAWSLambdaFunctionConfig_s3(bucketName, key, path),
|
|
|
|
|
Config: genAWSLambdaFunctionConfig_s3(bucketName, key, path, rInt),
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
testAccCheckAwsLambdaFunctionExists("aws_lambda_function.lambda_function_s3", "tf_acc_lambda_name_s3", &conf),
|
|
|
|
|
testAccCheckAwsLambdaFunctionName(&conf, "tf_acc_lambda_name_s3"),
|
|
|
|
|
@ -411,12 +415,12 @@ func TestAccAWSLambdaFunction_s3Update(t *testing.T) {
|
|
|
|
|
// Upload 2nd version
|
|
|
|
|
testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func_modified.js": "lambda.js"}, zipFile)
|
|
|
|
|
},
|
|
|
|
|
Config: genAWSLambdaFunctionConfig_s3(bucketName, key, path),
|
|
|
|
|
Config: genAWSLambdaFunctionConfig_s3(bucketName, key, path, rInt),
|
|
|
|
|
},
|
|
|
|
|
// Extra step because of missing ComputedWhen
|
|
|
|
|
// See https://github.com/hashicorp/terraform/pull/4846 & https://github.com/hashicorp/terraform/pull/5330
|
|
|
|
|
{
|
|
|
|
|
Config: genAWSLambdaFunctionConfig_s3(bucketName, key, path),
|
|
|
|
|
Config: genAWSLambdaFunctionConfig_s3(bucketName, key, path, rInt),
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
testAccCheckAwsLambdaFunctionExists("aws_lambda_function.lambda_function_s3", "tf_acc_lambda_name_s3", &conf),
|
|
|
|
|
testAccCheckAwsLambdaFunctionName(&conf, "tf_acc_lambda_name_s3"),
|
|
|
|
|
@ -1101,7 +1105,7 @@ resource "aws_lambda_function" "lambda_function_test" {
|
|
|
|
|
|
|
|
|
|
const testAccAWSLambdaFunctionConfig_local_tpl = `
|
|
|
|
|
resource "aws_iam_role" "iam_for_lambda" {
|
|
|
|
|
name = "iam_for_lambda"
|
|
|
|
|
name = "iam_for_lambda_%d"
|
|
|
|
|
assume_role_policy = <<EOF
|
|
|
|
|
{
|
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
|
@ -1128,8 +1132,8 @@ resource "aws_lambda_function" "lambda_function_local" {
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func genAWSLambdaFunctionConfig_local(filePath string) string {
|
|
|
|
|
return fmt.Sprintf(testAccAWSLambdaFunctionConfig_local_tpl,
|
|
|
|
|
func genAWSLambdaFunctionConfig_local(filePath string, rInt int) string {
|
|
|
|
|
return fmt.Sprintf(testAccAWSLambdaFunctionConfig_local_tpl, rInt,
|
|
|
|
|
filePath, filePath)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1182,7 +1186,7 @@ resource "aws_s3_bucket_object" "o" {
|
|
|
|
|
etag = "${md5(file("%s"))}"
|
|
|
|
|
}
|
|
|
|
|
resource "aws_iam_role" "iam_for_lambda" {
|
|
|
|
|
name = "iam_for_lambda"
|
|
|
|
|
name = "iam_for_lambda_%d"
|
|
|
|
|
assume_role_policy = <<EOF
|
|
|
|
|
{
|
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
|
@ -1210,9 +1214,9 @@ resource "aws_lambda_function" "lambda_function_s3" {
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func genAWSLambdaFunctionConfig_s3(bucket, key, path string) string {
|
|
|
|
|
func genAWSLambdaFunctionConfig_s3(bucket, key, path string, rInt int) string {
|
|
|
|
|
return fmt.Sprintf(testAccAWSLambdaFunctionConfig_s3_tpl,
|
|
|
|
|
bucket, key, path, path)
|
|
|
|
|
bucket, key, path, path, rInt)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testAccAWSLambdaFunctionConfig_s3_unversioned_tpl(rName, bucketName, key, path string) string {
|
|
|
|
|
|