Skip to content

Commit 70b8a51

Browse files
authored
Merge pull request #265 from 100-hours-a-week/feat/v3-k8s-iac
fix: NAT EIP 제거 (dev 동적 IP 사용)
2 parents 54247a6 + c470f9e commit 70b8a51

4 files changed

Lines changed: 3 additions & 33 deletions

File tree

IaC/3-v3/aws/environments/k8s-dev/outputs.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ output "workers" {
1616

1717
# --- Networking ---
1818

19-
output "nat_eip_public_ip" {
20-
description = "NAT EIP 퍼블릭 IP (모니터링 SG 허용 등)"
21-
value = module.nat_instance.eip_public_ip
22-
}
23-
2419
output "k8s_subnet_ids" {
2520
description = "K8S 서브넷 ID 맵"
2621
value = module.k8s_networking.private_subnet_ids

IaC/3-v3/aws/modules/nat-instance/main.tf

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ============================================================
22
# V3 K8S IaC — NAT Instance (ASG 래핑, dev: 1대 / prod: AZ별)
3-
# ASG Min=Max=1 + user_data에서 EIP 연결 + RT route 갱신
3+
# ASG Min=Max=1 + user_data에서 RT route 갱신
44
# Branch: feat/v3-k8s-iac
55
# ============================================================
66

@@ -54,17 +54,7 @@ resource "aws_security_group" "nat" {
5454
})
5555
}
5656

57-
# --- EIP (ASG 교체 시 user_data에서 재연결) ---
58-
59-
resource "aws_eip" "nat" {
60-
domain = "vpc"
61-
62-
tags = merge(var.common_tags, {
63-
Name = "${var.project_name}-nat-eip"
64-
})
65-
}
66-
67-
# --- IAM Role (NAT 전용: SSM + EIP/Route 권한) ---
57+
# --- IAM Role (NAT 전용: SSM + Route 권한) ---
6858

6959
resource "aws_iam_role" "nat" {
7060
name = "${var.project_name}-nat-role"
@@ -103,7 +93,6 @@ resource "aws_iam_role_policy" "nat_self_heal" {
10393
{
10494
Effect = "Allow"
10595
Action = [
106-
"ec2:AssociateAddress",
10796
"ec2:ModifyInstanceAttribute",
10897
"ec2:ReplaceRoute",
10998
"ec2:CreateRoute"
@@ -147,7 +136,6 @@ resource "aws_launch_template" "nat" {
147136

148137
user_data = base64encode(templatefile("${path.module}/user_data.sh.tpl", {
149138
vpc_cidr = var.vpc_cidr
150-
eip_alloc_id = aws_eip.nat.id
151139
route_table_ids = join(",", var.route_table_ids)
152140
region = var.region
153141
}))

IaC/3-v3/aws/modules/nat-instance/outputs.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
# V3 K8S IaC — NAT Instance Outputs
33
# ============================================================
44

5-
output "eip_public_ip" {
6-
description = "NAT EIP 퍼블릭 IP (모니터링 SG 허용 등에 사용)"
7-
value = aws_eip.nat.public_ip
8-
}
9-
105
output "security_group_id" {
116
value = aws_security_group.nat.id
127
}

IaC/3-v3/aws/modules/nat-instance/user_data.sh.tpl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/bin/bash
22
# ============================================================
33
# V3 K8S IaC — NAT Instance user_data
4-
# ASG 교체 시 자동으로 EIP 연결 + RT route 갱신
4+
# ASG 교체 시 자동으로 source/dest check 비활성화 + RT route 갱신
55
# Branch: feat/v3-k8s-iac
66
# ============================================================
77
set -euo pipefail
88

99
REGION="${region}"
10-
EIP_ALLOC_ID="${eip_alloc_id}"
1110
ROUTE_TABLE_IDS="${route_table_ids}"
1211
VPC_CIDR="${vpc_cidr}"
1312

@@ -17,13 +16,6 @@ TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" \
1716
INSTANCE_ID=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" \
1817
http://169.254.169.254/latest/meta-data/instance-id)
1918

20-
# --- Associate EIP ---
21-
aws ec2 associate-address \
22-
--instance-id "$INSTANCE_ID" \
23-
--allocation-id "$EIP_ALLOC_ID" \
24-
--region "$REGION" \
25-
--allow-reassociation
26-
2719
# --- Disable source/dest check ---
2820
aws ec2 modify-instance-attribute \
2921
--instance-id "$INSTANCE_ID" \

0 commit comments

Comments
 (0)