diff --git a/modules/infra/aws/ec2/data.tf b/modules/infra/aws/ec2/data.tf index 96587eb..43e4595 100644 --- a/modules/infra/aws/ec2/data.tf +++ b/modules/infra/aws/ec2/data.tf @@ -1,31 +1,8 @@ -# TODO: Make the Ubuntu OS version configurable # TODO: Add support for ARM architecture -data "aws_ami" "ubuntu" { - most_recent = true - owners = ["099720109477"] # Canonical - - filter { - name = "name" - values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] - } - - filter { - name = "virtualization-type" - values = ["hvm"] - } +data "aws_ssm_parameter" "sles" { + name = "/aws/service/suse/sles-byos/${var.sles_version}/x86_64/latest" } -data "aws_ami" "sles" { - most_recent = true - owners = ["679593333241"] # SUSE - - filter { - name = "name" - values = ["suse-sles-15-sp6-byos-*-hvm-ssd-x86_64-*"] - } - - filter { - name = "virtualization-type" - values = ["hvm"] - } +data "aws_ssm_parameter" "ubuntu" { + name = "/aws/service/canonical/ubuntu/server/${var.ubuntu_version}/stable/current/amd64/hvm/ebs-gp2/ami-id" } \ No newline at end of file diff --git a/modules/infra/aws/ec2/docs.md b/modules/infra/aws/ec2/docs.md index 071a4ce..23d73fb 100644 --- a/modules/infra/aws/ec2/docs.md +++ b/modules/infra/aws/ec2/docs.md @@ -25,8 +25,8 @@ No modules. | [aws_security_group.sg_allowall](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource | | [local_file.private_key_pem](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | | [tls_private_key.ssh_private_key](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) | resource | -| [aws_ami.sles](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | -| [aws_ami.ubuntu](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | +| [aws_ssm_parameter.sles](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source | +| [aws_ssm_parameter.ubuntu](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source | ## Inputs @@ -46,6 +46,7 @@ No modules. | [instance\_type](#input\_instance\_type) | Instance type used for all EC2 instances | `string` | `"t3.medium"` | no | | [os\_type](#input\_os\_type) | Use SLES or Ubuntu images when launching instances (sles or ubuntu) | `string` | `"sles"` | no | | [prefix](#input\_prefix) | Prefix added to names of all resources | `string` | `"rancher-terraform"` | no | +| [sles\_version](#input\_sles\_version) | Version of SLES to use for instances (ex: 15-sp6) | `string` | `"15-sp6"` | no | | [spot\_instances](#input\_spot\_instances) | Use spot instances | `bool` | `false` | no | | [ssh\_key](#input\_ssh\_key) | Contents of the private key to connect to the instances. | `string` | `null` | no | | [ssh\_key\_pair\_name](#input\_ssh\_key\_pair\_name) | Specify the SSH key name to use (that's already present in AWS) | `string` | `null` | no | @@ -55,6 +56,7 @@ No modules. | [subnet\_id](#input\_subnet\_id) | VPC Subnet ID to create the instance(s) in | `string` | `null` | no | | [tag\_begin](#input\_tag\_begin) | When module is being called mode than once, begin tagging from this number | `number` | `1` | no | | [tags](#input\_tags) | User-provided tags for the resources | `map(string)` | `{}` | no | +| [ubuntu\_version](#input\_ubuntu\_version) | Version of Ubuntu to use for instances (ex: 22.04) | `string` | `"22.04"` | no | | [user\_data](#input\_user\_data) | User data content for EC2 instance(s) | `any` | `null` | no | | [vpc\_id](#input\_vpc\_id) | VPC ID to create the instance(s) in | `string` | `null` | no | diff --git a/modules/infra/aws/ec2/main.tf b/modules/infra/aws/ec2/main.tf index 10fca06..6224088 100644 --- a/modules/infra/aws/ec2/main.tf +++ b/modules/infra/aws/ec2/main.tf @@ -82,11 +82,10 @@ resource "aws_security_group" "sg_allowall" { } resource "aws_instance" "instance" { - count = var.instance_count - ami = var.instance_ami != null ? var.instance_ami : var.os_type == "sles" ? data.aws_ami.sles.id : data.aws_ami.ubuntu.id - instance_type = var.instance_type - subnet_id = var.subnet_id - + count = var.instance_count + ami = var.instance_ami != null ? var.instance_ami : var.os_type == "sles" ? data.aws_ssm_parameter.sles.insecure_value : data.aws_ssm_parameter.ubuntu.insecure_value + instance_type = var.instance_type + subnet_id = var.subnet_id key_name = var.create_ssh_key_pair ? aws_key_pair.key_pair[0].key_name : var.ssh_key_pair_name vpc_security_group_ids = [var.create_security_group ? aws_security_group.sg_allowall[0].id : var.instance_security_group] user_data = var.user_data diff --git a/modules/infra/aws/ec2/variables.tf b/modules/infra/aws/ec2/variables.tf index 2feae0d..261bdbe 100644 --- a/modules/infra/aws/ec2/variables.tf +++ b/modules/infra/aws/ec2/variables.tf @@ -80,7 +80,7 @@ variable "instance_disk_size" { variable "instance_count" { type = number description = "Number of EC2 instances to create" - default = 1 + default = 0 nullable = false } @@ -100,6 +100,16 @@ variable "os_type" { } } +variable "sles_version" { + description = "Version of SLES to use for instances (ex: 15-sp6)" + default = "15-sp6" +} + +variable "ubuntu_version" { + description = "Version of Ubuntu to use for instances (ex: 22.04)" + default = "22.04" +} + variable "vpc_id" { type = string description = "VPC ID to create the instance(s) in" diff --git a/recipes/rke/split-roles/aws/docs.md b/recipes/rke/split-roles/aws/docs.md index f1904cd..e8339cd 100644 --- a/recipes/rke/split-roles/aws/docs.md +++ b/recipes/rke/split-roles/aws/docs.md @@ -45,12 +45,14 @@ No resources. | [master\_nodes\_instance\_type](#input\_master\_nodes\_instance\_type) | Instance type used for all master nodes | `string` | `"t3.medium"` | no | | [os\_type](#input\_os\_type) | Use SLES or Ubuntu images when launching instances (sles or ubuntu) | `string` | `null` | no | | [prefix](#input\_prefix) | Prefix added to names of all resources | `string` | n/a | yes | +| [sles\_version](#input\_sles\_version) | Version of SLES to use for instances (ex: 15-sp6) | `string` | `"15-sp6"` | no | | [ssh\_key](#input\_ssh\_key) | Contents of the private key to connect to the instances. | `string` | `null` | no | | [ssh\_key\_pair\_name](#input\_ssh\_key\_pair\_name) | Specify the SSH key name to use (that's already present in AWS) | `string` | `null` | no | | [ssh\_key\_pair\_path](#input\_ssh\_key\_pair\_path) | Path to the SSH private key used as the key pair (that's already present in AWS) | `string` | `null` | no | | [ssh\_username](#input\_ssh\_username) | Username used for SSH with sudo access, must align with the AMI in use | `string` | `null` | no | | [subnet\_id](#input\_subnet\_id) | VPC Subnet ID to create the instance(s) in | `string` | `null` | no | | [tags](#input\_tags) | User-provided tags for the resources | `map(string)` | `{}` | no | +| [ubuntu\_version](#input\_ubuntu\_version) | Version of Ubuntu to use for instances (ex: 22.04) | `string` | `"22.04"` | no | | [vpc\_id](#input\_vpc\_id) | VPC ID to create the instance(s) in | `string` | `null` | no | | [vpc\_zone](#input\_vpc\_zone) | VPC zone | `string` | `null` | no | | [worker\_nodes\_count](#input\_worker\_nodes\_count) | Number of worker nodes to create | `number` | `1` | no | diff --git a/recipes/rke/split-roles/aws/main.tf b/recipes/rke/split-roles/aws/main.tf index 950bf63..054129e 100644 --- a/recipes/rke/split-roles/aws/main.tf +++ b/recipes/rke/split-roles/aws/main.tf @@ -11,6 +11,8 @@ module "master_nodes" { instance_disk_size = var.master_nodes_instance_disk_size instance_ami = var.instance_ami os_type = var.os_type + sles_version = var.sles_version + ubuntu_version = var.ubuntu_version create_ssh_key_pair = var.create_ssh_key_pair ssh_key_pair_name = var.ssh_key_pair_name ssh_key_pair_path = var.ssh_key_pair_path @@ -43,6 +45,8 @@ module "worker_nodes" { instance_disk_size = var.worker_nodes_instance_disk_size instance_ami = var.instance_ami os_type = var.os_type + sles_version = var.sles_version + ubuntu_version = var.ubuntu_version create_ssh_key_pair = var.create_ssh_key_pair ssh_key_pair_name = var.ssh_key_pair_name ssh_key_pair_path = var.ssh_key_pair_path diff --git a/recipes/rke/split-roles/aws/terraform.tfvars.example b/recipes/rke/split-roles/aws/terraform.tfvars.example index 73be402..f59772e 100644 --- a/recipes/rke/split-roles/aws/terraform.tfvars.example +++ b/recipes/rke/split-roles/aws/terraform.tfvars.example @@ -37,6 +37,9 @@ worker_nodes_count = 1 ### -- Use SLES or Ubuntu images when launching instances (sles or ubuntu) # os_type = "sles" +# sles_version = "15-sp6" +# ubuntu_version = "22.04" + ## - SSH username (must match the SSH user for the AMI used) # ssh_username = "ec2-user" ## - Custom AMI to launch instances with diff --git a/recipes/rke/split-roles/aws/variables.tf b/recipes/rke/split-roles/aws/variables.tf index 8cc7c57..12198c8 100644 --- a/recipes/rke/split-roles/aws/variables.tf +++ b/recipes/rke/split-roles/aws/variables.tf @@ -152,6 +152,16 @@ variable "os_type" { default = null } +variable "sles_version" { + description = "Version of SLES to use for instances (ex: 15-sp6)" + default = "15-sp6" +} + +variable "ubuntu_version" { + description = "Version of Ubuntu to use for instances (ex: 22.04)" + default = "22.04" +} + variable "master_nodes_instance_type" { type = string description = "Instance type used for all master nodes" diff --git a/recipes/standalone/aws/rke/docs.md b/recipes/standalone/aws/rke/docs.md index 1f31b76..7f7f39a 100644 --- a/recipes/standalone/aws/rke/docs.md +++ b/recipes/standalone/aws/rke/docs.md @@ -39,11 +39,13 @@ No resources. | [kubernetes\_version](#input\_kubernetes\_version) | Kubernetes version to use for the RKE cluster | `string` | `null` | no | | [os\_type](#input\_os\_type) | Use SLES or Ubuntu images when launching instances (sles or ubuntu) | `string` | `null` | no | | [prefix](#input\_prefix) | Prefix added to names of all resources | `string` | `null` | no | +| [sles\_version](#input\_sles\_version) | Version of SLES to use for instances (ex: 15-sp6) | `string` | `"15-sp6"` | no | | [spot\_instances](#input\_spot\_instances) | Use spot instances | `bool` | `null` | no | | [ssh\_key\_pair\_name](#input\_ssh\_key\_pair\_name) | Specify the SSH key name to use (that's already present in AWS) | `string` | `null` | no | | [ssh\_key\_pair\_path](#input\_ssh\_key\_pair\_path) | Path to the SSH private key used as the key pair (that's already present in AWS) | `string` | `null` | no | | [ssh\_username](#input\_ssh\_username) | Username used for SSH with sudo access, must align with the AMI in use | `string` | `null` | no | | [subnet\_id](#input\_subnet\_id) | VPC Subnet ID to create the instance(s) in | `string` | `null` | no | +| [ubuntu\_version](#input\_ubuntu\_version) | Version of Ubuntu to use for instances (ex: 22.04) | `string` | `"22.04"` | no | ## Outputs diff --git a/recipes/standalone/aws/rke/main.tf b/recipes/standalone/aws/rke/main.tf index 3a3f7b6..590fe11 100644 --- a/recipes/standalone/aws/rke/main.tf +++ b/recipes/standalone/aws/rke/main.tf @@ -10,6 +10,8 @@ module "cluster-nodes" { instance_disk_size = var.instance_disk_size instance_ami = var.instance_ami os_type = var.os_type + sles_version = var.sles_version + ubuntu_version = var.ubuntu_version create_ssh_key_pair = var.create_ssh_key_pair ssh_key_pair_name = var.ssh_key_pair_name ssh_key_pair_path = var.ssh_key_pair_path diff --git a/recipes/standalone/aws/rke/terraform.tfvars.example b/recipes/standalone/aws/rke/terraform.tfvars.example index a104adc..1a483d9 100644 --- a/recipes/standalone/aws/rke/terraform.tfvars.example +++ b/recipes/standalone/aws/rke/terraform.tfvars.example @@ -35,6 +35,9 @@ instance_count = 1 ### -- Use SLES or Ubuntu images when launching instances (sles or ubuntu) # os_type = "sles" +# sles_version = "15-sp6" +# ubuntu_version = "22.04" + ## - SSH username (must match the SSH user for the AMI used) # ssh_username = "ec2-user" ## - Custom AMI to launch instances with diff --git a/recipes/standalone/aws/rke/variables.tf b/recipes/standalone/aws/rke/variables.tf index b6d0866..973d1ac 100644 --- a/recipes/standalone/aws/rke/variables.tf +++ b/recipes/standalone/aws/rke/variables.tf @@ -152,6 +152,16 @@ variable "os_type" { default = null } +variable "sles_version" { + description = "Version of SLES to use for instances (ex: 15-sp6)" + default = "15-sp6" +} + +variable "ubuntu_version" { + description = "Version of Ubuntu to use for instances (ex: 22.04)" + default = "22.04" +} + variable "subnet_id" { type = string description = "VPC Subnet ID to create the instance(s) in" diff --git a/recipes/upstream/aws/k3s/docs.md b/recipes/upstream/aws/k3s/docs.md index 2778100..13e5b49 100644 --- a/recipes/upstream/aws/k3s/docs.md +++ b/recipes/upstream/aws/k3s/docs.md @@ -63,11 +63,13 @@ | [rancher\_replicas](#input\_rancher\_replicas) | Value for replicas when installing the Rancher helm chart | `number` | `3` | no | | [rancher\_version](#input\_rancher\_version) | Rancher version to install | `string` | `null` | no | | [server\_instance\_count](#input\_server\_instance\_count) | Number of server EC2 instances to create | `number` | `null` | no | +| [sles\_version](#input\_sles\_version) | Version of SLES to use for instances (ex: 15-sp6) | `string` | `"15-sp6"` | no | | [spot\_instances](#input\_spot\_instances) | Use spot instances | `bool` | `null` | no | | [ssh\_key\_pair\_name](#input\_ssh\_key\_pair\_name) | Specify the SSH key name to use (that's already present in AWS) | `string` | `null` | no | | [ssh\_key\_pair\_path](#input\_ssh\_key\_pair\_path) | Path to the SSH private key used as the key pair (that's already present in AWS) | `string` | `null` | no | | [ssh\_username](#input\_ssh\_username) | Username used for SSH with sudo access, must align with the AMI in use | `string` | `null` | no | | [subnet\_id](#input\_subnet\_id) | VPC Subnet ID to create the instance(s) in | `string` | `null` | no | +| [ubuntu\_version](#input\_ubuntu\_version) | Version of Ubuntu to use for instances (ex: 22.04) | `string` | `"22.04"` | no | | [wait](#input\_wait) | An optional wait before installing the Rancher helm chart | `string` | `"20s"` | no | | [worker\_instance\_count](#input\_worker\_instance\_count) | Number of worker EC2 instances to create | `number` | `null` | no | diff --git a/recipes/upstream/aws/k3s/main.tf b/recipes/upstream/aws/k3s/main.tf index 527d162..0b86324 100644 --- a/recipes/upstream/aws/k3s/main.tf +++ b/recipes/upstream/aws/k3s/main.tf @@ -21,6 +21,8 @@ module "k3s_first_server" { instance_disk_size = var.instance_disk_size instance_ami = var.instance_ami os_type = var.os_type + sles_version = var.sles_version + ubuntu_version = var.ubuntu_version create_ssh_key_pair = var.create_ssh_key_pair ssh_key_pair_name = var.ssh_key_pair_name ssh_key_pair_path = var.ssh_key_pair_path @@ -52,6 +54,8 @@ module "k3s_additional_servers" { instance_disk_size = var.instance_disk_size instance_ami = var.instance_ami os_type = var.os_type + sles_version = var.sles_version + ubuntu_version = var.ubuntu_version create_ssh_key_pair = false ssh_key_pair_name = module.k3s_first_server.ssh_key_pair_name ssh_key_pair_path = module.k3s_first_server.ssh_key_path @@ -75,6 +79,8 @@ module "k3s_workers" { instance_disk_size = var.instance_disk_size instance_ami = var.instance_ami os_type = var.os_type + sles_version = var.sles_version + ubuntu_version = var.ubuntu_version create_ssh_key_pair = false ssh_key_pair_name = module.k3s_first_server.ssh_key_pair_name ssh_key_pair_path = module.k3s_first_server.ssh_key_path diff --git a/recipes/upstream/aws/k3s/terraform.tfvars.example b/recipes/upstream/aws/k3s/terraform.tfvars.example index 9e99b40..7510fc3 100644 --- a/recipes/upstream/aws/k3s/terraform.tfvars.example +++ b/recipes/upstream/aws/k3s/terraform.tfvars.example @@ -40,6 +40,9 @@ worker_instance_count = 1 ### -- Use SLES or Ubuntu images when launching instances (sles or ubuntu) # os_type = "sles" +# sles_version = "15-sp6" +# ubuntu_version = "22.04" + ## - SSH username (must match the SSH user for the AMI used) # ssh_username = "ec2-user" ## - Custom AMI to launch instances with diff --git a/recipes/upstream/aws/k3s/variables.tf b/recipes/upstream/aws/k3s/variables.tf index 56b8f90..9407a6a 100644 --- a/recipes/upstream/aws/k3s/variables.tf +++ b/recipes/upstream/aws/k3s/variables.tf @@ -227,6 +227,16 @@ variable "os_type" { default = "sles" } +variable "sles_version" { + description = "Version of SLES to use for instances (ex: 15-sp6)" + default = "15-sp6" +} + +variable "ubuntu_version" { + description = "Version of Ubuntu to use for instances (ex: 22.04)" + default = "22.04" +} + variable "subnet_id" { type = string description = "VPC Subnet ID to create the instance(s) in" diff --git a/recipes/upstream/aws/rke/docs.md b/recipes/upstream/aws/rke/docs.md index 129f86d..3e960eb 100644 --- a/recipes/upstream/aws/rke/docs.md +++ b/recipes/upstream/aws/rke/docs.md @@ -49,11 +49,13 @@ No resources. | [rancher\_password](#input\_rancher\_password) | Password for the Rancher admin account (min 12 characters) | `string` | `null` | no | | [rancher\_replicas](#input\_rancher\_replicas) | Value for replicas when installing the Rancher helm chart | `number` | `3` | no | | [rancher\_version](#input\_rancher\_version) | Rancher version to install | `string` | `null` | no | +| [sles\_version](#input\_sles\_version) | Version of SLES to use for instances (ex: 15-sp6) | `string` | `"15-sp6"` | no | | [spot\_instances](#input\_spot\_instances) | Use spot instances | `bool` | `null` | no | | [ssh\_key\_pair\_name](#input\_ssh\_key\_pair\_name) | Specify the SSH key name to use (that's already present in AWS) | `string` | `null` | no | | [ssh\_key\_pair\_path](#input\_ssh\_key\_pair\_path) | Path to the SSH private key used as the key pair (that's already present in AWS) | `string` | `null` | no | | [ssh\_username](#input\_ssh\_username) | Username used for SSH with sudo access, must align with the AMI in use | `string` | `null` | no | | [subnet\_id](#input\_subnet\_id) | VPC Subnet ID to create the instance(s) in | `string` | `null` | no | +| [ubuntu\_version](#input\_ubuntu\_version) | Version of Ubuntu to use for instances (ex: 22.04) | `string` | `"22.04"` | no | | [wait](#input\_wait) | An optional wait before installing the Rancher helm chart | `string` | `"20s"` | no | ## Outputs diff --git a/recipes/upstream/aws/rke/main.tf b/recipes/upstream/aws/rke/main.tf index f3a1a86..f9a89b8 100644 --- a/recipes/upstream/aws/rke/main.tf +++ b/recipes/upstream/aws/rke/main.tf @@ -12,6 +12,8 @@ module "rke" { instance_disk_size = var.instance_disk_size instance_ami = var.instance_ami os_type = var.os_type + sles_version = var.sles_version + ubuntu_version = var.ubuntu_version spot_instances = var.spot_instances install_docker = var.install_docker docker_version = var.docker_version diff --git a/recipes/upstream/aws/rke/terraform.tfvars.example b/recipes/upstream/aws/rke/terraform.tfvars.example index 993ffc3..056d48e 100644 --- a/recipes/upstream/aws/rke/terraform.tfvars.example +++ b/recipes/upstream/aws/rke/terraform.tfvars.example @@ -38,6 +38,9 @@ instance_count = 1 ### -- Use SLES or Ubuntu images when launching instances (sles or ubuntu) # os_type = "sles" +# sles_version = "15-sp6" +# ubuntu_version = "22.04" + ## - SSH username (must match the SSH user for the AMI used) # ssh_username = "ec2-user" ## - Custom AMI to launch instances with diff --git a/recipes/upstream/aws/rke/variables.tf b/recipes/upstream/aws/rke/variables.tf index 01c72ab..f3e1af1 100644 --- a/recipes/upstream/aws/rke/variables.tf +++ b/recipes/upstream/aws/rke/variables.tf @@ -186,6 +186,16 @@ variable "os_type" { default = "sles" } +variable "sles_version" { + description = "Version of SLES to use for instances (ex: 15-sp6)" + default = "15-sp6" +} + +variable "ubuntu_version" { + description = "Version of Ubuntu to use for instances (ex: 22.04)" + default = "22.04" +} + variable "subnet_id" { type = string description = "VPC Subnet ID to create the instance(s) in" diff --git a/recipes/upstream/aws/rke2/docs.md b/recipes/upstream/aws/rke2/docs.md index 138e51a..6dbfa2a 100644 --- a/recipes/upstream/aws/rke2/docs.md +++ b/recipes/upstream/aws/rke2/docs.md @@ -61,11 +61,13 @@ | [rke2\_config](#input\_rke2\_config) | Additional RKE2 configuration to add to the config.yaml file | `any` | `null` | no | | [rke2\_token](#input\_rke2\_token) | Token to use when configuring RKE2 nodes | `any` | `null` | no | | [rke2\_version](#input\_rke2\_version) | Kubernetes version to use for the RKE2 cluster | `string` | `null` | no | +| [sles\_version](#input\_sles\_version) | Version of SLES to use for instances (ex: 15-sp6) | `string` | `"15-sp6"` | no | | [spot\_instances](#input\_spot\_instances) | Use spot instances | `bool` | `null` | no | | [ssh\_key\_pair\_name](#input\_ssh\_key\_pair\_name) | Specify the SSH key name to use (that's already present in AWS) | `string` | `null` | no | | [ssh\_key\_pair\_path](#input\_ssh\_key\_pair\_path) | Path to the SSH private key used as the key pair (that's already present in AWS) | `string` | `null` | no | | [ssh\_username](#input\_ssh\_username) | Username used for SSH with sudo access, must align with the AMI in use | `string` | `null` | no | | [subnet\_id](#input\_subnet\_id) | VPC Subnet ID to create the instance(s) in | `string` | `null` | no | +| [ubuntu\_version](#input\_ubuntu\_version) | Version of Ubuntu to use for instances (ex: 22.04) | `string` | `"22.04"` | no | | [wait](#input\_wait) | An optional wait before installing the Rancher helm chart | `string` | `"20s"` | no | ## Outputs diff --git a/recipes/upstream/aws/rke2/main.tf b/recipes/upstream/aws/rke2/main.tf index 075e435..29016cf 100644 --- a/recipes/upstream/aws/rke2/main.tf +++ b/recipes/upstream/aws/rke2/main.tf @@ -20,6 +20,8 @@ module "rke2_first_server" { instance_disk_size = var.instance_disk_size instance_ami = var.instance_ami os_type = var.os_type + sles_version = var.sles_version + ubuntu_version = var.ubuntu_version create_ssh_key_pair = var.create_ssh_key_pair ssh_key_pair_name = var.ssh_key_pair_name ssh_key_pair_path = var.ssh_key_pair_path @@ -48,6 +50,8 @@ module "rke2_additional_servers" { instance_disk_size = var.instance_disk_size instance_ami = var.instance_ami os_type = var.os_type + sles_version = var.sles_version + ubuntu_version = var.ubuntu_version create_ssh_key_pair = false ssh_key_pair_name = module.rke2_first_server.ssh_key_pair_name ssh_key_pair_path = module.rke2_first_server.ssh_key_path diff --git a/recipes/upstream/aws/rke2/terraform.tfvars.example b/recipes/upstream/aws/rke2/terraform.tfvars.example index ada8534..fa4a676 100644 --- a/recipes/upstream/aws/rke2/terraform.tfvars.example +++ b/recipes/upstream/aws/rke2/terraform.tfvars.example @@ -38,6 +38,9 @@ instance_count = 1 ### -- Use SLES or Ubuntu images when launching instances (sles or ubuntu) # os_type = "sles" +# sles_version = "15-sp6" +# ubuntu_version = "22.04" + ## - SSH username (must match the SSH user for the AMI used) # ssh_username = "ec2-user" ## - Custom AMI to launch instances with diff --git a/recipes/upstream/aws/rke2/variables.tf b/recipes/upstream/aws/rke2/variables.tf index 9286f05..d4eaf3f 100644 --- a/recipes/upstream/aws/rke2/variables.tf +++ b/recipes/upstream/aws/rke2/variables.tf @@ -215,6 +215,16 @@ variable "os_type" { default = "sles" } +variable "sles_version" { + description = "Version of SLES to use for instances (ex: 15-sp6)" + default = "15-sp6" +} + +variable "ubuntu_version" { + description = "Version of Ubuntu to use for instances (ex: 22.04)" + default = "22.04" +} + variable "subnet_id" { type = string description = "VPC Subnet ID to create the instance(s) in"