Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterized name as suffix for all resources tag #31

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions blueprints/01-getting-started/.auto.tfvars.example
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
13 changes: 4 additions & 9 deletions blueprints/01-getting-started/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions:

1.- Replace cbci-bp-${var.name} by cbci-bp01${local.name}. Note cbci-bp01 ==> it refers to CBCI Blueprints 01 (getting started). It does nothing to do with random
2.- Add to locals

locals {
      name  = var.name == "" ? "" : "-${var.name}"
}

3.- Please, repeat the same approach for cbci-bp02${local.name}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, I will add the suggestion

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
Expand All @@ -31,11 +31,6 @@ locals {
})
}

resource "random_integer" "ramdom_id" {
min = 1
max = 999
}

################################################################################
# EKS: Add-ons
################################################################################
Expand Down
30 changes: 30 additions & 0 deletions blueprints/01-getting-started/variables.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -18,3 +32,19 @@ variable "temp_license" {
description = "Temporary license details"
type = map(string)
}

variable "k8s_version" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wellsiau-aws I believe that K8 version is best to not be parametrised in alignment with the EKS Addons v5 https://github.com/aws-ia/terraform-aws-eks-blueprints-addons/blob/main/tests/complete/main.tf#L65 and blueprints patterns https://github.com/aws-ia/terraform-aws-eks-blueprints/blob/main/patterns/stateful/main.tf#L6 in benefit of maintenance and its support.

It is aligned with Blueprints Terraform caveats that differs from AWS Quickstart approach. In the second there were many parameters to be configured (including passing your existing VPC in our old CloudBees CI which makes things more complicated to maintain).

Consecutive releases of this addons increase the version of the K8s as well as the CloudBees CI charts https://github.com/cloudbees/terraform-aws-cloudbees-ci-eks-addon/blob/main/main.tf#L12 ==> That version bump requires to be tested and validated. Leaving the K8s version as variable could lead to a situation not tested and frustration for end-user.

Note: At the end blueprints are seen as pattern but users can modify locals for their requirements at their own risk (assuming they know what they are doing).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable makes it easier for user to run test without modifying the underlying .tf files.

That said, I recognized the concern of externalizing other cluster / EKS level attributes, which are not the purpose of this reference blueprint.

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" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wellsiau-aws I personally believe that CIDR for the EKS cluster VPC is best to not be parametrised in alignment with the EKS Addons v5 https://github.com/aws-ia/terraform-aws-eks-blueprints-addons/blob/main/tests/complete/main.tf#L47 and blueprints patterns https://github.com/aws-ia/terraform-aws-eks-blueprints/blob/main/patterns/stateful/main.tf#L38 in benefit of maintenance.

As it was said before, it is aligned with Blueprints Terraform caveats that differs from AWS Quickstart approach.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

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."
}
}
Loading