From 5d612b7ffcec4f905b9c2a3bb0864da4e22bde3b Mon Sep 17 00:00:00 2001 From: Marcio Goda Date: Thu, 23 May 2024 15:53:53 +0100 Subject: [PATCH 1/2] add architectures --- README.md | 2 ++ main.tf | 5 +---- variables.tf | 6 ++++++ versions.tf | 9 +++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 versions.tf diff --git a/README.md b/README.md index c70943f..48aef46 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ This module will deploy a Lambda function. It supports both Zip and Image deploy - `reserved_concurrent_executions` (number) - The amount of reserved concurrent executions for this lambda function. - `tags` (map) - A mapping of tags to assign to this lambda function. - `datadog_log_subscription_arn` - (string) - Log subscription arn for shipping logs to datadog. +- `architectures` - (list) - List of architectures to support for the Lambda function. ### Zip deployment variables - `runtime` - (string) - **REQUIRED** - The runtime environment for the Lambda function you are uploading. @@ -50,6 +51,7 @@ module "lambda" { timeout = 5 memory_size = 256 lambda_env = "${var.lambda_env}" + architectures = ["x86_64"] } ``` Lambda environment variables file: diff --git a/main.tf b/main.tf index 7f44b05..d6f0442 100644 --- a/main.tf +++ b/main.tf @@ -1,7 +1,3 @@ -terraform { - required_version = ">= 0.12" -} - resource "aws_lambda_function" "lambda_function" { image_uri = var.image_uri s3_bucket = var.s3_bucket @@ -16,6 +12,7 @@ resource "aws_lambda_function" "lambda_function" { tags = var.tags package_type = var.image_uri != null ? "Image" : "Zip" layers = var.layers + architectures = var.architectures dynamic "image_config" { for_each = var.image_uri != null ? [1] : [] diff --git a/variables.tf b/variables.tf index ba9422c..d2fe7b9 100644 --- a/variables.tf +++ b/variables.tf @@ -131,3 +131,9 @@ variable "layers" { description = "ARNs of the layers to attach to the lambda function in order" default = [] } + +variable "architectures" { + type = list(string) + description = "Lambda architectures to support." + default = ["x86_64"] +} \ No newline at end of file diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..62c6021 --- /dev/null +++ b/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 0.12" + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.61.0" + } + } +} \ No newline at end of file From e75756c76085268e83a75a4cce5a1010dda44419 Mon Sep 17 00:00:00 2001 From: Marcio Goda Date: Fri, 24 May 2024 10:50:01 +0100 Subject: [PATCH 2/2] fixed tests --- test/Dockerfile | 4 +- test/files/create_lambda.json | 293 +++++++-------- test/files/create_lambda_container.json | 292 +++++++-------- test/files/create_lambda_in_vpc.json | 354 ++++++++---------- test/files/create_lambda_with_layers.json | 293 +++++++-------- ...a_with_reserved_concurrent_executions.json | 293 +++++++-------- test/files/create_lambda_with_tags.json | 299 +++++++-------- test/infra/main.tf | 7 +- test/infra_container/main.tf | 7 +- test/run | 7 +- test/test_lambda.py | 4 +- versions.tf | 2 +- 12 files changed, 841 insertions(+), 1014 deletions(-) diff --git a/test/Dockerfile b/test/Dockerfile index ae550cb..855d6d8 100644 --- a/test/Dockerfile +++ b/test/Dockerfile @@ -1,9 +1,9 @@ FROM python:3-alpine COPY requirements.txt . -ENV TERRAFORM_VERSION=0.12.18 +ENV TERRAFORM_VERSION=0.13.7 ENV TERRAFORM_ZIP=terraform_${TERRAFORM_VERSION}_linux_amd64.zip -ENV TERRAFORM_SUM=e7ebe3ca988768bffe0c239d107645bd53515354cff6cbe5651718195a151700 +ENV TERRAFORM_SUM=4a52886e019b4fdad2439da5ff43388bbcc6cce9784fde32c53dcd0e28ca9957 RUN apk add -U ca-certificates curl && \ cd /tmp && \ diff --git a/test/files/create_lambda.json b/test/files/create_lambda.json index 05895f6..dca3fa7 100644 --- a/test/files/create_lambda.json +++ b/test/files/create_lambda.json @@ -1,160 +1,133 @@ -{ - "resource_changes": [ - { - "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_cloudwatch_log_group", - "name": "lambda_loggroup", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "kms_key_id": null, - "name": "/aws/lambda/check_lambda_function", - "name_prefix": null, - "retention_in_days": 7, - "tags": null - }, - "after_unknown": { - "arn": true, - "id": true - } - } - }, - { - "address": "module.lambda.aws_iam_role.iam_for_lambda", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role", - "name": "iam_for_lambda", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", - "description": null, - "force_detach_policies": false, - "max_session_duration": 3600, - "name_prefix": "check_lambda_function", - "path": "/", - "permissions_boundary": null, - "tags": null - }, - "after_unknown": { - "arn": true, - "create_date": true, - "id": true, - "inline_policy": true, - "managed_policy_arns": true, - "name": true, - "unique_id": true - } - } - }, - { - "address": "module.lambda.aws_iam_role_policy.lambda_policy", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role_policy", - "name": "lambda_policy", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "name": "policy", - "name_prefix": null, - "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" - }, - "after_unknown": { - "id": true, - "role": true - } - } - }, - { - "address": "module.lambda.aws_lambda_function.lambda_function", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_lambda_function", - "name": "lambda_function", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "code_signing_config_arn": null, - "dead_letter_config": [], - "description": null, - "environment": [ - { - "variables": null - } - ], - "file_system_config": [], - "filename": null, - "function_name": "check_lambda_function", - "handler": "some_handler", - "image_config": [], - "image_uri": null, - "kms_key_arn": null, - "layers": [], - "memory_size": 128, - "package_type": "Zip", - "publish": false, - "reserved_concurrent_executions": -1, - "runtime": "python3.7", - "s3_bucket": "cdflow-lambda-releases", - "s3_key": "s3key.zip", - "s3_object_version": null, - "tags": null, - "timeout": 3, - "timeouts": null, - "vpc_config": [ - { - "security_group_ids": null, - "subnet_ids": null - } - ] - }, - "after_unknown": { - "arn": true, - "dead_letter_config": [], - "environment": [ - {} - ], - "file_system_config": [], - "id": true, - "image_config": [], - "invoke_arn": true, - "last_modified": true, - "layers": [], - "qualified_arn": true, - "role": true, - "signing_job_arn": true, - "signing_profile_version_arn": true, - "source_code_hash": true, - "source_code_size": true, - "tracing_config": true, - "version": true, - "vpc_config": [ - { - "vpc_id": true - } - ] - } - } - } - ] -} \ No newline at end of file +[ + { + "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_cloudwatch_log_group", + "name": "lambda_loggroup", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "kms_key_id": null, + "name": "/aws/lambda/check_lambda_function", + "name_prefix": null, + "retention_in_days": 7, + "tags": null + }, + "after_unknown": { "arn": true, "id": true, "tags_all": true } + } + }, + { + "address": "module.lambda.aws_iam_role.iam_for_lambda", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role", + "name": "iam_for_lambda", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", + "description": null, + "force_detach_policies": false, + "max_session_duration": 3600, + "name_prefix": "check_lambda_function", + "path": "/", + "permissions_boundary": null, + "tags": null + }, + "after_unknown": { + "arn": true, + "create_date": true, + "id": true, + "inline_policy": true, + "managed_policy_arns": true, + "name": true, + "tags_all": true, + "unique_id": true + } + } + }, + { + "address": "module.lambda.aws_iam_role_policy.lambda_policy", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role_policy", + "name": "lambda_policy", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "name": "policy", + "name_prefix": null, + "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" + }, + "after_unknown": { "id": true, "role": true } + } + }, + { + "address": "module.lambda.aws_lambda_function.lambda_function", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_lambda_function", + "name": "lambda_function", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "architectures": ["x86_64"], + "code_signing_config_arn": null, + "dead_letter_config": [], + "description": null, + "environment": [{ "variables": null }], + "file_system_config": [], + "filename": null, + "function_name": "check_lambda_function", + "handler": "some_handler", + "image_config": [], + "image_uri": null, + "kms_key_arn": null, + "layers": [], + "memory_size": 128, + "package_type": "Zip", + "publish": false, + "reserved_concurrent_executions": -1, + "runtime": "python3.7", + "s3_bucket": "cdflow-lambda-releases", + "s3_key": "s3key.zip", + "s3_object_version": null, + "tags": null, + "timeout": 3, + "timeouts": null, + "vpc_config": [{ "security_group_ids": null, "subnet_ids": null }] + }, + "after_unknown": { + "architectures": [false], + "arn": true, + "dead_letter_config": [], + "environment": [{}], + "file_system_config": [], + "id": true, + "image_config": [], + "invoke_arn": true, + "last_modified": true, + "layers": [], + "qualified_arn": true, + "role": true, + "signing_job_arn": true, + "signing_profile_version_arn": true, + "source_code_hash": true, + "source_code_size": true, + "tags_all": true, + "tracing_config": true, + "version": true, + "vpc_config": [{ "vpc_id": true }] + } + } + } +] diff --git a/test/files/create_lambda_container.json b/test/files/create_lambda_container.json index efe100e..8de0643 100644 --- a/test/files/create_lambda_container.json +++ b/test/files/create_lambda_container.json @@ -1,153 +1,139 @@ -{ - "resource_changes": [{ - "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_cloudwatch_log_group", - "name": "lambda_loggroup", - "provider_name": "aws", - "change": { - "actions": ["create"], - "before": null, - "after": { - "kms_key_id": null, - "name": "/aws/lambda/check_lambda_function", - "name_prefix": null, - "retention_in_days": 7, - "tags": null - }, - "after_unknown": { - "arn": true, - "id": true - } - } - }, { - "address": "module.lambda.aws_iam_role.iam_for_lambda", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role", - "name": "iam_for_lambda", - "provider_name": "aws", - "change": { - "actions": ["create"], - "before": null, - "after": { - "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", - "description": null, - "force_detach_policies": false, - "max_session_duration": 3600, - "name_prefix": "check_lambda_function", - "path": "/", - "permissions_boundary": null, - "tags": null - }, - "after_unknown": { - "arn": true, - "create_date": true, - "id": true, - "inline_policy": true, - "managed_policy_arns": true, - "name": true, - "unique_id": true - } - } - }, { - "address": "module.lambda.aws_iam_role_policy.lambda_policy", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role_policy", - "name": "lambda_policy", - "provider_name": "aws", - "change": { - "actions": ["create"], - "before": null, - "after": { - "name": "policy", - "name_prefix": null, - "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" - }, - "after_unknown": { - "id": true, - "role": true - } - } - }, { - "address": "module.lambda.aws_lambda_function.lambda_function", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_lambda_function", - "name": "lambda_function", - "provider_name": "aws", - "change": { - "actions": ["create"], - "before": null, - "after": { - "code_signing_config_arn": null, - "dead_letter_config": [], - "description": null, - "environment": [{ - "variables": null - } - ], - "file_system_config": [], - "filename": null, - "function_name": "check_lambda_function", - "handler": null, - "image_config": [{ - "command": ["some_cmd"], - "entry_point": ["some_entrypoint"], - "working_directory": null - } - ], - "image_uri": "image", - "kms_key_arn": null, - "layers": [], - "memory_size": 128, - "package_type": "Image", - "publish": false, - "reserved_concurrent_executions": -1, - "runtime": null, - "s3_bucket": null, - "s3_key": null, - "s3_object_version": null, - "tags": null, - "timeout": 3, - "timeouts": null, - "vpc_config": [{ - "security_group_ids": null, - "subnet_ids": null - } - ] - }, - "after_unknown": { - "arn": true, - "dead_letter_config": [], - "environment": [{} - ], - "file_system_config": [], - "id": true, - "image_config": [{ - "command": [false], - "entry_point": [false] - } - ], - "invoke_arn": true, - "last_modified": true, - "layers": [], - "qualified_arn": true, - "role": true, - "signing_job_arn": true, - "signing_profile_version_arn": true, - "source_code_hash": true, - "source_code_size": true, - "tracing_config": true, - "version": true, - "vpc_config": [{ - "vpc_id": true - } - ] - } - } - } - ] -} +[ + { + "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_cloudwatch_log_group", + "name": "lambda_loggroup", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "kms_key_id": null, + "name": "/aws/lambda/check_lambda_function", + "name_prefix": null, + "retention_in_days": 7, + "tags": null + }, + "after_unknown": { "arn": true, "id": true, "tags_all": true } + } + }, + { + "address": "module.lambda.aws_iam_role.iam_for_lambda", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role", + "name": "iam_for_lambda", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", + "description": null, + "force_detach_policies": false, + "max_session_duration": 3600, + "name_prefix": "check_lambda_function", + "path": "/", + "permissions_boundary": null, + "tags": null + }, + "after_unknown": { + "arn": true, + "create_date": true, + "id": true, + "inline_policy": true, + "managed_policy_arns": true, + "name": true, + "tags_all": true, + "unique_id": true + } + } + }, + { + "address": "module.lambda.aws_iam_role_policy.lambda_policy", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role_policy", + "name": "lambda_policy", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "name": "policy", + "name_prefix": null, + "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" + }, + "after_unknown": { "id": true, "role": true } + } + }, + { + "address": "module.lambda.aws_lambda_function.lambda_function", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_lambda_function", + "name": "lambda_function", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "architectures": ["x86_64"], + "code_signing_config_arn": null, + "dead_letter_config": [], + "description": null, + "environment": [{ "variables": null }], + "file_system_config": [], + "filename": null, + "function_name": "check_lambda_function", + "handler": null, + "image_config": [ + { + "command": ["some_cmd"], + "entry_point": ["some_entrypoint"], + "working_directory": null + } + ], + "image_uri": "image", + "kms_key_arn": null, + "layers": [], + "memory_size": 128, + "package_type": "Image", + "publish": false, + "reserved_concurrent_executions": -1, + "runtime": null, + "s3_bucket": null, + "s3_key": null, + "s3_object_version": null, + "tags": null, + "timeout": 3, + "timeouts": null, + "vpc_config": [{ "security_group_ids": null, "subnet_ids": null }] + }, + "after_unknown": { + "architectures": [false], + "arn": true, + "dead_letter_config": [], + "environment": [{}], + "file_system_config": [], + "id": true, + "image_config": [{ "command": [false], "entry_point": [false] }], + "invoke_arn": true, + "last_modified": true, + "layers": [], + "qualified_arn": true, + "role": true, + "signing_job_arn": true, + "signing_profile_version_arn": true, + "source_code_hash": true, + "source_code_size": true, + "tags_all": true, + "tracing_config": true, + "version": true, + "vpc_config": [{ "vpc_id": true }] + } + } + } +] diff --git a/test/files/create_lambda_in_vpc.json b/test/files/create_lambda_in_vpc.json index 53c7e35..58b83ec 100644 --- a/test/files/create_lambda_in_vpc.json +++ b/test/files/create_lambda_in_vpc.json @@ -1,196 +1,158 @@ -{ - "resource_changes": [ - { - "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_cloudwatch_log_group", - "name": "lambda_loggroup", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "kms_key_id": null, - "name": "/aws/lambda/check_lambda_function", - "name_prefix": null, - "retention_in_days": 7, - "tags": null - }, - "after_unknown": { - "arn": true, - "id": true - } - } - }, - { - "address": "module.lambda.aws_iam_role.iam_for_lambda", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role", - "name": "iam_for_lambda", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", - "description": null, - "force_detach_policies": false, - "max_session_duration": 3600, - "name_prefix": "check_lambda_function", - "path": "/", - "permissions_boundary": null, - "tags": null - }, - "after_unknown": { - "arn": true, - "create_date": true, - "id": true, - "inline_policy": true, - "managed_policy_arns": true, - "name": true, - "unique_id": true - } - } - }, - { - "address": "module.lambda.aws_iam_role_policy.lambda_policy", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role_policy", - "name": "lambda_policy", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "name": "policy", - "name_prefix": null, - "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" - }, - "after_unknown": { - "id": true, - "role": true - } - } - }, - { - "address": "module.lambda.aws_iam_role_policy_attachment.vpc_permissions[0]", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role_policy_attachment", - "name": "vpc_permissions", - "index": 0, - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole" - }, - "after_unknown": { - "id": true, - "role": true - } - } - }, - { - "address": "module.lambda.aws_lambda_function.lambda_function", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_lambda_function", - "name": "lambda_function", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "code_signing_config_arn": null, - "dead_letter_config": [], - "description": null, - "environment": [ - { - "variables": null - } - ], - "file_system_config": [], - "filename": null, - "function_name": "check_lambda_function", - "handler": "some_handler", - "image_config": [], - "image_uri": null, - "kms_key_arn": null, - "layers": [], - "memory_size": 128, - "package_type": "Zip", - "publish": false, - "reserved_concurrent_executions": -1, - "runtime": "python3.7", - "s3_bucket": "cdflow-lambda-releases", - "s3_key": "s3key.zip", - "s3_object_version": null, - "tags": null, - "timeout": 3, - "timeouts": null, - "vpc_config": [ - { - "security_group_ids": [ - "4" - ], - "subnet_ids": [ - "1", - "2", - "3" - ] - } - ] - }, - "after_unknown": { - "arn": true, - "dead_letter_config": [], - "environment": [ - {} - ], - "file_system_config": [], - "id": true, - "image_config": [], - "invoke_arn": true, - "last_modified": true, - "layers": [], - "qualified_arn": true, - "role": true, - "signing_job_arn": true, - "signing_profile_version_arn": true, - "source_code_hash": true, - "source_code_size": true, - "tracing_config": true, - "version": true, - "vpc_config": [ - { - "security_group_ids": [ - false - ], - "subnet_ids": [ - false, - false, - false - ], - "vpc_id": true - } - ] - } - } - } - ] -} \ No newline at end of file +[ + { + "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_cloudwatch_log_group", + "name": "lambda_loggroup", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "kms_key_id": null, + "name": "/aws/lambda/check_lambda_function", + "name_prefix": null, + "retention_in_days": 7, + "tags": null + }, + "after_unknown": { "arn": true, "id": true, "tags_all": true } + } + }, + { + "address": "module.lambda.aws_iam_role.iam_for_lambda", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role", + "name": "iam_for_lambda", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", + "description": null, + "force_detach_policies": false, + "max_session_duration": 3600, + "name_prefix": "check_lambda_function", + "path": "/", + "permissions_boundary": null, + "tags": null + }, + "after_unknown": { + "arn": true, + "create_date": true, + "id": true, + "inline_policy": true, + "managed_policy_arns": true, + "name": true, + "tags_all": true, + "unique_id": true + } + } + }, + { + "address": "module.lambda.aws_iam_role_policy.lambda_policy", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role_policy", + "name": "lambda_policy", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "name": "policy", + "name_prefix": null, + "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" + }, + "after_unknown": { "id": true, "role": true } + } + }, + { + "address": "module.lambda.aws_iam_role_policy_attachment.vpc_permissions[0]", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role_policy_attachment", + "name": "vpc_permissions", + "index": 0, + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole" + }, + "after_unknown": { "id": true, "role": true } + } + }, + { + "address": "module.lambda.aws_lambda_function.lambda_function", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_lambda_function", + "name": "lambda_function", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "architectures": ["x86_64"], + "code_signing_config_arn": null, + "dead_letter_config": [], + "description": null, + "environment": [{ "variables": null }], + "file_system_config": [], + "filename": null, + "function_name": "check_lambda_function", + "handler": "some_handler", + "image_config": [], + "image_uri": null, + "kms_key_arn": null, + "layers": [], + "memory_size": 128, + "package_type": "Zip", + "publish": false, + "reserved_concurrent_executions": -1, + "runtime": "python3.7", + "s3_bucket": "cdflow-lambda-releases", + "s3_key": "s3key.zip", + "s3_object_version": null, + "tags": null, + "timeout": 3, + "timeouts": null, + "vpc_config": [ + { "security_group_ids": ["4"], "subnet_ids": ["1", "2", "3"] } + ] + }, + "after_unknown": { + "architectures": [false], + "arn": true, + "dead_letter_config": [], + "environment": [{}], + "file_system_config": [], + "id": true, + "image_config": [], + "invoke_arn": true, + "last_modified": true, + "layers": [], + "qualified_arn": true, + "role": true, + "signing_job_arn": true, + "signing_profile_version_arn": true, + "source_code_hash": true, + "source_code_size": true, + "tags_all": true, + "tracing_config": true, + "version": true, + "vpc_config": [ + { + "security_group_ids": [false], + "subnet_ids": [false, false, false], + "vpc_id": true + } + ] + } + } + } +] diff --git a/test/files/create_lambda_with_layers.json b/test/files/create_lambda_with_layers.json index 90ef231..6fba8ab 100644 --- a/test/files/create_lambda_with_layers.json +++ b/test/files/create_lambda_with_layers.json @@ -1,160 +1,133 @@ -{ - "resource_changes": [ - { - "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_cloudwatch_log_group", - "name": "lambda_loggroup", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "kms_key_id": null, - "name": "/aws/lambda/check_lambda_function", - "name_prefix": null, - "retention_in_days": 7, - "tags": null - }, - "after_unknown": { - "arn": true, - "id": true - } - } - }, - { - "address": "module.lambda.aws_iam_role.iam_for_lambda", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role", - "name": "iam_for_lambda", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", - "description": null, - "force_detach_policies": false, - "max_session_duration": 3600, - "name_prefix": "check_lambda_function", - "path": "/", - "permissions_boundary": null, - "tags": null - }, - "after_unknown": { - "arn": true, - "create_date": true, - "id": true, - "inline_policy": true, - "managed_policy_arns": true, - "name": true, - "unique_id": true - } - } - }, - { - "address": "module.lambda.aws_iam_role_policy.lambda_policy", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role_policy", - "name": "lambda_policy", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "name": "policy", - "name_prefix": null, - "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" - }, - "after_unknown": { - "id": true, - "role": true - } - } - }, - { - "address": "module.lambda.aws_lambda_function.lambda_function", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_lambda_function", - "name": "lambda_function", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "code_signing_config_arn": null, - "dead_letter_config": [], - "description": null, - "environment": [ - { - "variables": null - } - ], - "file_system_config": [], - "filename": null, - "function_name": "check_lambda_function", - "handler": "some_handler", - "image_config": [], - "image_uri": null, - "kms_key_arn": null, - "layers": [ "arn:aws:lambda:eu-west-1:aws:r1" ], - "memory_size": 128, - "package_type": "Zip", - "publish": false, - "reserved_concurrent_executions": -1, - "runtime": "python3.7", - "s3_bucket": "cdflow-lambda-releases", - "s3_key": "s3key.zip", - "s3_object_version": null, - "tags": null, - "timeout": 3, - "timeouts": null, - "vpc_config": [ - { - "security_group_ids": null, - "subnet_ids": null - } - ] - }, - "after_unknown": { - "arn": true, - "dead_letter_config": [], - "environment": [ - {} - ], - "file_system_config": [], - "id": true, - "image_config": [], - "invoke_arn": true, - "last_modified": true, - "layers": [ false ], - "qualified_arn": true, - "role": true, - "signing_job_arn": true, - "signing_profile_version_arn": true, - "source_code_hash": true, - "source_code_size": true, - "tracing_config": true, - "version": true, - "vpc_config": [ - { - "vpc_id": true - } - ] - } - } - } - ] -} \ No newline at end of file +[ + { + "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_cloudwatch_log_group", + "name": "lambda_loggroup", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "kms_key_id": null, + "name": "/aws/lambda/check_lambda_function", + "name_prefix": null, + "retention_in_days": 7, + "tags": null + }, + "after_unknown": { "arn": true, "id": true, "tags_all": true } + } + }, + { + "address": "module.lambda.aws_iam_role.iam_for_lambda", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role", + "name": "iam_for_lambda", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", + "description": null, + "force_detach_policies": false, + "max_session_duration": 3600, + "name_prefix": "check_lambda_function", + "path": "/", + "permissions_boundary": null, + "tags": null + }, + "after_unknown": { + "arn": true, + "create_date": true, + "id": true, + "inline_policy": true, + "managed_policy_arns": true, + "name": true, + "tags_all": true, + "unique_id": true + } + } + }, + { + "address": "module.lambda.aws_iam_role_policy.lambda_policy", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role_policy", + "name": "lambda_policy", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "name": "policy", + "name_prefix": null, + "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" + }, + "after_unknown": { "id": true, "role": true } + } + }, + { + "address": "module.lambda.aws_lambda_function.lambda_function", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_lambda_function", + "name": "lambda_function", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "architectures": ["x86_64"], + "code_signing_config_arn": null, + "dead_letter_config": [], + "description": null, + "environment": [{ "variables": null }], + "file_system_config": [], + "filename": null, + "function_name": "check_lambda_function", + "handler": "some_handler", + "image_config": [], + "image_uri": null, + "kms_key_arn": null, + "layers": ["arn:aws:lambda:eu-west-1:aws:r1"], + "memory_size": 128, + "package_type": "Zip", + "publish": false, + "reserved_concurrent_executions": -1, + "runtime": "python3.7", + "s3_bucket": "cdflow-lambda-releases", + "s3_key": "s3key.zip", + "s3_object_version": null, + "tags": null, + "timeout": 3, + "timeouts": null, + "vpc_config": [{ "security_group_ids": null, "subnet_ids": null }] + }, + "after_unknown": { + "architectures": [false], + "arn": true, + "dead_letter_config": [], + "environment": [{}], + "file_system_config": [], + "id": true, + "image_config": [], + "invoke_arn": true, + "last_modified": true, + "layers": [false], + "qualified_arn": true, + "role": true, + "signing_job_arn": true, + "signing_profile_version_arn": true, + "source_code_hash": true, + "source_code_size": true, + "tags_all": true, + "tracing_config": true, + "version": true, + "vpc_config": [{ "vpc_id": true }] + } + } + } +] diff --git a/test/files/create_lambda_with_reserved_concurrent_executions.json b/test/files/create_lambda_with_reserved_concurrent_executions.json index 3e21916..34f0065 100644 --- a/test/files/create_lambda_with_reserved_concurrent_executions.json +++ b/test/files/create_lambda_with_reserved_concurrent_executions.json @@ -1,160 +1,133 @@ -{ - "resource_changes": [ - { - "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_cloudwatch_log_group", - "name": "lambda_loggroup", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "kms_key_id": null, - "name": "/aws/lambda/check_lambda_function", - "name_prefix": null, - "retention_in_days": 7, - "tags": null - }, - "after_unknown": { - "arn": true, - "id": true - } - } - }, - { - "address": "module.lambda.aws_iam_role.iam_for_lambda", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role", - "name": "iam_for_lambda", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", - "description": null, - "force_detach_policies": false, - "max_session_duration": 3600, - "name_prefix": "check_lambda_function", - "path": "/", - "permissions_boundary": null, - "tags": null - }, - "after_unknown": { - "arn": true, - "create_date": true, - "id": true, - "inline_policy": true, - "managed_policy_arns": true, - "name": true, - "unique_id": true - } - } - }, - { - "address": "module.lambda.aws_iam_role_policy.lambda_policy", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role_policy", - "name": "lambda_policy", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "name": "policy", - "name_prefix": null, - "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" - }, - "after_unknown": { - "id": true, - "role": true - } - } - }, - { - "address": "module.lambda.aws_lambda_function.lambda_function", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_lambda_function", - "name": "lambda_function", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "code_signing_config_arn": null, - "dead_letter_config": [], - "description": null, - "environment": [ - { - "variables": null - } - ], - "file_system_config": [], - "filename": null, - "function_name": "check_lambda_function", - "handler": "some_handler", - "image_config": [], - "image_uri": null, - "kms_key_arn": null, - "layers": [], - "memory_size": 128, - "package_type": "Zip", - "publish": false, - "reserved_concurrent_executions": 3, - "runtime": "python3.7", - "s3_bucket": "cdflow-lambda-releases", - "s3_key": "s3key.zip", - "s3_object_version": null, - "tags": null, - "timeout": 3, - "timeouts": null, - "vpc_config": [ - { - "security_group_ids": null, - "subnet_ids": null - } - ] - }, - "after_unknown": { - "arn": true, - "dead_letter_config": [], - "environment": [ - {} - ], - "file_system_config": [], - "id": true, - "image_config": [], - "invoke_arn": true, - "last_modified": true, - "layers": [], - "qualified_arn": true, - "role": true, - "signing_job_arn": true, - "signing_profile_version_arn": true, - "source_code_hash": true, - "source_code_size": true, - "tracing_config": true, - "version": true, - "vpc_config": [ - { - "vpc_id": true - } - ] - } - } - } - ] -} \ No newline at end of file +[ + { + "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_cloudwatch_log_group", + "name": "lambda_loggroup", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "kms_key_id": null, + "name": "/aws/lambda/check_lambda_function", + "name_prefix": null, + "retention_in_days": 7, + "tags": null + }, + "after_unknown": { "arn": true, "id": true, "tags_all": true } + } + }, + { + "address": "module.lambda.aws_iam_role.iam_for_lambda", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role", + "name": "iam_for_lambda", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", + "description": null, + "force_detach_policies": false, + "max_session_duration": 3600, + "name_prefix": "check_lambda_function", + "path": "/", + "permissions_boundary": null, + "tags": null + }, + "after_unknown": { + "arn": true, + "create_date": true, + "id": true, + "inline_policy": true, + "managed_policy_arns": true, + "name": true, + "tags_all": true, + "unique_id": true + } + } + }, + { + "address": "module.lambda.aws_iam_role_policy.lambda_policy", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role_policy", + "name": "lambda_policy", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "name": "policy", + "name_prefix": null, + "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" + }, + "after_unknown": { "id": true, "role": true } + } + }, + { + "address": "module.lambda.aws_lambda_function.lambda_function", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_lambda_function", + "name": "lambda_function", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "architectures": ["x86_64"], + "code_signing_config_arn": null, + "dead_letter_config": [], + "description": null, + "environment": [{ "variables": null }], + "file_system_config": [], + "filename": null, + "function_name": "check_lambda_function", + "handler": "some_handler", + "image_config": [], + "image_uri": null, + "kms_key_arn": null, + "layers": [], + "memory_size": 128, + "package_type": "Zip", + "publish": false, + "reserved_concurrent_executions": 3, + "runtime": "python3.7", + "s3_bucket": "cdflow-lambda-releases", + "s3_key": "s3key.zip", + "s3_object_version": null, + "tags": null, + "timeout": 3, + "timeouts": null, + "vpc_config": [{ "security_group_ids": null, "subnet_ids": null }] + }, + "after_unknown": { + "architectures": [false], + "arn": true, + "dead_letter_config": [], + "environment": [{}], + "file_system_config": [], + "id": true, + "image_config": [], + "invoke_arn": true, + "last_modified": true, + "layers": [], + "qualified_arn": true, + "role": true, + "signing_job_arn": true, + "signing_profile_version_arn": true, + "source_code_hash": true, + "source_code_size": true, + "tags_all": true, + "tracing_config": true, + "version": true, + "vpc_config": [{ "vpc_id": true }] + } + } + } +] diff --git a/test/files/create_lambda_with_tags.json b/test/files/create_lambda_with_tags.json index 0bd59b6..1328746 100644 --- a/test/files/create_lambda_with_tags.json +++ b/test/files/create_lambda_with_tags.json @@ -1,164 +1,135 @@ -{ - "resource_changes": [ - { - "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_cloudwatch_log_group", - "name": "lambda_loggroup", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "kms_key_id": null, - "name": "/aws/lambda/check_lambda_function", - "name_prefix": null, - "retention_in_days": 7, - "tags": null - }, - "after_unknown": { - "arn": true, - "id": true - } - } - }, - { - "address": "module.lambda.aws_iam_role.iam_for_lambda", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role", - "name": "iam_for_lambda", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", - "description": null, - "force_detach_policies": false, - "max_session_duration": 3600, - "name_prefix": "check_lambda_function", - "path": "/", - "permissions_boundary": null, - "tags": null - }, - "after_unknown": { - "arn": true, - "create_date": true, - "id": true, - "inline_policy": true, - "managed_policy_arns": true, - "name": true, - "unique_id": true - } - } - }, - { - "address": "module.lambda.aws_iam_role_policy.lambda_policy", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_iam_role_policy", - "name": "lambda_policy", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "name": "policy", - "name_prefix": null, - "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" - }, - "after_unknown": { - "id": true, - "role": true - } - } - }, - { - "address": "module.lambda.aws_lambda_function.lambda_function", - "module_address": "module.lambda", - "mode": "managed", - "type": "aws_lambda_function", - "name": "lambda_function", - "provider_name": "aws", - "change": { - "actions": [ - "create" - ], - "before": null, - "after": { - "code_signing_config_arn": null, - "dead_letter_config": [], - "description": null, - "environment": [ - { - "variables": null - } - ], - "file_system_config": [], - "filename": null, - "function_name": "check_lambda_function", - "handler": "some_handler", - "image_config": [], - "image_uri": null, - "kms_key_arn": null, - "layers": [], - "memory_size": 128, - "package_type": "Zip", - "publish": false, - "reserved_concurrent_executions": -1, - "runtime": "python3.7", - "s3_bucket": "cdflow-lambda-releases", - "s3_key": "s3key.zip", - "s3_object_version": null, - "tags": { - "component": "test-component", - "env": "test" - }, - "timeout": 3, - "timeouts": null, - "vpc_config": [ - { - "security_group_ids": null, - "subnet_ids": null - } - ] - }, - "after_unknown": { - "arn": true, - "dead_letter_config": [], - "environment": [ - {} - ], - "file_system_config": [], - "id": true, - "image_config": [], - "invoke_arn": true, - "last_modified": true, - "layers": [], - "qualified_arn": true, - "role": true, - "signing_job_arn": true, - "signing_profile_version_arn": true, - "source_code_hash": true, - "source_code_size": true, - "tags": {}, - "tracing_config": true, - "version": true, - "vpc_config": [ - { - "vpc_id": true - } - ] - } - } - } - ] -} \ No newline at end of file +[ + { + "address": "module.lambda.aws_cloudwatch_log_group.lambda_loggroup", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_cloudwatch_log_group", + "name": "lambda_loggroup", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "kms_key_id": null, + "name": "/aws/lambda/check_lambda_function", + "name_prefix": null, + "retention_in_days": 7, + "tags": null + }, + "after_unknown": { "arn": true, "id": true, "tags_all": true } + } + }, + { + "address": "module.lambda.aws_iam_role.iam_for_lambda", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role", + "name": "iam_for_lambda", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "assume_role_policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": \"sts:AssumeRole\",\n \"Principal\": {\n \"Service\": \"lambda.amazonaws.com\"\n },\n \"Effect\": \"Allow\"\n }\n ]\n}\n", + "description": null, + "force_detach_policies": false, + "max_session_duration": 3600, + "name_prefix": "check_lambda_function", + "path": "/", + "permissions_boundary": null, + "tags": null + }, + "after_unknown": { + "arn": true, + "create_date": true, + "id": true, + "inline_policy": true, + "managed_policy_arns": true, + "name": true, + "tags_all": true, + "unique_id": true + } + } + }, + { + "address": "module.lambda.aws_iam_role_policy.lambda_policy", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_iam_role_policy", + "name": "lambda_policy", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "name": "policy", + "name_prefix": null, + "policy": "{\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:CreateLogGroup\",\n \"logs:CreateLogStream\",\n \"logs:PutLogEvents\"\n ],\n \"Resource\": \"arn:aws:logs:*:*:*\"\n }\n ]\n}\n" + }, + "after_unknown": { "id": true, "role": true } + } + }, + { + "address": "module.lambda.aws_lambda_function.lambda_function", + "module_address": "module.lambda", + "mode": "managed", + "type": "aws_lambda_function", + "name": "lambda_function", + "provider_name": "registry.terraform.io/hashicorp/aws", + "change": { + "actions": ["create"], + "before": null, + "after": { + "architectures": ["x86_64"], + "code_signing_config_arn": null, + "dead_letter_config": [], + "description": null, + "environment": [{ "variables": null }], + "file_system_config": [], + "filename": null, + "function_name": "check_lambda_function", + "handler": "some_handler", + "image_config": [], + "image_uri": null, + "kms_key_arn": null, + "layers": [], + "memory_size": 128, + "package_type": "Zip", + "publish": false, + "reserved_concurrent_executions": -1, + "runtime": "python3.7", + "s3_bucket": "cdflow-lambda-releases", + "s3_key": "s3key.zip", + "s3_object_version": null, + "tags": { "component": "test-component", "env": "test" }, + "tags_all": { "component": "test-component", "env": "test" }, + "timeout": 3, + "timeouts": null, + "vpc_config": [{ "security_group_ids": null, "subnet_ids": null }] + }, + "after_unknown": { + "architectures": [false], + "arn": true, + "dead_letter_config": [], + "environment": [{}], + "file_system_config": [], + "id": true, + "image_config": [], + "invoke_arn": true, + "last_modified": true, + "layers": [], + "qualified_arn": true, + "role": true, + "signing_job_arn": true, + "signing_profile_version_arn": true, + "source_code_hash": true, + "source_code_size": true, + "tags": {}, + "tags_all": {}, + "tracing_config": true, + "version": true, + "vpc_config": [{ "vpc_id": true }] + } + } + } +] diff --git a/test/infra/main.tf b/test/infra/main.tf index 88d4be7..0f81fd9 100644 --- a/test/infra/main.tf +++ b/test/infra/main.tf @@ -1,12 +1,7 @@ -terraform { - required_version = ">= 0.12" -} - provider "aws" { - version = ">= 2.15" + version = "3.61.0" skip_credentials_validation = true skip_metadata_api_check = true - skip_get_ec2_platforms = true skip_region_validation = true skip_requesting_account_id = true max_retries = 1 diff --git a/test/infra_container/main.tf b/test/infra_container/main.tf index 3d4df69..ca90bff 100644 --- a/test/infra_container/main.tf +++ b/test/infra_container/main.tf @@ -1,12 +1,7 @@ -terraform { - required_version = ">= 0.12" -} - provider "aws" { - version = ">= 2.15" + version = "3.61.0" skip_credentials_validation = true skip_metadata_api_check = true - skip_get_ec2_platforms = true skip_region_validation = true skip_requesting_account_id = true max_retries = 1 diff --git a/test/run b/test/run index e436084..3d5e455 100755 --- a/test/run +++ b/test/run @@ -14,6 +14,7 @@ docker run \ -w $repo_dir \ -v $repo_dir:$repo_dir \ $name \ - py.test \ - --tb=short \ - "$@" + py.test \ + --tb=long \ + -vv \ + "$@" diff --git a/test/test_lambda.py b/test/test_lambda.py index 9d01e3a..761bd23 100644 --- a/test/test_lambda.py +++ b/test/test_lambda.py @@ -1,7 +1,6 @@ import json import os import unittest - from subprocess import check_call, check_output cwd = os.getcwd() @@ -36,7 +35,7 @@ def assert_resource_changes(self, testname, resource_changes): with open(f'test/files/{testname}.json', 'r') as f: data = json.load(f) - assert data.get('resource_changes') == resource_changes + assert data == resource_changes def test_all_resources_to_be_created(self): # Given When @@ -104,7 +103,6 @@ def test_create_lambda_with_reserved_concurrent_executions(self): ]) resource_changes = self.get_resource_changes() - # Then assert len(resource_changes) == 4 self.assert_resource_changes_action(resource_changes, 'create', 4) diff --git a/versions.tf b/versions.tf index 62c6021..d1a4a22 100644 --- a/versions.tf +++ b/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.12" + required_version = ">= 0.13" required_providers { aws = { source = "hashicorp/aws"