diff --git a/test/unit-test/main.tf b/test/unit-test/main.tf index c802cfe..2bdfc8e 100644 --- a/test/unit-test/main.tf +++ b/test/unit-test/main.tf @@ -152,8 +152,7 @@ data "aws_iam_policy_document" "instance-scheduler-lambda-function-policy" { resource "aws_lambda_invocation" "test_invocation" { function_name = module.module_test.lambda_function_name - input = jsonencode( - { + input = jsonencode({ action = "Test" }) } @@ -162,16 +161,16 @@ resource "aws_lambda_invocation" "test_invocation" { module "lambda_function_in_vpc" { source = "../../" application_name = local.application_name + tags = local.tags description = "lambda function provisioned within a vpc test" + lambda_role = aws_iam_role.lambda-vpc-role.arn + function_name = format("lambda-function-in-vpc-test-%s", random_id.lambda_name.dec) + create_role = false package_type = "Zip" filename = data.archive_file.lambda-zip.output_path source_code_hash = data.archive_file.lambda-zip.output_base64sha256 handler = "test.lambda_handler" runtime = "python3.8" - tags = local.tags - function_name = format("lambda-function-in-vpc-test-%s", random_id.lambda_name.dec) - create_role = false - lambda_role = aws_iam_role.lambda-vpc-role.arn vpc_subnet_ids = [data.aws_subnet.private-2a.id] vpc_security_group_ids = [aws_security_group.lambda_security_group_test.id] @@ -213,15 +212,14 @@ resource "aws_security_group" "lambda_security_group_test" { name = format("lambda-vpc-module-test-%s", random_id.sg_name.dec) description = "lambda attached to vpc test security group" vpc_id = data.aws_vpc.platforms-test.id - + tags = local.tags + egress { description = "Allow all outbound traffic" from_port = 0 to_port = 0 protocol = "-1" } - - tags = local.tags } data "archive_file" "lambda-zip" { @@ -233,8 +231,7 @@ data "archive_file" "lambda-zip" { resource "aws_lambda_invocation" "test_vpc_invocation" { function_name = module.lambda_function_in_vpc.lambda_function_name - input = jsonencode( - { + input = jsonencode({ action = "Test" }) } diff --git a/test/unit-test/outputs.tf b/test/unit-test/outputs.tf index 0aeff2d..d213914 100644 --- a/test/unit-test/outputs.tf +++ b/test/unit-test/outputs.tf @@ -24,4 +24,4 @@ output "function_vpc_name" { output "vpc_result_code" { value = aws_lambda_invocation.test_vpc_invocation.result -} \ No newline at end of file +}