{"id":82558,"date":"2024-11-04T16:01:11","date_gmt":"2024-11-04T12:31:11","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/standup-serverless-jenkins-on-fargate-with-terraform-part-1-networking-ba\/"},"modified":"2024-11-04T16:01:11","modified_gmt":"2024-11-04T12:31:11","slug":"standup-serverless-jenkins-on-fargate-with-terraform-part-1-networking-ba","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/standup-serverless-jenkins-on-fargate-with-terraform-part-1-networking-ba\/","title":{"rendered":"Standup Serverless Jenkins on Fargate with Terraform &#8211; Part 1: Networking"},"content":{"rendered":"<p>Summarize this content to 400 words in Persian Lang<br \/>\n            \u0627\u0628\u062a\u062f\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0645\u062a\u063a\u06cc\u0631\u0647\u0627.tf. \u0627\u06cc\u0646 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0645\u0627 \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc \u062f\u0647\u062f \u062a\u0627 \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc \u0645\u0648\u0631\u062f \u0646\u06cc\u0627\u0632 \u062e\u0648\u062f \u0631\u0627 \u062a\u0639\u0631\u06cc\u0641 \u06a9\u0646\u06cc\u0645 &#8211; \u06cc\u06a9 \u0628\u0644\u0648\u06a9 VPC CIDR\u060c \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u062e\u0635\u0648\u0635\u06cc \u0648 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0639\u0645\u0648\u0645\u06cc.<\/p>\n<p>variable &#8220;vpc_cidr_block&#8221; {<br \/>\n  description = &#8220;CIDR of vpc&#8221;<br \/>\n  type        = string<br \/>\n}<\/p>\n<p>variable &#8220;public_subnets&#8221; {<br \/>\n  description = &#8220;Map of public subnets that should be created&#8221;<br \/>\n  type = map(object({<br \/>\n    cidr_block        = string<br \/>\n    availability_zone = string<br \/>\n  }))<br \/>\n}<\/p>\n<p>variable &#8220;private_subnets&#8221; {<br \/>\n  description = &#8220;Map of private subnets that should be created&#8221;<br \/>\n  type = map(object({<br \/>\n    cidr_block        = string<br \/>\n    availability_zone = string<br \/>\n  }))<br \/>\n}<\/p>\n<p>variable &#8220;application_name&#8221; {<br \/>\n  description = &#8220;Name of the application&#8221;<br \/>\n  type        = string<br \/>\n}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u062f\u0631 \u0645\u0631\u062d\u0644\u0647 \u0628\u0639\u062f\u060c \u062a\u0639\u0627\u0631\u06cc\u0641 \u0645\u062a\u063a\u06cc\u0631 \u0631\u0627 \u0627\u0631\u0627\u0626\u0647 \u062e\u0648\u0627\u0647\u06cc\u0645 \u062f\u0627\u062f terraform.tfvars.<\/p>\n<p>vpc_cidr_block = &#8220;10.0.0.0\/24&#8221;<\/p>\n<p>public_subnets = {<br \/>\n  subnet_1 = {<br \/>\n    cidr_block        = &#8220;10.0.0.0\/26&#8221;<br \/>\n    availability_zone = &#8220;us-east-1a&#8221;<br \/>\n  }<br \/>\n  subnet_2 = {<br \/>\n    cidr_block        = &#8220;10.0.0.64\/26&#8221;<br \/>\n    availability_zone = &#8220;us-east-1b&#8221;<br \/>\n  }<br \/>\n}<\/p>\n<p>private_subnets = {<br \/>\n  subnet_1 = {<br \/>\n    cidr_block        = &#8220;10.0.0.128\/26&#8221;<br \/>\n    availability_zone = &#8220;us-east-1a&#8221;<br \/>\n  }<br \/>\n  subnet_2 = {<br \/>\n    cidr_block        = &#8220;10.0.0.192\/26&#8221;<br \/>\n    availability_zone = &#8220;us-east-1b&#8221;<br \/>\n  }<br \/>\n}<\/p>\n<p>application_name = &#8220;serverless-jenkins-on-ecs&#8221;<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0627\u06a9\u0646\u0648\u0646\u060c \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f vpc.tf  \u0648 \u0627\u0628\u062a\u062f\u0627 VPC \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f. \u06cc\u06a9 AWS VPC (Virtual Private Cloud) \u06cc\u06a9 \u0634\u0628\u06a9\u0647 \u0645\u062c\u0627\u0632\u06cc \u0627\u0633\u062a \u06a9\u0647 \u0628\u0647 \u0637\u0648\u0631 \u0645\u0646\u0637\u0642\u06cc \u0627\u0632 \u0633\u0627\u06cc\u0631 \u0634\u0628\u06a9\u0647\u200c\u0647\u0627\u06cc \u0645\u062c\u0627\u0632\u06cc \u062f\u0631 AWS Cloud \u062c\u062f\u0627 \u0634\u062f\u0647 \u0627\u0633\u062a \u0648 \u06a9\u0646\u062a\u0631\u0644 \u0622\u062f\u0631\u0633\u200c\u0647\u0627\u06cc IP\u060c \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647\u200c\u0647\u0627\u060c \u062c\u062f\u0648\u0644\u200c\u0647\u0627\u06cc \u0645\u0633\u06cc\u0631 \u0648 \u062f\u0631\u0648\u0627\u0632\u0647\u200c\u0647\u0627\u06cc \u0634\u0628\u06a9\u0647 \u0631\u0627 \u062f\u0631 \u0627\u062e\u062a\u06cc\u0627\u0631 \u0634\u0645\u0627 \u0642\u0631\u0627\u0631 \u0645\u06cc\u200c\u062f\u0647\u062f.<\/p>\n<p># VPC<br \/>\nresource &#8220;aws_vpc&#8221; &#8220;this&#8221; {<br \/>\n  cidr_block           = var.vpc_cidr_block<br \/>\n  enable_dns_hostnames = true<br \/>\n  tags = {<br \/>\n    Name = var.application_name<br \/>\n  }<br \/>\n}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0639\u0645\u0648\u0645\u06cc \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0686\u06cc\u0632\u06cc \u06a9\u0647 \u0627\u06cc\u0646 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627 \u0631\u0627 \u0639\u0645\u0648\u0645\u06cc \u0645\u06cc \u06a9\u0646\u062f \u0627\u06cc\u0646 \u0627\u0633\u062a \u06a9\u0647 \u0645\u0633\u06cc\u0631\u06cc \u0628\u0647 \u06cc\u06a9 \u062f\u0631\u0648\u0627\u0632\u0647 \u0627\u06cc\u0646\u062a\u0631\u0646\u062a\u06cc (IGW) \u062e\u0648\u0627\u0647\u0646\u062f \u062f\u0627\u0634\u062a \u06a9\u0647 \u0628\u0647 \u0645\u0646\u0627\u0628\u0639 \u062f\u0631\u0648\u0646 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc \u062f\u0647\u062f \u0645\u0633\u062a\u0642\u06cc\u0645\u0627\u064b \u0628\u0627 \u0627\u06cc\u0646\u062a\u0631\u0646\u062a \u0627\u0631\u062a\u0628\u0627\u0637 \u0628\u0631\u0642\u0631\u0627\u0631 \u06a9\u0646\u0646\u062f.<\/p>\n<p># Public Subnets<br \/>\nresource &#8220;aws_subnet&#8221; &#8220;public&#8221; {<br \/>\n  for_each = var.public_subnets<br \/>\n  vpc_id = aws_vpc.this.id<br \/>\n  cidr_block              = each.value.cidr_block<br \/>\n  availability_zone       = each.value.availability_zone<br \/>\n  map_public_ip_on_launch = true<br \/>\n  tags = {<br \/>\n    Name = format(&#8220;public-%s-%s&#8221;, var.application_name, each.value.availability_zone)<br \/>\n  }<br \/>\n}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>IGW \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u0622\u0646 \u0631\u0627 \u0628\u0627 VPC \u0645\u0631\u062a\u0628\u0637 \u06a9\u0646\u06cc\u062f. \u0628\u0639\u062f\u0627\u064b \u062f\u0631 \u062c\u062f\u0648\u0644 \u0645\u0633\u06cc\u0631 \u062e\u0648\u062f \u0628\u0647 \u0622\u0646 \u0627\u0634\u0627\u0631\u0647 \u062e\u0648\u0627\u0647\u06cc\u0645 \u06a9\u0631\u062f \u0648 \u0628\u0647 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0639\u0645\u0648\u0645\u06cc \u062e\u0648\u062f \u0645\u062a\u0635\u0644 \u062e\u0648\u0627\u0647\u06cc\u0645 \u06a9\u0631\u062f.<\/p>\n<p># IGW<br \/>\nresource &#8220;aws_internet_gateway&#8221; &#8220;this&#8221; {<br \/>\n  vpc_id = aws_vpc.this.id<br \/>\n}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u06cc\u06a9 \u062c\u062f\u0648\u0644 \u0645\u0633\u06cc\u0631 \u0628\u0631\u0627\u06cc \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0639\u0645\u0648\u0645\u06cc \u062e\u0648\u062f \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u06cc\u06a9 \u0645\u0633\u06cc\u0631 \u0628\u0647 \u062a\u0631\u0627\u0641\u06cc\u06a9 \u0642\u06cc\u0641\u06cc \u0627\u0632 \u0637\u0631\u06cc\u0642 IGW \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f. \u067e\u0633 \u0627\u0632 \u0622\u0646\u060c \u0627\u0631\u062a\u0628\u0627\u0637 \u062c\u062f\u0648\u0644 \u0645\u0633\u06cc\u0631 \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u062a\u0627 IGW \u0628\u0627 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0639\u0645\u0648\u0645\u06cc \u0633\u06cc\u0645 \u06a9\u0634\u06cc \u0634\u0648\u062f.<\/p>\n<p># Public Route Table<br \/>\nresource &#8220;aws_route_table&#8221; &#8220;public&#8221; {<br \/>\n  vpc_id = aws_vpc.this.id<br \/>\n  tags = {<br \/>\n    Name = &#8220;public&#8221;<br \/>\n  }<br \/>\n}<br \/>\n# Add IGW Route<br \/>\nresource &#8220;aws_route&#8221; &#8220;public&#8221; {<br \/>\n  route_table_id         = aws_route_table.public.id<br \/>\n  destination_cidr_block = &#8220;0.0.0.0\/0&#8221;<br \/>\n  gateway_id             = aws_internet_gateway.this.id<br \/>\n}<br \/>\n# Associate Route Table with Subnet<br \/>\nresource &#8220;aws_route_table_association&#8221; &#8220;public&#8221; {<br \/>\n  for_each = aws_subnet.public<\/p>\n<p>  subnet_id      = each.value.id<br \/>\n  route_table_id = aws_route_table.public.id<br \/>\n}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0628\u0639\u062f\u060c \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u062e\u0635\u0648\u0635\u06cc \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f. \u0647\u0645\u0627\u0646\u0637\u0648\u0631 \u06a9\u0647 \u0627\u0632 \u0646\u0627\u0645 \u0622\u0646 \u067e\u06cc\u062f\u0627\u0633\u062a\u060c \u0627\u06cc\u0646 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627 \u0627\u0632 \u062f\u0646\u06cc\u0627\u06cc \u062e\u0627\u0631\u062c \u063a\u06cc\u0631\u0642\u0627\u0628\u0644 \u062f\u0633\u062a\u0631\u0633\u06cc \u0647\u0633\u062a\u0646\u062f.<\/p>\n<p># Private Subnets<br \/>\nresource &#8220;aws_subnet&#8221; &#8220;private&#8221; {<br \/>\n  for_each = var.private_subnets<\/p>\n<p>  vpc_id = aws_vpc.this.id<\/p>\n<p>  cidr_block        = each.value.cidr_block<br \/>\n  availability_zone = each.value.availability_zone<\/p>\n<p>  tags = {<br \/>\n    Name = format(&#8220;private-%s-%s&#8221;, var.application_name, each.value.availability_zone)<br \/>\n  }<br \/>\n}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u062d\u0627\u0644\u0627 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u06cc\u06a9 IP \u0627\u0644\u0627\u0633\u062a\u06cc\u06a9 (EIP) \u0648 \u06cc\u06a9 \u062f\u0631\u0648\u0627\u0632\u0647 NAT \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u0645. \u0645\u0627 \u0628\u0647 EIP \u0646\u06cc\u0627\u0632 \u062f\u0627\u0631\u06cc\u0645\u060c \u0632\u06cc\u0631\u0627 AWS \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u0628\u062e\u0634\u06cc \u0627\u0632 \u0627\u06cc\u062c\u0627\u062f NAT Gateway \u0628\u0647 \u06cc\u06a9\u06cc \u0646\u06cc\u0627\u0632 \u062f\u0627\u0631\u062f. NAT Gateway \u0636\u0631\u0648\u0631\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 \u0628\u0647 \u0627\u06cc\u0646 \u062a\u0631\u062a\u06cc\u0628 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u062e\u0635\u0648\u0635\u06cc \u0645\u06cc \u062a\u0648\u0627\u0646\u0646\u062f \u0628\u0627 \u0634\u0628\u06a9\u0647 \u0627\u0631\u062a\u0628\u0627\u0637 \u0628\u0631\u0642\u0631\u0627\u0631 \u06a9\u0646\u0646\u062f. \u062a\u0635\u0648\u0631 \u06a9\u0646\u06cc\u062f \u06a9\u0647 RHEL EC2 \u062f\u0627\u0631\u06cc\u062f \u06a9\u0647 \u0628\u0627\u06cc\u062f \u0628\u0647\u200c\u0631\u0648\u0632\u0631\u0633\u0627\u0646\u06cc\u200c\u0647\u0627\u06cc yum \u0631\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0646\u0646\u062f. \u0634\u0645\u0627 \u0628\u0647 \u06cc\u06a9 NAT Gateway \u0646\u06cc\u0627\u0632 \u062f\u0627\u0631\u06cc\u062f.<\/p>\n<p># EIP for NAT Gateway<br \/>\nresource &#8220;aws_eip&#8221; &#8220;this&#8221; {<br \/>\n  for_each = aws_subnet.private<br \/>\n}<\/p>\n<p># NAT Gateway<br \/>\nresource &#8220;aws_nat_gateway&#8221; &#8220;this&#8221; {<br \/>\n  for_each = aws_subnet.private<\/p>\n<p>  subnet_id     = aws_subnet.public[each.key].id<br \/>\n  allocation_id = aws_eip.this[each.key].id<\/p>\n<p>  tags = {<br \/>\n    Name = format(&#8220;private-%s-%s&#8221;, var.application_name, each.value.availability_zone)<br \/>\n  }<br \/>\n}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u062f\u0631 \u0645\u0631\u062d\u0644\u0647 \u0628\u0639\u062f\u060c \u062c\u062f\u0648\u0644 \u0645\u0633\u06cc\u0631\u060c \u0645\u0633\u06cc\u0631 \u0627\u0631\u062a\u0628\u0627\u0637 NAT Gateway \u0628\u0647 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u062e\u0635\u0648\u0635\u06cc \u0648 \u0627\u0631\u062a\u0628\u0627\u0637 \u062c\u062f\u0648\u0644 \u0645\u0633\u06cc\u0631 \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u0645\u06cc \u06a9\u0646\u06cc\u0645.<\/p>\n<p># Private Route Table<br \/>\nresource &#8220;aws_route_table&#8221; &#8220;private&#8221; {<br \/>\n  for_each = aws_subnet.private<\/p>\n<p>  vpc_id = aws_vpc.this.id<\/p>\n<p>  tags = {<br \/>\n    Name = format(&#8220;private-%s-%s&#8221;, var.application_name, each.value.availability_zone)<br \/>\n  }<br \/>\n}<br \/>\n# Add Route &#8211; Private Subnets to NAT Gateway<br \/>\nresource &#8220;aws_route&#8221; &#8220;private&#8221; {<br \/>\n  for_each = aws_subnet.private<\/p>\n<p>  route_table_id         = aws_route_table.private[each.key].id<br \/>\n  destination_cidr_block = &#8220;0.0.0.0\/0&#8221;<br \/>\n  nat_gateway_id         = aws_nat_gateway.this[each.key].id<br \/>\n}<br \/>\n# Associate Private RT with Private Subnets<br \/>\nresource &#8220;aws_route_table_association&#8221; &#8220;private&#8221; {<br \/>\n  for_each = aws_subnet.private<\/p>\n<p>  subnet_id      = each.value.id<br \/>\n  route_table_id = aws_route_table.private[each.key].id<br \/>\n}<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0634\u0645\u0627 \u0622\u0645\u0627\u062f\u0647 \u0627\u06cc\u062f. \u062f\u0633\u062a\u0648\u0631\u0627\u062a \u0632\u06cc\u0631 \u0631\u0627 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f.<\/p>\n<p># Initialize Terraform<br \/>\nterraform init<br \/>\n# Check and see what will be created<br \/>\nterraform plan<br \/>\n# Let&#8217;s do this!<br \/>\nterraform apply<\/p>\n<p>    \u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/p>\n<p>    \u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/p>\n<p>\u0627\u06a9\u0646\u0648\u0646 \u0628\u0647 \u06a9\u0646\u0633\u0648\u0644 AWS \u0628\u0631\u0648\u06cc\u062f \u0648 VPC \u0631\u0627 \u062c\u0633\u062a\u062c\u0648 \u06a9\u0646\u06cc\u062f. \u0628\u0647 \u0633\u0645\u062a \u067e\u0627\u06cc\u06cc\u0646 \u0628\u0647 \u0646\u0642\u0634\u0647 \u0645\u0646\u0628\u0639 VPC \u0628\u0631\u0648\u06cc\u062f. \u0631\u0648\u06cc subnets next \u06a9\u0644\u06cc\u06a9 \u06a9\u0646\u06cc\u062f.\u0647\u0645\u0686\u0646\u06cc\u0646\u060c \u062c\u062f\u0648\u0644 \u0647\u0627\u06cc \u0645\u0633\u06cc\u0631\u060c \u062f\u0631\u0648\u0627\u0632\u0647 \u0647\u0627\u06cc \u0627\u06cc\u0646\u062a\u0631\u0646\u062a\u06cc\u060c \u062f\u0631\u0648\u0627\u0632\u0647 \u0647\u0627\u06cc NAT \u0648 IP \u0647\u0627\u06cc \u0627\u0644\u0627\u0633\u062a\u06cc\u06a9 \u062e\u0648\u062f \u0631\u0627 \u0628\u0631\u0631\u0633\u06cc \u06a9\u0646\u06cc\u062f. <\/p>\n<p>\u0641\u06cc\u0646<\/p>\n<div data-article-id=\"2062386\" id=\"article-body\">\n<p>\u0627\u0628\u062a\u062f\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f <em><strong>\u0645\u062a\u063a\u06cc\u0631\u0647\u0627.tf<\/strong><\/em>. \u0627\u06cc\u0646 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0645\u0627 \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc \u062f\u0647\u062f \u062a\u0627 \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc \u0645\u0648\u0631\u062f \u0646\u06cc\u0627\u0632 \u062e\u0648\u062f \u0631\u0627 \u062a\u0639\u0631\u06cc\u0641 \u06a9\u0646\u06cc\u0645 &#8211; \u06cc\u06a9 \u0628\u0644\u0648\u06a9 VPC CIDR\u060c \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u062e\u0635\u0648\u0635\u06cc \u0648 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0639\u0645\u0648\u0645\u06cc.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>variable \"vpc_cidr_block\" {\n  description = \"CIDR of vpc\"\n  type        = string\n}\n\nvariable \"public_subnets\" {\n  description = \"Map of public subnets that should be created\"\n  type = map(object({\n    cidr_block        = string\n    availability_zone = string\n  }))\n}\n\nvariable \"private_subnets\" {\n  description = \"Map of private subnets that should be created\"\n  type = map(object({\n    cidr_block        = string\n    availability_zone = string\n  }))\n}\n\nvariable \"application_name\" {\n  description = \"Name of the application\"\n  type        = string\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u062f\u0631 \u0645\u0631\u062d\u0644\u0647 \u0628\u0639\u062f\u060c \u062a\u0639\u0627\u0631\u06cc\u0641 \u0645\u062a\u063a\u06cc\u0631 \u0631\u0627 \u0627\u0631\u0627\u0626\u0647 \u062e\u0648\u0627\u0647\u06cc\u0645 \u062f\u0627\u062f <strong><em>terraform.tfvars<\/em><\/strong>.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>vpc_cidr_block = \"10.0.0.0\/24\"\n\npublic_subnets = {\n  subnet_1 = {\n    cidr_block        = \"10.0.0.0\/26\"\n    availability_zone = \"us-east-1a\"\n  }\n  subnet_2 = {\n    cidr_block        = \"10.0.0.64\/26\"\n    availability_zone = \"us-east-1b\"\n  }\n}\n\nprivate_subnets = {\n  subnet_1 = {\n    cidr_block        = \"10.0.0.128\/26\"\n    availability_zone = \"us-east-1a\"\n  }\n  subnet_2 = {\n    cidr_block        = \"10.0.0.192\/26\"\n    availability_zone = \"us-east-1b\"\n  }\n}\n\napplication_name = \"serverless-jenkins-on-ecs\"\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0627\u06a9\u0646\u0648\u0646\u060c \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f <em><strong>vpc.tf<\/strong><\/em>  \u0648 \u0627\u0628\u062a\u062f\u0627 VPC \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f. \u06cc\u06a9 AWS VPC (Virtual Private Cloud) \u06cc\u06a9 \u0634\u0628\u06a9\u0647 \u0645\u062c\u0627\u0632\u06cc \u0627\u0633\u062a \u06a9\u0647 \u0628\u0647 \u0637\u0648\u0631 \u0645\u0646\u0637\u0642\u06cc \u0627\u0632 \u0633\u0627\u06cc\u0631 \u0634\u0628\u06a9\u0647\u200c\u0647\u0627\u06cc \u0645\u062c\u0627\u0632\u06cc \u062f\u0631 AWS Cloud \u062c\u062f\u0627 \u0634\u062f\u0647 \u0627\u0633\u062a \u0648 \u06a9\u0646\u062a\u0631\u0644 \u0622\u062f\u0631\u0633\u200c\u0647\u0627\u06cc IP\u060c \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647\u200c\u0647\u0627\u060c \u062c\u062f\u0648\u0644\u200c\u0647\u0627\u06cc \u0645\u0633\u06cc\u0631 \u0648 \u062f\u0631\u0648\u0627\u0632\u0647\u200c\u0647\u0627\u06cc \u0634\u0628\u06a9\u0647 \u0631\u0627 \u062f\u0631 \u0627\u062e\u062a\u06cc\u0627\u0631 \u0634\u0645\u0627 \u0642\u0631\u0627\u0631 \u0645\u06cc\u200c\u062f\u0647\u062f.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code># VPC\nresource \"aws_vpc\" \"this\" {\n  cidr_block           = var.vpc_cidr_block\n  enable_dns_hostnames = true\n  tags = {\n    Name = var.application_name\n  }\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0639\u0645\u0648\u0645\u06cc \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0686\u06cc\u0632\u06cc \u06a9\u0647 \u0627\u06cc\u0646 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627 \u0631\u0627 \u0639\u0645\u0648\u0645\u06cc \u0645\u06cc \u06a9\u0646\u062f \u0627\u06cc\u0646 \u0627\u0633\u062a \u06a9\u0647 \u0645\u0633\u06cc\u0631\u06cc \u0628\u0647 \u06cc\u06a9 \u062f\u0631\u0648\u0627\u0632\u0647 \u0627\u06cc\u0646\u062a\u0631\u0646\u062a\u06cc (IGW) \u062e\u0648\u0627\u0647\u0646\u062f \u062f\u0627\u0634\u062a \u06a9\u0647 \u0628\u0647 \u0645\u0646\u0627\u0628\u0639 \u062f\u0631\u0648\u0646 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc \u062f\u0647\u062f \u0645\u0633\u062a\u0642\u06cc\u0645\u0627\u064b \u0628\u0627 \u0627\u06cc\u0646\u062a\u0631\u0646\u062a \u0627\u0631\u062a\u0628\u0627\u0637 \u0628\u0631\u0642\u0631\u0627\u0631 \u06a9\u0646\u0646\u062f.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code># Public Subnets\nresource \"aws_subnet\" \"public\" {\n  for_each = var.public_subnets\n  vpc_id = aws_vpc.this.id\n  cidr_block              = each.value.cidr_block\n  availability_zone       = each.value.availability_zone\n  map_public_ip_on_launch = true\n  tags = {\n    Name = format(\"public-%s-%s\", var.application_name, each.value.availability_zone)\n  }\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>IGW \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u0622\u0646 \u0631\u0627 \u0628\u0627 VPC \u0645\u0631\u062a\u0628\u0637 \u06a9\u0646\u06cc\u062f. \u0628\u0639\u062f\u0627\u064b \u062f\u0631 \u062c\u062f\u0648\u0644 \u0645\u0633\u06cc\u0631 \u062e\u0648\u062f \u0628\u0647 \u0622\u0646 \u0627\u0634\u0627\u0631\u0647 \u062e\u0648\u0627\u0647\u06cc\u0645 \u06a9\u0631\u062f \u0648 \u0628\u0647 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0639\u0645\u0648\u0645\u06cc \u062e\u0648\u062f \u0645\u062a\u0635\u0644 \u062e\u0648\u0627\u0647\u06cc\u0645 \u06a9\u0631\u062f.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code># IGW \nresource \"aws_internet_gateway\" \"this\" {\n  vpc_id = aws_vpc.this.id\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u06cc\u06a9 \u062c\u062f\u0648\u0644 \u0645\u0633\u06cc\u0631 \u0628\u0631\u0627\u06cc \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0639\u0645\u0648\u0645\u06cc \u062e\u0648\u062f \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u06cc\u06a9 \u0645\u0633\u06cc\u0631 \u0628\u0647 \u062a\u0631\u0627\u0641\u06cc\u06a9 \u0642\u06cc\u0641\u06cc \u0627\u0632 \u0637\u0631\u06cc\u0642 IGW \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f. \u067e\u0633 \u0627\u0632 \u0622\u0646\u060c \u0627\u0631\u062a\u0628\u0627\u0637 \u062c\u062f\u0648\u0644 \u0645\u0633\u06cc\u0631 \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u062a\u0627 IGW \u0628\u0627 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0639\u0645\u0648\u0645\u06cc \u0633\u06cc\u0645 \u06a9\u0634\u06cc \u0634\u0648\u062f.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code># Public Route Table\nresource \"aws_route_table\" \"public\" {\n  vpc_id = aws_vpc.this.id\n  tags = {\n    Name = \"public\"\n  }\n}\n# Add IGW Route \nresource \"aws_route\" \"public\" {\n  route_table_id         = aws_route_table.public.id\n  destination_cidr_block = \"0.0.0.0\/0\"\n  gateway_id             = aws_internet_gateway.this.id\n}\n# Associate Route Table with Subnet \nresource \"aws_route_table_association\" \"public\" {\n  for_each = aws_subnet.public\n\n  subnet_id      = each.value.id\n  route_table_id = aws_route_table.public.id\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0628\u0639\u062f\u060c \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u062e\u0635\u0648\u0635\u06cc \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f. \u0647\u0645\u0627\u0646\u0637\u0648\u0631 \u06a9\u0647 \u0627\u0632 \u0646\u0627\u0645 \u0622\u0646 \u067e\u06cc\u062f\u0627\u0633\u062a\u060c \u0627\u06cc\u0646 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627 \u0627\u0632 \u062f\u0646\u06cc\u0627\u06cc \u062e\u0627\u0631\u062c \u063a\u06cc\u0631\u0642\u0627\u0628\u0644 \u062f\u0633\u062a\u0631\u0633\u06cc \u0647\u0633\u062a\u0646\u062f.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code># Private Subnets\nresource \"aws_subnet\" \"private\" {\n  for_each = var.private_subnets\n\n  vpc_id = aws_vpc.this.id\n\n  cidr_block        = each.value.cidr_block\n  availability_zone = each.value.availability_zone\n\n  tags = {\n    Name = format(\"private-%s-%s\", var.application_name, each.value.availability_zone)\n  }\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u062d\u0627\u0644\u0627 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u06cc\u06a9 IP \u0627\u0644\u0627\u0633\u062a\u06cc\u06a9 (EIP) \u0648 \u06cc\u06a9 \u062f\u0631\u0648\u0627\u0632\u0647 NAT \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u0645. \u0645\u0627 \u0628\u0647 EIP \u0646\u06cc\u0627\u0632 \u062f\u0627\u0631\u06cc\u0645\u060c \u0632\u06cc\u0631\u0627 AWS \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u0628\u062e\u0634\u06cc \u0627\u0632 \u0627\u06cc\u062c\u0627\u062f NAT Gateway \u0628\u0647 \u06cc\u06a9\u06cc \u0646\u06cc\u0627\u0632 \u062f\u0627\u0631\u062f. NAT Gateway \u0636\u0631\u0648\u0631\u06cc \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 \u0628\u0647 \u0627\u06cc\u0646 \u062a\u0631\u062a\u06cc\u0628 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u062e\u0635\u0648\u0635\u06cc \u0645\u06cc \u062a\u0648\u0627\u0646\u0646\u062f \u0628\u0627 \u0634\u0628\u06a9\u0647 \u0627\u0631\u062a\u0628\u0627\u0637 \u0628\u0631\u0642\u0631\u0627\u0631 \u06a9\u0646\u0646\u062f. \u062a\u0635\u0648\u0631 \u06a9\u0646\u06cc\u062f \u06a9\u0647 RHEL EC2 \u062f\u0627\u0631\u06cc\u062f \u06a9\u0647 \u0628\u0627\u06cc\u062f \u0628\u0647\u200c\u0631\u0648\u0632\u0631\u0633\u0627\u0646\u06cc\u200c\u0647\u0627\u06cc yum \u0631\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0646\u0646\u062f. \u0634\u0645\u0627 \u0628\u0647 \u06cc\u06a9 NAT Gateway \u0646\u06cc\u0627\u0632 \u062f\u0627\u0631\u06cc\u062f.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code># EIP for NAT Gateway\nresource \"aws_eip\" \"this\" {\n  for_each = aws_subnet.private\n}\n\n# NAT Gateway \nresource \"aws_nat_gateway\" \"this\" {\n  for_each = aws_subnet.private\n\n  subnet_id     = aws_subnet.public[each.key].id\n  allocation_id = aws_eip.this[each.key].id\n\n  tags = {\n    Name = format(\"private-%s-%s\", var.application_name, each.value.availability_zone)\n  }\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u062f\u0631 \u0645\u0631\u062d\u0644\u0647 \u0628\u0639\u062f\u060c \u062c\u062f\u0648\u0644 \u0645\u0633\u06cc\u0631\u060c \u0645\u0633\u06cc\u0631 \u0627\u0631\u062a\u0628\u0627\u0637 NAT Gateway \u0628\u0647 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u062e\u0635\u0648\u0635\u06cc \u0648 \u0627\u0631\u062a\u0628\u0627\u0637 \u062c\u062f\u0648\u0644 \u0645\u0633\u06cc\u0631 \u0631\u0627 \u0627\u06cc\u062c\u0627\u062f \u0645\u06cc \u06a9\u0646\u06cc\u0645.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code># Private Route Table \nresource \"aws_route_table\" \"private\" {\n  for_each = aws_subnet.private\n\n  vpc_id = aws_vpc.this.id\n\n  tags = {\n    Name = format(\"private-%s-%s\", var.application_name, each.value.availability_zone)\n  }\n}\n# Add Route - Private Subnets to NAT Gateway\nresource \"aws_route\" \"private\" {\n  for_each = aws_subnet.private\n\n  route_table_id         = aws_route_table.private[each.key].id\n  destination_cidr_block = \"0.0.0.0\/0\"\n  nat_gateway_id         = aws_nat_gateway.this[each.key].id\n}\n# Associate Private RT with Private Subnets\nresource \"aws_route_table_association\" \"private\" {\n  for_each = aws_subnet.private\n\n  subnet_id      = each.value.id\n  route_table_id = aws_route_table.private[each.key].id\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0634\u0645\u0627 \u0622\u0645\u0627\u062f\u0647 \u0627\u06cc\u062f. \u062f\u0633\u062a\u0648\u0631\u0627\u062a \u0632\u06cc\u0631 \u0631\u0627 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code># Initialize Terraform\nterraform init\n# Check and see what will be created\nterraform plan\n# Let's do this!\nterraform apply\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0627\u06a9\u0646\u0648\u0646 \u0628\u0647 \u06a9\u0646\u0633\u0648\u0644 AWS \u0628\u0631\u0648\u06cc\u062f \u0648 VPC \u0631\u0627 \u062c\u0633\u062a\u062c\u0648 \u06a9\u0646\u06cc\u062f. <br \/><br \/>\u0628\u0647 \u0633\u0645\u062a \u067e\u0627\u06cc\u06cc\u0646 \u0628\u0647 \u0646\u0642\u0634\u0647 \u0645\u0646\u0628\u0639 VPC \u0628\u0631\u0648\u06cc\u062f. <br \/><img decoding=\"async\" src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft5hxlggq8291beuesgau.png\" alt=\"\u0646\u0642\u0634\u0647 \u0645\u0646\u0627\u0628\u0639 VPC\" loading=\"lazy\" width=\"800\" height=\"266\" title=\"\"><br \/>\u0631\u0648\u06cc subnets next \u06a9\u0644\u06cc\u06a9 \u06a9\u0646\u06cc\u062f.<br \/><img decoding=\"async\" src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsfxaf3bh6vhamlim8omp.png\" alt=\"\u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc AWS\" loading=\"lazy\" width=\"800\" height=\"273\" title=\"\"><br \/>\u0647\u0645\u0686\u0646\u06cc\u0646\u060c \u062c\u062f\u0648\u0644 \u0647\u0627\u06cc \u0645\u0633\u06cc\u0631\u060c \u062f\u0631\u0648\u0627\u0632\u0647 \u0647\u0627\u06cc \u0627\u06cc\u0646\u062a\u0631\u0646\u062a\u06cc\u060c \u062f\u0631\u0648\u0627\u0632\u0647 \u0647\u0627\u06cc NAT \u0648 IP \u0647\u0627\u06cc \u0627\u0644\u0627\u0633\u062a\u06cc\u06a9 \u062e\u0648\u062f \u0631\u0627 \u0628\u0631\u0631\u0633\u06cc \u06a9\u0646\u06cc\u062f. <\/p>\n<p>\u0641\u06cc\u0646<\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summarize this content to 400 words in Persian Lang \u0627\u0628\u062a\u062f\u0627 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0645\u062a\u063a\u06cc\u0631\u0647\u0627.tf. \u0627\u06cc\u0646 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0645\u0627 \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc \u062f\u0647\u062f \u062a\u0627 \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc \u0645\u0648\u0631\u062f \u0646\u06cc\u0627\u0632 \u062e\u0648\u062f \u0631\u0627 \u062a\u0639\u0631\u06cc\u0641 \u06a9\u0646\u06cc\u0645 &#8211; \u06cc\u06a9 \u0628\u0644\u0648\u06a9 VPC CIDR\u060c \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u062e\u0635\u0648\u0635\u06cc \u0648 \u0632\u06cc\u0631\u0634\u0628\u06a9\u0647 \u0647\u0627\u06cc \u0639\u0645\u0648\u0645\u06cc. variable &#8220;vpc_cidr_block&#8221; { description = &#8220;CIDR of vpc&#8221; type = string } variable &#8220;public_subnets&#8221; { &hellip;<\/p>\n","protected":false},"author":2,"featured_media":82559,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-82558","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/82558","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=82558"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/82558\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media\/82559"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=82558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=82558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=82558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}