Files
zeekay 241625e7d9 rename: ziti → zt across all paths
- Repo names: ziti-* → zt-*
- Go modules: github.com/hanzozt/ziti → github.com/hanzozt/zt
- Docker images: hanzozt/ziti-* → hanzozt/zt-*
- C/Java/JS symbols: ziti_* → zt_*
- File and directory names updated
2026-02-18 18:34:19 -08:00

161 lines
3.2 KiB
Terraform

variable "access_key" {}
variable "secret_key" {}
variable "region" {}
variable "vpc_cidr" {}
variable "public_cidr" {}
variable "az" {}
variable "environment_tag" {}
output "fablab_security_group_id" { value = aws_security_group.fablab.id }
output "subnet_id" { value = aws_subnet.fablab.id }
provider "aws" {
access_key = var.access_key
secret_key = var.secret_key
region = var.region
}
resource "aws_vpc" "fablab" {
cidr_block = var.vpc_cidr
enable_dns_hostnames = true
tags = {
Name = var.environment_tag
source = "fablab"
}
}
resource "aws_internet_gateway" "fablab" {
vpc_id = aws_vpc.fablab.id
tags = {
Name = var.environment_tag
source = "fablab"
}
}
resource "aws_subnet" "fablab" {
vpc_id = aws_vpc.fablab.id
cidr_block = var.public_cidr
availability_zone = var.az
tags = {
Name = var.environment_tag
source = "fablab"
}
}
resource "aws_route_table" "fablab" {
vpc_id = aws_vpc.fablab.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.fablab.id
}
tags = {
Name = var.environment_tag
source = "fablab"
}
}
resource "aws_route_table_association" "fablab" {
subnet_id = aws_subnet.fablab.id
route_table_id = aws_route_table.fablab.id
}
resource "aws_security_group" "fablab" {
name = var.environment_tag
vpc_id = aws_vpc.fablab.id
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 443
to_port = 443
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 10000
to_port = 10000
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 8171
to_port = 8171
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 7001
to_port = 7005
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 7001
to_port = 7001
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 6000
to_port = 6400
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 6000
to_port = 6400
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 1280
to_port = 1280
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = var.environment_tag
source = "fablab"
}
}
{{ range $sgId, $sg := .Model.AWS.SecurityGroups }}
resource "aws_security_group" "{{ $sgId }}" {
name = "{{ $sg.Name }}"
vpc_id = aws_vpc.fablab.id
{{ range $idx, $rule := $sg.Rules }}
{{ $rule.Direction }} {
from_port = {{ $rule.Port }}
to_port = {{ $rule.Port }}
protocol = "{{ $rule.Protocol }}"
cidr_blocks = {{ $rule.CidrBlockList }}
}
{{ end }}
tags = {
Name = "{{ $sg.Name}}"
source = "fablab"
}
}
output "{{ $sgId }}_security_group_id" { value = aws_security_group.{{ $sgId }}.id }
{{ end }}