Last active
September 13, 2023 07:45
-
-
Save muromec/9fcb94c0a495eea26911c85e35afd90d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "~> 4.16" | |
} | |
} | |
required_version = ">= 1.2.0" | |
} | |
provider "aws" { | |
region = "eu-north-1" | |
} | |
resource "aws_vpc" "example" { | |
cidr_block = "10.0.0.0/24" | |
assign_generated_ipv6_cidr_block = true | |
tags = { | |
Name = "example-vpc" | |
} | |
} | |
resource "aws_internet_gateway" "gw" { | |
vpc_id = aws_vpc.example.id | |
tags = { | |
Name = "main" | |
} | |
} | |
resource "aws_eip" "nat_gateway" { | |
vpc = true | |
} | |
resource "aws_subnet" "example" { | |
vpc_id = aws_vpc.example.id | |
cidr_block = "10.0.0.0/24" | |
ipv6_cidr_block = cidrsubnet(aws_vpc.example.ipv6_cidr_block, 8, 1) | |
availability_zone = "eu-north-1b" | |
assign_ipv6_address_on_creation = true | |
enable_dns64 = true | |
tags = { | |
Name = "tf-example" | |
} | |
} | |
resource "aws_default_security_group" "example" { | |
vpc_id = aws_vpc.example.id | |
egress { | |
from_port = 0 | |
to_port = 0 | |
protocol = "-1" | |
cidr_blocks = ["0.0.0.0/0"] | |
ipv6_cidr_blocks = ["::/0"] | |
} | |
ingress { | |
from_port = 0 | |
to_port = 0 | |
protocol = "-1" | |
ipv6_cidr_blocks = [] | |
cidr_blocks = [] | |
self = true | |
} | |
ingress { | |
from_port = 0 | |
to_port = 0 | |
protocol = "-1" | |
cidr_blocks = ["0.0.0.0/0"] | |
ipv6_cidr_blocks = ["::/0"] | |
} | |
} | |
resource "aws_nat_gateway" "example" { | |
allocation_id = aws_eip.nat_gateway.id | |
subnet_id = aws_subnet.example.id | |
tags = { | |
Name = "gw NAT" | |
} | |
# To ensure proper ordering, it is recommended to add an explicit dependency | |
# on the Internet Gateway for the VPC. | |
depends_on = [aws_internet_gateway.gw] | |
} | |
resource "aws_default_route_table" "default" { | |
default_route_table_id = aws_vpc.example.default_route_table_id | |
route { | |
ipv6_cidr_block = "64:ff9b::/96" | |
nat_gateway_id = aws_nat_gateway.example.id | |
} | |
route { | |
gateway_id = aws_internet_gateway.gw.id | |
ipv6_cidr_block = "::/0" | |
} | |
route { | |
cidr_block = "0.0.0.0/0" | |
gateway_id = "igw-0573746ac031d6bf8" | |
} | |
} | |
resource "aws_ecs_cluster" "devtf" { | |
name = "devtf" | |
setting { | |
name = "containerInsights" | |
value = "enabled" | |
} | |
} | |
resource "aws_ecs_service" "ssh" { | |
name = "ssh" | |
cluster = aws_ecs_cluster.devtf.id | |
launch_type = "FARGATE" | |
task_definition = "ssh" | |
desired_count = 0 | |
network_configuration { | |
subnets = [aws_subnet.example.id] | |
security_groups = [aws_default_security_group.example.id] | |
assign_public_ip = false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment