Last active
August 16, 2023 14:55
-
-
Save atrakic/50ac323cbaf7ffd5a05234d1896263f4 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_version = ">= 0.12.6" | |
} | |
variable "environment" { | |
type = string | |
description = "What deployment environment should we use <dev|stg|prd>?" | |
default = "dev" | |
} | |
locals { | |
environment = lookup(local.environment_map, var.environment, "dev") | |
environment_map = { | |
dev = "dev" | |
stg = "stg" | |
prd = "prd" | |
} | |
region = local.region_map[local.environment] | |
region_map = { | |
dev = "eu-west-1" | |
stg = "eu-west-1" | |
prd = "eu-west-1" | |
} | |
# VPCs Peering (rfc1918): | |
vpc_cidr_map = { | |
dev = "10.0.0.0/16" | |
stg = "172.16.0.0/16" | |
prd = "192.168.0.0/16" | |
} | |
private_subnets_map = { | |
dev = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] | |
stg = ["172.16.1.0/24", "172.16.2.0/24", "172.16.3.0/24"] | |
prd = ["192.168.1.0/24", "192.168.2.0/24", "192.168.3.0/24"] | |
} | |
intra_subnets_map = { | |
dev = ["10.0.11.0/24", "10.0.12.0/24", "10.0.13.0/24"] | |
stg = ["172.16.11.0/24", "172.16.12.0/24", "172.16.13/24"] | |
prd = ["192.168.11.0/24", "192.168.12.0/24", "192.168.13.0/24"] | |
} | |
database_subnets_map = { | |
dev = ["10.0.21.0/24", "10.0.22.0/24", "10.0.23.0/24"] | |
stg = ["172.16.21.0/24", "172.16.22.0/24", "172.16.23.0/24"] | |
prd = ["192.168.21.0/24", "192.168.22.0/24", "192.168.23.0/24"] | |
} | |
public_subnets_map = { | |
dev = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"] | |
stg = ["172.16.101.0/24", "172.16.102.0/24", "172.16.103.0/24"] | |
prd = ["192.168.101.0/24", "192.168.102.0/24", "192.168.103.0/24"] | |
} | |
ec2_instance_type_map = { | |
dev = "t3a.small" | |
stg = "t3a.small" | |
prd = "t3a.medium" | |
} | |
} | |
output "environment" { | |
description = "This environment" | |
value = local.environment | |
} | |
output "region_map" { | |
description = "Map with aws_region for each environment" | |
value = local.region_map | |
} | |
output "region" { | |
description = "Region used for selected environment" | |
value = local.region | |
} | |
output "defaults" { | |
description = "Default settings for choosen environment" | |
value = { | |
organization = "example" | |
hq_ip = "152.115.64.106/32" | |
ubuntu_release = "20.04" | |
domain_name = "foo.bar" | |
cidr = local.vpc_cidr_map[local.environment] | |
private_subnets = flatten(local.private_subnets_map[local.environment]) | |
intra_subnets = flatten(local.intra_subnets_map[local.environment]) | |
public_subnets = flatten(local.public_subnets_map[local.environment]) | |
database_subnets = flatten(local.database_subnets_map[local.environment]) | |
ec2_instance_type = local.ec2_instance_type_map[local.environment] | |
aws_accounts = { | |
"prd" = "063792149814" | |
"dev" = "091671180443" | |
"stg" = "091671180443" | |
} | |
} | |
} | |
output "vpc_cidr_map" { | |
value = local.vpc_cidr_map | |
} | |
output "environment_map" { | |
description = "Map of available environments" | |
value = local.environment_map | |
} | |
output "codeship_ips" { | |
description = "https://docs.cloudbees.com/docs/cloudbees-codeship/latest/general-account/static-ip-addresses" | |
value = sort(compact(distinct(["35.153.154.87", "34.235.84.42", "54.88.27.219", "35.170.141.30", "52.20.253.7", "107.23.56.82", "34.238.108.61", "34.239.17.55"]))) | |
} | |
output "third_part_cidr_blocks" { | |
description = "Map with third part block cidr" | |
value = { | |
noitso = ["94.189.60.102/32"] | |
trustly = ["93.158.127.40/32"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment