fix: make subnet names static (#71)
* fix: make network names static Signed-off-by: matttrach <matt.trachier@suse.com> * fix: put flag back Signed-off-by: matttrach <matt.trachier@suse.com> --------- Signed-off-by: matttrach <matt.trachier@suse.com>
This commit is contained in:
parent
916d98b7b0
commit
b256b55fb6
|
|
@ -1,5 +1,7 @@
|
|||
# Terraform AWS Access
|
||||
|
||||
WARNING! The subnets argument must not be derived from an apply time resource.
|
||||
|
||||
## Recent Changes
|
||||
|
||||
- Manage external access
|
||||
|
|
|
|||
|
|
@ -13,17 +13,11 @@ provider "acme" {
|
|||
locals {
|
||||
identifier = var.identifier
|
||||
example = "basic"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, md5(local.identifier)])), 0, 5)}-${local.identifier}"
|
||||
zone = var.zone
|
||||
domain = "${local.identifier}.${local.zone}"
|
||||
}
|
||||
resource "random_pet" "string" {
|
||||
keepers = {
|
||||
# regenerate the pet name when the identifier changes
|
||||
identifier = local.identifier
|
||||
}
|
||||
length = 1
|
||||
}
|
||||
|
||||
# AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
|
||||
module "this" {
|
||||
source = "../../"
|
||||
|
|
|
|||
|
|
@ -13,19 +13,13 @@ provider "acme" {
|
|||
locals {
|
||||
identifier = var.identifier
|
||||
example = "domain"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, md5(local.identifier)])), 0, 5)}-${local.identifier}"
|
||||
owner = "terraform-ci@suse.com"
|
||||
zone = var.zone
|
||||
domain = "${local.identifier}.${local.zone}"
|
||||
#zone = var.domain_zone
|
||||
}
|
||||
resource "random_pet" "string" {
|
||||
keepers = {
|
||||
# regenerate the pet name when the identifier changes
|
||||
identifier = local.identifier
|
||||
}
|
||||
length = 1
|
||||
}
|
||||
|
||||
# AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
|
||||
module "this" {
|
||||
source = "../../"
|
||||
|
|
|
|||
|
|
@ -14,17 +14,11 @@ provider "acme" {
|
|||
locals {
|
||||
identifier = var.identifier
|
||||
example = "ingress"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, md5(local.identifier)])), 0, 5)}-${local.identifier}"
|
||||
zone = var.zone
|
||||
domain = "${local.identifier}.${local.zone}"
|
||||
}
|
||||
resource "random_pet" "string" {
|
||||
keepers = {
|
||||
# regenerate the pet name when the identifier changes
|
||||
identifier = local.identifier
|
||||
}
|
||||
length = 1
|
||||
}
|
||||
|
||||
# AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
|
||||
module "this" {
|
||||
source = "../../"
|
||||
|
|
|
|||
|
|
@ -13,15 +13,9 @@ provider "acme" {
|
|||
locals {
|
||||
identifier = var.identifier
|
||||
example = "loadbalancer"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
|
||||
}
|
||||
resource "random_pet" "string" {
|
||||
keepers = {
|
||||
# regenerate the pet name when the identifier changes
|
||||
identifier = local.identifier
|
||||
}
|
||||
length = 1
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, md5(local.identifier)])), 0, 5)}-${local.identifier}"
|
||||
}
|
||||
|
||||
# AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
|
||||
module "this" {
|
||||
source = "../../"
|
||||
|
|
|
|||
|
|
@ -13,15 +13,9 @@ provider "acme" {
|
|||
locals {
|
||||
identifier = var.identifier
|
||||
example = "securitygroup"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
|
||||
}
|
||||
resource "random_pet" "string" {
|
||||
keepers = {
|
||||
# regenerate the pet name when the identifier changes
|
||||
identifier = local.identifier
|
||||
}
|
||||
length = 1
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, md5(local.identifier)])), 0, 5)}-${local.identifier}"
|
||||
}
|
||||
|
||||
# AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
|
||||
module "this" {
|
||||
source = "../../"
|
||||
|
|
|
|||
|
|
@ -14,17 +14,10 @@ provider "acme" {
|
|||
locals {
|
||||
identifier = var.identifier
|
||||
example = "selectvpc"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, md5(local.identifier)])), 0, 5)}-${local.identifier}"
|
||||
zone = var.zone
|
||||
domain = "${local.identifier}.${local.zone}"
|
||||
}
|
||||
resource "random_pet" "string" {
|
||||
keepers = {
|
||||
# regenerate the pet name when the identifier changes
|
||||
identifier = local.identifier
|
||||
}
|
||||
length = 1
|
||||
}
|
||||
|
||||
module "setup" {
|
||||
source = "../../"
|
||||
|
|
|
|||
|
|
@ -13,32 +13,26 @@ provider "acme" {
|
|||
locals {
|
||||
identifier = var.identifier
|
||||
example = "subnets"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
|
||||
}
|
||||
resource "random_pet" "string" {
|
||||
keepers = {
|
||||
# regenerate the pet name when the identifier changes
|
||||
identifier = local.identifier
|
||||
}
|
||||
length = 1
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, md5(local.identifier)])), 0, 5)}-${local.identifier}"
|
||||
}
|
||||
|
||||
# AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
|
||||
module "this" {
|
||||
source = "../../"
|
||||
vpc_name = "${local.project_name}-vpc"
|
||||
vpc_cidr = "10.0.255.0/24" # gives 256 usable addresses from .1 to .254, but AWS reserves .1 to .4 and .255, leaving .5 to .254
|
||||
subnets = {
|
||||
"subnetA" = {
|
||||
"${local.project_name}A" = {
|
||||
cidr = "10.0.255.0/26"
|
||||
availability_zone = "us-west-2a"
|
||||
public = false # when true AWS will automatically provision public ips for instances in this subnet
|
||||
}
|
||||
"subnetB" = {
|
||||
"${local.project_name}B" = {
|
||||
cidr = "10.0.255.64/26"
|
||||
availability_zone = "us-west-2b"
|
||||
public = false # when true AWS will automatically provision public ips for instances in this subnet
|
||||
}
|
||||
"subnetC" = {
|
||||
"${local.project_name}C" = {
|
||||
cidr = "10.0.255.128/26"
|
||||
availability_zone = "us-west-2c"
|
||||
public = false # when true AWS will automatically provision public ips for instances in this subnet
|
||||
|
|
|
|||
|
|
@ -13,15 +13,9 @@ provider "acme" {
|
|||
locals {
|
||||
identifier = var.identifier
|
||||
example = "vpc"
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
|
||||
}
|
||||
resource "random_pet" "string" {
|
||||
keepers = {
|
||||
# regenerate the pet name when the identifier changes
|
||||
identifier = local.identifier
|
||||
}
|
||||
length = 1
|
||||
project_name = "tf-${substr(md5(join("-", [local.example, md5(local.identifier)])), 0, 5)}-${local.identifier}"
|
||||
}
|
||||
|
||||
# AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
|
||||
module "this" {
|
||||
source = "../../"
|
||||
|
|
|
|||
4
main.tf
4
main.tf
|
|
@ -47,7 +47,7 @@ locals {
|
|||
vpc_cidr = (var.vpc_cidr == "" ? "10.0.255.0/24" : var.vpc_cidr)
|
||||
|
||||
# subnet
|
||||
subnets = (local.subnet_mod == 1 ? var.subnets : {})
|
||||
subnets = var.subnets
|
||||
subnet_names = keys(local.subnets)
|
||||
subnet_count = length(local.subnets)
|
||||
newbits = (local.subnet_count > 1 ? ceil(log(local.subnet_count, 2)) : 1)
|
||||
|
|
@ -86,7 +86,7 @@ module "subnet" {
|
|||
depends_on = [
|
||||
module.vpc,
|
||||
]
|
||||
for_each = local.subnets
|
||||
for_each = (local.subnet_mod == 1 ? local.subnets : {})
|
||||
source = "./modules/subnet"
|
||||
use = local.subnet_use_strategy
|
||||
vpc_id = module.vpc[0].id
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ variable "subnets" {
|
|||
- The cidr will be generated based on the VPC's cidr and the number of subnets you are creating.
|
||||
- The public flag will be set to false.
|
||||
If you are expecting high availability, make sure there are at least three availability zones in the region you are deploying to.
|
||||
WARNING! The key for this argument must not be derived from a resource, it must be static.
|
||||
EOT
|
||||
default = { "default" = {
|
||||
cidr = "", # will be generated based on the vpc cidr
|
||||
|
|
@ -221,4 +222,4 @@ variable "domain_zone" {
|
|||
If you are using an existing domain zone, you can leave this blank.
|
||||
EOT
|
||||
default = ""
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue