diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 0a5b89a..89f7a0f 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -11,18 +11,26 @@ provider "acme" { server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" } locals { - identifier = var.identifier - name = "tf-${local.identifier}" - zone = var.zone - domain = "${local.identifier}.${local.zone}" + identifier = var.identifier + example = "basic" + project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 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 = "../../" - 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 - security_group_name = local.name + security_group_name = "${local.project_name}-sg" security_group_type = "egress" - load_balancer_name = local.name + load_balancer_name = "${local.project_name}-lb" domain = local.domain } diff --git a/examples/basic/versions.tf b/examples/basic/versions.tf index 1399985..ee03d75 100644 --- a/examples/basic/versions.tf +++ b/examples/basic/versions.tf @@ -9,9 +9,13 @@ terraform { source = "hashicorp/aws" version = ">= 5.11" } + random = { + source = "hashicorp/random" + version = ">= 3.1" + } acme = { source = "vancluever/acme" version = ">= 2.0" } } -} \ No newline at end of file +} diff --git a/examples/domain/main.tf b/examples/domain/main.tf index 2d04be1..3d577ae 100644 --- a/examples/domain/main.tf +++ b/examples/domain/main.tf @@ -11,21 +11,29 @@ provider "acme" { server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" } locals { - identifier = var.identifier - name = "tf-${local.identifier}" - owner = "terraform-ci@suse.com" - zone = var.zone - domain = "${local.identifier}.${local.zone}" + identifier = var.identifier + example = "domain" + project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 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 = "../../" - 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 - security_group_name = local.name + security_group_name = "${local.project_name}-sg" security_group_type = "project" - load_balancer_name = local.name + load_balancer_name = "${local.project_name}-lb" domain = local.domain #domain_zone = local.zone # only specify when creating a new zone } diff --git a/examples/domain/versions.tf b/examples/domain/versions.tf index 1399985..ee03d75 100644 --- a/examples/domain/versions.tf +++ b/examples/domain/versions.tf @@ -9,9 +9,13 @@ terraform { source = "hashicorp/aws" version = ">= 5.11" } + random = { + source = "hashicorp/random" + version = ">= 3.1" + } acme = { source = "vancluever/acme" version = ">= 2.0" } } -} \ No newline at end of file +} diff --git a/examples/ingress/main.tf b/examples/ingress/main.tf index 007c1e3..7067519 100644 --- a/examples/ingress/main.tf +++ b/examples/ingress/main.tf @@ -12,20 +12,28 @@ provider "acme" { #server_url = "https://acme-v02.api.letsencrypt.org/directory" # use this url in production } locals { - identifier = var.identifier - name = "tf-${local.identifier}" - zone = var.zone - domain = "${local.identifier}.${local.zone}" + identifier = var.identifier + example = "ingress" + project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 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 = "../../" - 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 - security_group_name = local.name + security_group_name = "${local.project_name}-sg" security_group_type = "egress" domain = local.domain - load_balancer_name = local.name + load_balancer_name = "${local.project_name}-lb" load_balancer_access_cidrs = { application = { port = 443 diff --git a/examples/ingress/versions.tf b/examples/ingress/versions.tf index 1399985..ee03d75 100644 --- a/examples/ingress/versions.tf +++ b/examples/ingress/versions.tf @@ -9,9 +9,13 @@ terraform { source = "hashicorp/aws" version = ">= 5.11" } + random = { + source = "hashicorp/random" + version = ">= 3.1" + } acme = { source = "vancluever/acme" version = ">= 2.0" } } -} \ No newline at end of file +} diff --git a/examples/loadbalancer/main.tf b/examples/loadbalancer/main.tf index c23f80d..f06e7f8 100644 --- a/examples/loadbalancer/main.tf +++ b/examples/loadbalancer/main.tf @@ -11,16 +11,24 @@ provider "acme" { server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" } locals { - identifier = var.identifier - name = "tf-${local.identifier}" + 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 } # 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.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 - security_group_name = local.name + security_group_name = "${local.project_name}-sg" security_group_type = "project" - load_balancer_name = local.name + load_balancer_name = "${local.project_name}-lb" domain_use_strategy = "skip" } diff --git a/examples/loadbalancer/versions.tf b/examples/loadbalancer/versions.tf index 1399985..ee03d75 100644 --- a/examples/loadbalancer/versions.tf +++ b/examples/loadbalancer/versions.tf @@ -9,9 +9,13 @@ terraform { source = "hashicorp/aws" version = ">= 5.11" } + random = { + source = "hashicorp/random" + version = ">= 3.1" + } acme = { source = "vancluever/acme" version = ">= 2.0" } } -} \ No newline at end of file +} diff --git a/examples/securitygroup/main.tf b/examples/securitygroup/main.tf index ce86a27..6e99a32 100644 --- a/examples/securitygroup/main.tf +++ b/examples/securitygroup/main.tf @@ -11,15 +11,23 @@ provider "acme" { server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" } locals { - identifier = var.identifier - name = "tf-${local.identifier}" + 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 } # 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.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 - security_group_name = local.name + security_group_name = "${local.project_name}-sg" security_group_type = "project" load_balancer_use_strategy = "skip" # everything depending on load balancer is skipped implicitly } diff --git a/examples/securitygroup/versions.tf b/examples/securitygroup/versions.tf index 1399985..ee03d75 100644 --- a/examples/securitygroup/versions.tf +++ b/examples/securitygroup/versions.tf @@ -9,9 +9,13 @@ terraform { source = "hashicorp/aws" version = ">= 5.11" } + random = { + source = "hashicorp/random" + version = ">= 3.1" + } acme = { source = "vancluever/acme" version = ">= 2.0" } } -} \ No newline at end of file +} diff --git a/examples/selectvpc/main.tf b/examples/selectvpc/main.tf index 7b9cbd1..7a7ddf6 100644 --- a/examples/selectvpc/main.tf +++ b/examples/selectvpc/main.tf @@ -12,15 +12,23 @@ provider "acme" { } locals { - identifier = var.identifier - name = "tf-${local.identifier}" - zone = var.zone - domain = "${local.identifier}.${local.zone}" + identifier = var.identifier + example = "selectvpc" + project_name = "tf-${substr(md5(join("-", [local.example, random_pet.string.id])), 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 = "../../" - vpc_name = local.name + vpc_name = "${local.project_name}-vpc" vpc_cidr = "10.0.255.0/24" subnet_use_strategy = "skip" } @@ -32,8 +40,8 @@ module "this" { source = "../../" vpc_use_strategy = "select" vpc_name = module.setup.vpc.tags.Name - security_group_name = local.name + security_group_name = "${local.project_name}-sg" security_group_type = "egress" - load_balancer_name = local.name + load_balancer_name = "${local.project_name}-lb" domain = local.domain } diff --git a/examples/selectvpc/versions.tf b/examples/selectvpc/versions.tf index 1399985..ee03d75 100644 --- a/examples/selectvpc/versions.tf +++ b/examples/selectvpc/versions.tf @@ -9,9 +9,13 @@ terraform { source = "hashicorp/aws" version = ">= 5.11" } + random = { + source = "hashicorp/random" + version = ">= 3.1" + } acme = { source = "vancluever/acme" version = ">= 2.0" } } -} \ No newline at end of file +} diff --git a/examples/skipvpc/versions.tf b/examples/skipvpc/versions.tf index 1399985..ee03d75 100644 --- a/examples/skipvpc/versions.tf +++ b/examples/skipvpc/versions.tf @@ -9,9 +9,13 @@ terraform { source = "hashicorp/aws" version = ">= 5.11" } + random = { + source = "hashicorp/random" + version = ">= 3.1" + } acme = { source = "vancluever/acme" version = ">= 2.0" } } -} \ No newline at end of file +} diff --git a/examples/subnets/main.tf b/examples/subnets/main.tf index c72e61a..e3fb4a1 100644 --- a/examples/subnets/main.tf +++ b/examples/subnets/main.tf @@ -11,13 +11,21 @@ provider "acme" { server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" } locals { - identifier = var.identifier - name = "tf-${local.identifier}" + 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 } # 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.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 subnets = { "subnetA" = { diff --git a/examples/subnets/versions.tf b/examples/subnets/versions.tf index 1399985..ee03d75 100644 --- a/examples/subnets/versions.tf +++ b/examples/subnets/versions.tf @@ -9,9 +9,13 @@ terraform { source = "hashicorp/aws" version = ">= 5.11" } + random = { + source = "hashicorp/random" + version = ">= 3.1" + } acme = { source = "vancluever/acme" version = ">= 2.0" } } -} \ No newline at end of file +} diff --git a/examples/vpc/main.tf b/examples/vpc/main.tf index 66539a7..338b722 100644 --- a/examples/vpc/main.tf +++ b/examples/vpc/main.tf @@ -11,13 +11,21 @@ provider "acme" { server_url = "https://acme-staging-v02.api.letsencrypt.org/directory" } locals { - identifier = var.identifier - name = "tf-${local.identifier}" + 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 } # 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.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 subnet_use_strategy = "skip" # everything depending on subnet is skipped implicitly } diff --git a/examples/vpc/versions.tf b/examples/vpc/versions.tf index 1399985..ee03d75 100644 --- a/examples/vpc/versions.tf +++ b/examples/vpc/versions.tf @@ -9,9 +9,13 @@ terraform { source = "hashicorp/aws" version = ">= 5.11" } + random = { + source = "hashicorp/random" + version = ">= 3.1" + } acme = { source = "vancluever/acme" version = ">= 2.0" } } -} \ No newline at end of file +}