From 44fa2dffc805f46caf3f2eb18661f3d0c71d4861 Mon Sep 17 00:00:00 2001 From: wellsiau-aws Date: Wed, 20 Dec 2023 12:53:53 -0800 Subject: [PATCH] use name instead of random-id --- .../01-getting-started/.auto.tfvars.example | 5 ++++ blueprints/01-getting-started/main.tf | 13 +++----- blueprints/01-getting-started/variables.tf | 30 +++++++++++++++++++ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/blueprints/01-getting-started/.auto.tfvars.example b/blueprints/01-getting-started/.auto.tfvars.example index e64e6a2b..2e3ed620 100644 --- a/blueprints/01-getting-started/.auto.tfvars.example +++ b/blueprints/01-getting-started/.auto.tfvars.example @@ -1,3 +1,5 @@ +# name = "random-id" # Optional, enter unique name / random id here +region = "us-east-1" # Required, change this according to your target region domain_name = "example.domain.com" # Required. Domain name used by the CloudBees CI instance. temp_license = { # Required. Temporary license details. @@ -12,3 +14,6 @@ temp_license = { # Required. Temporary license details. # "cb-user" : "crodriguezlopez" # "cb-environment" : "demo" # } + +# k8s_version = "1.27" Optional +# vpc_cidr = "10.0.0.0/16" Optional \ No newline at end of file diff --git a/blueprints/01-getting-started/main.tf b/blueprints/01-getting-started/main.tf index 63447fc4..a3fc59eb 100644 --- a/blueprints/01-getting-started/main.tf +++ b/blueprints/01-getting-started/main.tf @@ -5,18 +5,18 @@ data "aws_route53_zone" "this" { data "aws_availability_zones" "available" {} locals { - name = "cbci-bp01-i${random_integer.ramdom_id.result}" - region = "us-east-1" + name = "cbci-bp-${var.name}" + region = var.region vpc_name = "${local.name}-vpc" cluster_name = "${local.name}-eks" kubeconfig_file = "kubeconfig_${local.name}.yaml" kubeconfig_file_path = abspath("${path.root}/${local.kubeconfig_file}") - vpc_cidr = "10.0.0.0/16" + vpc_cidr = var.vpc_cidr #https://docs.cloudbees.com/docs/cloudbees-common/latest/supported-platforms/cloudbees-ci-cloud#_kubernetes - k8s_version = "1.26" + k8s_version = var.k8s_version route53_zone_id = data.aws_route53_zone.this.id route53_zone_arn = data.aws_route53_zone.this.arn @@ -31,11 +31,6 @@ locals { }) } -resource "random_integer" "ramdom_id" { - min = 1 - max = 999 -} - ################################################################################ # EKS: Add-ons ################################################################################ diff --git a/blueprints/01-getting-started/variables.tf b/blueprints/01-getting-started/variables.tf index 1e7610c8..e2fa9651 100644 --- a/blueprints/01-getting-started/variables.tf +++ b/blueprints/01-getting-started/variables.tf @@ -1,3 +1,17 @@ +variable "name" { + description = "Unique name to be assigned to all resources" + default = "" + type = string +} + +variable "region" { + description = "The region from which this module will be executed." + type = string + validation { + condition = can(regex("(us(-gov)?|ap|ca|cn|eu|sa)-(central|(north|south)?(east|west)?)-\\d", var.region)) + error_message = "Variable var: region is not valid." + } +} variable "tags" { description = "Tags to apply to resources" @@ -18,3 +32,19 @@ variable "temp_license" { description = "Temporary license details" type = map(string) } + +variable "k8s_version" { + description = "EKS cluster version, refer to: https://docs.cloudbees.com/docs/cloudbees-common/latest/supported-platforms/cloudbees-ci-cloud#_kubernetes " + type = string + default = "1.26" +} + +variable "vpc_cidr" { + description = "CIDR for the EKS cluster VPC" + type = string + default = "10.0.0.0/16" + validation { + condition = can(cidrhost(var.vpc_cidr, 0)) + error_message = "Must be valid IPv4 CIDR." + } +} \ No newline at end of file