fix: add more random names (#70)

Signed-off-by: matttrach <matt.trachier@suse.com>
This commit is contained in:
Matt Trachier 2024-05-03 16:48:42 -05:00 committed by GitHub
parent 261177ad4c
commit 403f6309ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 153 additions and 53 deletions

View File

@ -11,18 +11,26 @@ provider "acme" {
server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" server_url = "https://acme-staging-v02.api.letsencrypt.org/directory"
} }
locals { locals {
identifier = var.identifier identifier = var.identifier
name = "tf-${local.identifier}" example = "basic"
zone = var.zone project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
domain = "${local.identifier}.${local.zone}" 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) # AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
module "this" { module "this" {
source = "../../" source = "../../"
vpc_name = local.name 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 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
security_group_name = local.name security_group_name = "${local.project_name}-sg"
security_group_type = "egress" security_group_type = "egress"
load_balancer_name = local.name load_balancer_name = "${local.project_name}-lb"
domain = local.domain domain = local.domain
} }

View File

@ -9,9 +9,13 @@ terraform {
source = "hashicorp/aws" source = "hashicorp/aws"
version = ">= 5.11" version = ">= 5.11"
} }
random = {
source = "hashicorp/random"
version = ">= 3.1"
}
acme = { acme = {
source = "vancluever/acme" source = "vancluever/acme"
version = ">= 2.0" version = ">= 2.0"
} }
} }
} }

View File

@ -11,21 +11,29 @@ provider "acme" {
server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" server_url = "https://acme-staging-v02.api.letsencrypt.org/directory"
} }
locals { locals {
identifier = var.identifier identifier = var.identifier
name = "tf-${local.identifier}" example = "domain"
owner = "terraform-ci@suse.com" project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
zone = var.zone owner = "terraform-ci@suse.com"
domain = "${local.identifier}.${local.zone}" zone = var.zone
domain = "${local.identifier}.${local.zone}"
#zone = var.domain_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) # AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
module "this" { module "this" {
source = "../../" source = "../../"
vpc_name = local.name 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 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
security_group_name = local.name security_group_name = "${local.project_name}-sg"
security_group_type = "project" security_group_type = "project"
load_balancer_name = local.name load_balancer_name = "${local.project_name}-lb"
domain = local.domain domain = local.domain
#domain_zone = local.zone # only specify when creating a new zone #domain_zone = local.zone # only specify when creating a new zone
} }

View File

@ -9,9 +9,13 @@ terraform {
source = "hashicorp/aws" source = "hashicorp/aws"
version = ">= 5.11" version = ">= 5.11"
} }
random = {
source = "hashicorp/random"
version = ">= 3.1"
}
acme = { acme = {
source = "vancluever/acme" source = "vancluever/acme"
version = ">= 2.0" version = ">= 2.0"
} }
} }
} }

View File

@ -12,20 +12,28 @@ provider "acme" {
#server_url = "https://acme-v02.api.letsencrypt.org/directory" # use this url in production #server_url = "https://acme-v02.api.letsencrypt.org/directory" # use this url in production
} }
locals { locals {
identifier = var.identifier identifier = var.identifier
name = "tf-${local.identifier}" example = "ingress"
zone = var.zone project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
domain = "${local.identifier}.${local.zone}" 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) # AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
module "this" { module "this" {
source = "../../" source = "../../"
vpc_name = local.name 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 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
security_group_name = local.name security_group_name = "${local.project_name}-sg"
security_group_type = "egress" security_group_type = "egress"
domain = local.domain domain = local.domain
load_balancer_name = local.name load_balancer_name = "${local.project_name}-lb"
load_balancer_access_cidrs = { load_balancer_access_cidrs = {
application = { application = {
port = 443 port = 443

View File

@ -9,9 +9,13 @@ terraform {
source = "hashicorp/aws" source = "hashicorp/aws"
version = ">= 5.11" version = ">= 5.11"
} }
random = {
source = "hashicorp/random"
version = ">= 3.1"
}
acme = { acme = {
source = "vancluever/acme" source = "vancluever/acme"
version = ">= 2.0" version = ">= 2.0"
} }
} }
} }

View File

@ -11,16 +11,24 @@ provider "acme" {
server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" server_url = "https://acme-staging-v02.api.letsencrypt.org/directory"
} }
locals { locals {
identifier = var.identifier identifier = var.identifier
name = "tf-${local.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
} }
# AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively) # AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
module "this" { module "this" {
source = "../../" source = "../../"
vpc_name = local.name 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 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
security_group_name = local.name security_group_name = "${local.project_name}-sg"
security_group_type = "project" security_group_type = "project"
load_balancer_name = local.name load_balancer_name = "${local.project_name}-lb"
domain_use_strategy = "skip" domain_use_strategy = "skip"
} }

View File

@ -9,9 +9,13 @@ terraform {
source = "hashicorp/aws" source = "hashicorp/aws"
version = ">= 5.11" version = ">= 5.11"
} }
random = {
source = "hashicorp/random"
version = ">= 3.1"
}
acme = { acme = {
source = "vancluever/acme" source = "vancluever/acme"
version = ">= 2.0" version = ">= 2.0"
} }
} }
} }

