diff --git a/lambda-managed-instances-tf/main.tf b/lambda-managed-instances-tf/main.tf index 78279780d..8a993e716 100644 --- a/lambda-managed-instances-tf/main.tf +++ b/lambda-managed-instances-tf/main.tf @@ -24,7 +24,7 @@ provider "aws" { # Local variables locals { - function_name = "hello-world-managed-instances-tf" + function_name = "hello-world-managed-instances-tf" log_group_name = "/demo/lambda/${local.function_name}" } @@ -43,7 +43,7 @@ data "archive_file" "lambda_zip" { resource "aws_cloudwatch_log_group" "demo_log_group" { name = local.log_group_name retention_in_days = 14 - + tags = { Name = "DemoLogGroup" Environment = "demo" @@ -101,7 +101,7 @@ resource "aws_internet_gateway" "igw" { } } -# Public subnets (matching CDK CIDR blocks) +# Public subnets resource "aws_subnet" "public_subnet_1" { vpc_id = aws_vpc.lambda_managed_instances_vpc.id cidr_block = "10.0.0.0/19" @@ -109,10 +109,8 @@ resource "aws_subnet" "public_subnet_1" { map_public_ip_on_launch = true tags = { - Name = "LambdaManagedInstancesPublicSubnet1" - Environment = "demo" - "aws-cdk:subnet-name" = "Public" - "aws-cdk:subnet-type" = "Public" + Name = "LambdaManagedInstancesPublicSubnet1" + Environment = "demo" } } @@ -123,10 +121,8 @@ resource "aws_subnet" "public_subnet_2" { map_public_ip_on_launch = true tags = { - Name = "LambdaManagedInstancesPublicSubnet2" - Environment = "demo" - "aws-cdk:subnet-name" = "Public" - "aws-cdk:subnet-type" = "Public" + Name = "LambdaManagedInstancesPublicSubnet2" + Environment = "demo" } } @@ -137,24 +133,20 @@ resource "aws_subnet" "public_subnet_3" { map_public_ip_on_launch = true tags = { - Name = "LambdaManagedInstancesPublicSubnet3" - Environment = "demo" - "aws-cdk:subnet-name" = "Public" - "aws-cdk:subnet-type" = "Public" + Name = "LambdaManagedInstancesPublicSubnet3" + Environment = "demo" } } -# Private subnets (matching CDK CIDR blocks) +# Private subnets resource "aws_subnet" "private_subnet_1" { vpc_id = aws_vpc.lambda_managed_instances_vpc.id cidr_block = "10.0.96.0/19" availability_zone = data.aws_availability_zones.available.names[0] tags = { - Name = "LambdaManagedInstancesPrivateSubnet1" - Environment = "demo" - "aws-cdk:subnet-name" = "Private" - "aws-cdk:subnet-type" = "Private" + Name = "LambdaManagedInstancesPrivateSubnet1" + Environment = "demo" } } @@ -164,10 +156,8 @@ resource "aws_subnet" "private_subnet_2" { availability_zone = data.aws_availability_zones.available.names[1] tags = { - Name = "LambdaManagedInstancesPrivateSubnet2" - Environment = "demo" - "aws-cdk:subnet-name" = "Private" - "aws-cdk:subnet-type" = "Private" + Name = "LambdaManagedInstancesPrivateSubnet2" + Environment = "demo" } } @@ -177,10 +167,8 @@ resource "aws_subnet" "private_subnet_3" { availability_zone = data.aws_availability_zones.available.names[2] tags = { - Name = "LambdaManagedInstancesPrivateSubnet3" - Environment = "demo" - "aws-cdk:subnet-name" = "Private" - "aws-cdk:subnet-type" = "Private" + Name = "LambdaManagedInstancesPrivateSubnet3" + Environment = "demo" } } @@ -191,7 +179,7 @@ data "aws_availability_zones" "available" { # Elastic IPs for NAT Gateways resource "aws_eip" "nat_eip_1" { - domain = "vpc" + domain = "vpc" depends_on = [aws_internet_gateway.igw] tags = { @@ -201,7 +189,7 @@ resource "aws_eip" "nat_eip_1" { } resource "aws_eip" "nat_eip_2" { - domain = "vpc" + domain = "vpc" depends_on = [aws_internet_gateway.igw] tags = { @@ -211,7 +199,7 @@ resource "aws_eip" "nat_eip_2" { } resource "aws_eip" "nat_eip_3" { - domain = "vpc" + domain = "vpc" depends_on = [aws_internet_gateway.igw] tags = { @@ -394,7 +382,7 @@ resource "aws_security_group" "lambda_security_group" { } } -# Restrict default security group (matching CDK behavior) +# Restrict default security group resource "aws_default_security_group" "default" { vpc_id = aws_vpc.lambda_managed_instances_vpc.id @@ -412,14 +400,14 @@ resource "aws_default_security_group" "default" { resource "aws_lambda_function" "hello_world_function" { filename = data.archive_file.lambda_zip.output_path function_name = local.function_name - role = aws_iam_role.lambda_role.arn - handler = "hello-world.lambda_handler" + role = aws_iam_role.lambda_role.arn + handler = "hello-world.lambda_handler" source_code_hash = data.archive_file.lambda_zip.output_base64sha256 - runtime = "python3.13" - architectures = ["arm64"] - description = "Simple Hello World Lambda function on Managed Instances" - memory_size = 2048 - publish = true + runtime = "python3.13" + architectures = ["arm64"] + description = "Simple Hello World Lambda function on Managed Instances" + memory_size = 2048 + publish = true logging_config { log_format = "JSON" @@ -492,7 +480,7 @@ resource "aws_iam_role_policy_attachment" "capacity_provider_managed_policy" { # Lambda Capacity Provider for Managed Instances resource "aws_lambda_capacity_provider" "lambda_capacity_provider" { name = "lambda-capacity-provider-tf" - + vpc_config { subnet_ids = [aws_subnet.private_subnet_1.id, aws_subnet.private_subnet_2.id, aws_subnet.private_subnet_3.id] security_group_ids = [aws_security_group.lambda_security_group.id] @@ -512,4 +500,4 @@ resource "aws_lambda_capacity_provider" "lambda_capacity_provider" { } } -# Function association with capacity provider is configured in the Lambda function resource above \ No newline at end of file +# Function association with capacity provider is configured in the Lambda function resource above diff --git a/lambda-managed-instances-tf/outputs.tf b/lambda-managed-instances-tf/outputs.tf index fff3ae639..049ec6b6f 100644 --- a/lambda-managed-instances-tf/outputs.tf +++ b/lambda-managed-instances-tf/outputs.tf @@ -62,7 +62,7 @@ output "function_alias" { output "manual_association_command" { description = "Manual command to associate Lambda function with capacity provider" - value = "aws lambda put-capacity-provider-function --capacity-provider-arn ${aws_lambda_capacity_provider.lambda_capacity_provider.arn} --function-name ${aws_lambda_function.hello_world_function.function_name}" + value = "aws lambda put-capacity-provider-function --capacity-provider-arn ${aws_lambda_capacity_provider.lambda_capacity_provider.arn} --function-name ${aws_lambda_function.hello_world_function.function_name}" } output "nat_gateway_ids" {