Skip to content

Commit

Permalink
feat: implement choice of AZs (#99)
Browse files Browse the repository at this point in the history
* feat: implement choice of AZs

This PR introduce a choice for the AWS AZs, it's backward compatible,
and implement both the AZs definition in the VPC and the ROSA Cluster
itself

Related to
camunda/team-infrastructure-experience#411

* chore: add desc
  • Loading branch information
leiicamundi authored Nov 12, 2024
1 parent 335ff08 commit bfe79a2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 3 additions & 1 deletion modules/rosa-hcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_availability_zones_count"></a> [availability\_zones\_count](#input\_availability\_zones\_count) | The number of availability zones to use for the cluster (minimum 2) | `number` | `2` | no |
| <a name="input_availability_zones"></a> [availability\_zones](#input\_availability\_zones) | A list of availability zone names in the region. By default, this is set to `null` and is not used; instead, `availability_zones_count` manages the number of availability zones. This value should not be updated directly. To make changes, please create a new resource. | `list(string)` | `null` | no |
| <a name="input_availability_zones_count"></a> [availability\_zones\_count](#input\_availability\_zones\_count) | The count of availability (minimum 2) zones to utilize within the specified AWS Region, where pairs of public and private subnets will be generated. Valid only when availability\_zones variable is not provided. This value should not be updated, please create a new resource instead. | `number` | `2` | no |
| <a name="input_aws_availability_zones"></a> [aws\_availability\_zones](#input\_aws\_availability\_zones) | The AWS availability zones where instances of the default worker machine pool are deployed. Leave empty for the installer to pick availability zones from the VPC `availability_zones` or `availability_zones_count` | `list(string)` | `[]` | no |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The name of the ROSA cluster to create | `string` | `"my-ocp-cluster"` | no |
| <a name="input_compute_node_instance_type"></a> [compute\_node\_instance\_type](#input\_compute\_node\_instance\_type) | The EC2 instance type to use for compute nodes | `string` | `"m5.xlarge"` | no |
| <a name="input_host_prefix"></a> [host\_prefix](#input\_host\_prefix) | The subnet mask to assign to each compute node in the cluster | `string` | `"23"` | no |
Expand Down
9 changes: 6 additions & 3 deletions modules/rosa-hcp/rosa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ module "rosa_hcp" {


replicas = var.replicas
aws_availability_zones = module.vpc.availability_zones
aws_availability_zones = length(var.aws_availability_zones) > 0 ? var.aws_availability_zones : module.vpc.availability_zones

aws_subnet_ids = concat(
module.vpc.public_subnets, module.vpc.private_subnets,
)
Expand Down Expand Up @@ -61,8 +62,10 @@ module "vpc" {
source = "terraform-redhat/rosa-hcp/rhcs//modules/vpc"
version = "1.6.5"

name_prefix = var.cluster_name
availability_zones_count = var.availability_zones_count
name_prefix = var.cluster_name

availability_zones_count = var.availability_zones != null ? null : var.availability_zones_count
availability_zones = var.availability_zones

vpc_cidr = var.vpc_cidr_block
}
15 changes: 14 additions & 1 deletion modules/rosa-hcp/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,23 @@ variable "offline_access_token" {

variable "availability_zones_count" {
type = number
description = "The number of availability zones to use for the cluster (minimum 2)"
description = "The count of availability (minimum 2) zones to utilize within the specified AWS Region, where pairs of public and private subnets will be generated. Valid only when availability_zones variable is not provided. This value should not be updated, please create a new resource instead."
default = 2
}

variable "availability_zones" {
type = list(string)
description = "A list of availability zone names in the region. By default, this is set to `null` and is not used; instead, `availability_zones_count` manages the number of availability zones. This value should not be updated directly. To make changes, please create a new resource."
default = null
}


variable "aws_availability_zones" {
type = list(string)
description = "The AWS availability zones where instances of the default worker machine pool are deployed. Leave empty for the installer to pick availability zones from the VPC `availability_zones` or `availability_zones_count`"
default = []
}

variable "vpc_cidr_block" {
type = string
description = "value of the CIDR block to use for the VPC"
Expand Down

0 comments on commit bfe79a2

Please sign in to comment.