View File

@ -11,15 +11,23 @@ provider "acme" {
server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" server_url = "https://acme-staging-v02.api.letsencrypt.org/directory"
} }
locals { locals {
identifier = var.identifier identifier = var.identifier
name = "tf-${local.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
} }
# AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively) # AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
module "this" { module "this" {
source = "../../" source = "../../"
vpc_name = local.name 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 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
security_group_name = local.name security_group_name = "${local.project_name}-sg"
security_group_type = "project" security_group_type = "project"
load_balancer_use_strategy = "skip" # everything depending on load balancer is skipped implicitly load_balancer_use_strategy = "skip" # everything depending on load balancer is skipped implicitly
} }

View File

@ -9,9 +9,13 @@ terraform {
source = "hashicorp/aws" source = "hashicorp/aws"
version = ">= 5.11" version = ">= 5.11"
} }
random = {
source = "hashicorp/random"
version = ">= 3.1"
}
acme = { acme = {
source = "vancluever/acme" source = "vancluever/acme"
version = ">= 2.0" version = ">= 2.0"
} }
} }
} }

View File

@ -12,15 +12,23 @@ provider "acme" {
} }
locals { locals {
identifier = var.identifier identifier = var.identifier
name = "tf-${local.identifier}" example = "selectvpc"
zone = var.zone project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 0, 5)}-${local.identifier}"
domain = "${local.identifier}.${local.zone}" 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" { module "setup" {
source = "../../" source = "../../"
vpc_name = local.name vpc_name = "${local.project_name}-vpc"
vpc_cidr = "10.0.255.0/24" vpc_cidr = "10.0.255.0/24"
subnet_use_strategy = "skip" subnet_use_strategy = "skip"
} }
@ -32,8 +40,8 @@ module "this" {
source = "../../" source = "../../"
vpc_use_strategy = "select" vpc_use_strategy = "select"
vpc_name = module.setup.vpc.tags.Name vpc_name = module.setup.vpc.tags.Name
security_group_name = local.name security_group_name = "${local.project_name}-sg"
security_group_type = "egress" security_group_type = "egress"
load_balancer_name = local.name load_balancer_name = "${local.project_name}-lb"
domain = local.domain domain = local.domain
} }

View File

@ -9,9 +9,13 @@ terraform {
source = "hashicorp/aws" source = "hashicorp/aws"
version = ">= 5.11" version = ">= 5.11"
} }
random = {
source = "hashicorp/random"
version = ">= 3.1"
}
acme = { acme = {
source = "vancluever/acme" source = "vancluever/acme"
version = ">= 2.0" version = ">= 2.0"
} }
} }
} }

View File

@ -9,9 +9,13 @@ terraform {
source = "hashicorp/aws" source = "hashicorp/aws"
version = ">= 5.11" version = ">= 5.11"
} }
random = {
source = "hashicorp/random"
version = ">= 3.1"
}
acme = { acme = {
source = "vancluever/acme" source = "vancluever/acme"
version = ">= 2.0" version = ">= 2.0"
} }
} }
} }

View File

@ -11,13 +11,21 @@ provider "acme" {
server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" server_url = "https://acme-staging-v02.api.letsencrypt.org/directory"
} }
locals { locals {
identifier = var.identifier identifier = var.identifier
name = "tf-${local.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
} }
# AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively) # AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
module "this" { module "this" {
source = "../../" source = "../../"
vpc_name = local.name 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 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 = { subnets = {
"subnetA" = { "subnetA" = {

View File

@ -9,9 +9,13 @@ terraform {
source = "hashicorp/aws" source = "hashicorp/aws"
version = ">= 5.11" version = ">= 5.11"
} }
random = {
source = "hashicorp/random"
version = ">= 3.1"
}
acme = { acme = {
source = "vancluever/acme" source = "vancluever/acme"
version = ">= 2.0" version = ">= 2.0"
} }
} }
} }

View File

@ -11,13 +11,21 @@ provider "acme" {
server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" server_url = "https://acme-staging-v02.api.letsencrypt.org/directory"
} }
locals { locals {
identifier = var.identifier identifier = var.identifier
name = "tf-${local.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
} }
# AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively) # AWS reserves the first four IP addresses and the last IP address in any CIDR block for its own use (cumulatively)
module "this" { module "this" {
source = "../../" source = "../../"
vpc_name = local.name 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 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
subnet_use_strategy = "skip" # everything depending on subnet is skipped implicitly subnet_use_strategy = "skip" # everything depending on subnet is skipped implicitly
} }

View File

@ -9,9 +9,13 @@ terraform {
source = "hashicorp/aws" source = "hashicorp/aws"
version = ">= 5.11" version = ">= 5.11"
} }
random = {
source = "hashicorp/random"
version = ">= 3.1"
}
acme = { acme = {
source = "vancluever/acme" source = "vancluever/acme"
version = ">= 2.0" version = ">= 2.0"
} }
} }
} }