Skip to content

Commit e24ce48

Browse files
authored
Merge pull request #2972 from kakakakakku/lambda-managed-instances-tf
lambda-managed-instances-tf: Remove CDK-specific tags from Terraform
2 parents b392ac6 + 7c6b62e commit e24ce48

2 files changed

Lines changed: 30 additions & 42 deletions

File tree

lambda-managed-instances-tf/main.tf

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ provider "aws" {
2424

2525
# Local variables
2626
locals {
27-
function_name = "hello-world-managed-instances-tf"
27+
function_name = "hello-world-managed-instances-tf"
2828
log_group_name = "/demo/lambda/${local.function_name}"
2929
}
3030

@@ -43,7 +43,7 @@ data "archive_file" "lambda_zip" {
4343
resource "aws_cloudwatch_log_group" "demo_log_group" {
4444
name = local.log_group_name
4545
retention_in_days = 14
46-
46+
4747
tags = {
4848
Name = "DemoLogGroup"
4949
Environment = "demo"
@@ -101,18 +101,16 @@ resource "aws_internet_gateway" "igw" {
101101
}
102102
}
103103

104-
# Public subnets (matching CDK CIDR blocks)
104+
# Public subnets
105105
resource "aws_subnet" "public_subnet_1" {
106106
vpc_id = aws_vpc.lambda_managed_instances_vpc.id
107107
cidr_block = "10.0.0.0/19"
108108
availability_zone = data.aws_availability_zones.available.names[0]
109109
map_public_ip_on_launch = true
110110

111111
tags = {
112-
Name = "LambdaManagedInstancesPublicSubnet1"
113-
Environment = "demo"
114-
"aws-cdk:subnet-name" = "Public"
115-
"aws-cdk:subnet-type" = "Public"
112+
Name = "LambdaManagedInstancesPublicSubnet1"
113+
Environment = "demo"
116114
}
117115
}
118116

@@ -123,10 +121,8 @@ resource "aws_subnet" "public_subnet_2" {
123121
map_public_ip_on_launch = true
124122

125123
tags = {
126-
Name = "LambdaManagedInstancesPublicSubnet2"
127-
Environment = "demo"
128-
"aws-cdk:subnet-name" = "Public"
129-
"aws-cdk:subnet-type" = "Public"
124+
Name = "LambdaManagedInstancesPublicSubnet2"
125+
Environment = "demo"
130126
}
131127
}
132128

@@ -137,24 +133,20 @@ resource "aws_subnet" "public_subnet_3" {
137133
map_public_ip_on_launch = true
138134

139135
tags = {
140-
Name = "LambdaManagedInstancesPublicSubnet3"
141-
Environment = "demo"
142-
"aws-cdk:subnet-name" = "Public"
143-
"aws-cdk:subnet-type" = "Public"
136+
Name = "LambdaManagedInstancesPublicSubnet3"
137+
Environment = "demo"
144138
}
145139
}
146140

147-
# Private subnets (matching CDK CIDR blocks)
141+
# Private subnets
148142
resource "aws_subnet" "private_subnet_1" {
149143
vpc_id = aws_vpc.lambda_managed_instances_vpc.id
150144
cidr_block = "10.0.96.0/19"
151145
availability_zone = data.aws_availability_zones.available.names[0]
152146

153147
tags = {
154-
Name = "LambdaManagedInstancesPrivateSubnet1"
155-
Environment = "demo"
156-
"aws-cdk:subnet-name" = "Private"
157-
"aws-cdk:subnet-type" = "Private"
148+
Name = "LambdaManagedInstancesPrivateSubnet1"
149+
Environment = "demo"
158150
}
159151
}
160152

@@ -164,10 +156,8 @@ resource "aws_subnet" "private_subnet_2" {
164156
availability_zone = data.aws_availability_zones.available.names[1]
165157

166158
tags = {
167-
Name = "LambdaManagedInstancesPrivateSubnet2"
168-
Environment = "demo"
169-
"aws-cdk:subnet-name" = "Private"
170-
"aws-cdk:subnet-type" = "Private"
159+
Name = "LambdaManagedInstancesPrivateSubnet2"
160+
Environment = "demo"
171161
}
172162
}
173163

@@ -177,10 +167,8 @@ resource "aws_subnet" "private_subnet_3" {
177167
availability_zone = data.aws_availability_zones.available.names[2]
178168

179169
tags = {
180-
Name = "LambdaManagedInstancesPrivateSubnet3"
181-
Environment = "demo"
182-
"aws-cdk:subnet-name" = "Private"
183-
"aws-cdk:subnet-type" = "Private"
170+
Name = "LambdaManagedInstancesPrivateSubnet3"
171+
Environment = "demo"
184172
}
185173
}
186174

@@ -191,7 +179,7 @@ data "aws_availability_zones" "available" {
191179

192180
# Elastic IPs for NAT Gateways
193181
resource "aws_eip" "nat_eip_1" {
194-
domain = "vpc"
182+
domain = "vpc"
195183
depends_on = [aws_internet_gateway.igw]
196184

197185
tags = {
@@ -201,7 +189,7 @@ resource "aws_eip" "nat_eip_1" {
201189
}
202190

203191
resource "aws_eip" "nat_eip_2" {
204-
domain = "vpc"
192+
domain = "vpc"
205193
depends_on = [aws_internet_gateway.igw]
206194

207195
tags = {
@@ -211,7 +199,7 @@ resource "aws_eip" "nat_eip_2" {
211199
}
212200

213201
resource "aws_eip" "nat_eip_3" {
214-
domain = "vpc"
202+
domain = "vpc"
215203
depends_on = [aws_internet_gateway.igw]
216204

217205
tags = {
@@ -394,7 +382,7 @@ resource "aws_security_group" "lambda_security_group" {
394382
}
395383
}
396384

397-
# Restrict default security group (matching CDK behavior)
385+
# Restrict default security group
398386
resource "aws_default_security_group" "default" {
399387
vpc_id = aws_vpc.lambda_managed_instances_vpc.id
400388

@@ -412,14 +400,14 @@ resource "aws_default_security_group" "default" {
412400
resource "aws_lambda_function" "hello_world_function" {
413401
filename = data.archive_file.lambda_zip.output_path
414402
function_name = local.function_name
415-
role = aws_iam_role.lambda_role.arn
416-
handler = "hello-world.lambda_handler"
403+
role = aws_iam_role.lambda_role.arn
404+
handler = "hello-world.lambda_handler"
417405
source_code_hash = data.archive_file.lambda_zip.output_base64sha256
418-
runtime = "python3.13"
419-
architectures = ["arm64"]
420-
description = "Simple Hello World Lambda function on Managed Instances"
421-
memory_size = 2048
422-
publish = true
406+
runtime = "python3.13"
407+
architectures = ["arm64"]
408+
description = "Simple Hello World Lambda function on Managed Instances"
409+
memory_size = 2048
410+
publish = true
423411

424412
logging_config {
425413
log_format = "JSON"
@@ -492,7 +480,7 @@ resource "aws_iam_role_policy_attachment" "capacity_provider_managed_policy" {
492480
# Lambda Capacity Provider for Managed Instances
493481
resource "aws_lambda_capacity_provider" "lambda_capacity_provider" {
494482
name = "lambda-capacity-provider-tf"
495-
483+
496484
vpc_config {
497485
subnet_ids = [aws_subnet.private_subnet_1.id, aws_subnet.private_subnet_2.id, aws_subnet.private_subnet_3.id]
498486
security_group_ids = [aws_security_group.lambda_security_group.id]
@@ -512,4 +500,4 @@ resource "aws_lambda_capacity_provider" "lambda_capacity_provider" {
512500
}
513501
}
514502

515-
# Function association with capacity provider is configured in the Lambda function resource above
503+
# Function association with capacity provider is configured in the Lambda function resource above

lambda-managed-instances-tf/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ output "function_alias" {
6262

6363
output "manual_association_command" {
6464
description = "Manual command to associate Lambda function with capacity provider"
65-
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}"
65+
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}"
6666
}
6767

6868
output "nat_gateway_ids" {

0 commit comments

Comments
 (0)