mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-04-29 20:07:38 +02:00
feat!: Add support for Outposts, remove node security group, add support for addon preserve and most_recent configurations (#2250)
Co-authored-by: Anton Babenko <anton@antonbabenko.com> Resolves undefined
This commit is contained in:
@@ -9,7 +9,7 @@ See [`examples/user_data/`](https://github.com/terraform-aws-modules/terraform-a
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
|
||||
| <a name="requirement_cloudinit"></a> [cloudinit](#requirement\_cloudinit) | >= 2.0 |
|
||||
|
||||
## Providers
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
output "user_data" {
|
||||
description = "Base64 encoded user data rendered for the provided inputs"
|
||||
value = try(local.platform[var.platform].user_data, "")
|
||||
value = try(local.platform[var.platform].user_data, null)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
terraform {
|
||||
required_version = ">= 0.13.1"
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
cloudinit = {
|
||||
|
||||
@@ -18,7 +18,18 @@ module "eks_managed_node_group" {
|
||||
// The following variables are necessary if you decide to use the module outside of the parent EKS module context.
|
||||
// Without it, the security groups of the nodes are empty and thus won't join the cluster.
|
||||
cluster_primary_security_group_id = module.eks.cluster_primary_security_group_id
|
||||
cluster_security_group_id = module.eks.node_security_group_id
|
||||
cluster_security_group_id = module.eks.node_security_group_id
|
||||
|
||||
// Note: `disk_size`, and `remote_access` can only be set when using the EKS managed node group default launch template
|
||||
// This module defaults to providing a custom launch template to allow for custom security groups, tag propagation, etc.
|
||||
// use_custom_launch_template = false
|
||||
// disk_size = 50
|
||||
//
|
||||
// # Remote access cannot be specified with a launch template
|
||||
// remote_access = {
|
||||
// ec2_ssh_key = module.key_pair.key_pair_name
|
||||
// source_security_group_ids = [aws_security_group.remote_access.id]
|
||||
// }
|
||||
|
||||
min_size = 1
|
||||
max_size = 10
|
||||
@@ -53,14 +64,14 @@ module "eks_managed_node_group" {
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.72 |
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.45 |
|
||||
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.72 |
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.45 |
|
||||
|
||||
## Modules
|
||||
|
||||
@@ -74,10 +85,9 @@ module "eks_managed_node_group" {
|
||||
|------|------|
|
||||
| [aws_eks_node_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_node_group) | resource |
|
||||
| [aws_iam_role.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
|
||||
| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
||||
| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
||||
| [aws_launch_template.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template) | resource |
|
||||
| [aws_security_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
|
||||
| [aws_security_group_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
|
||||
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
|
||||
| [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
||||
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
|
||||
@@ -98,26 +108,24 @@ module "eks_managed_node_group" {
|
||||
| <a name="input_cluster_ip_family"></a> [cluster\_ip\_family](#input\_cluster\_ip\_family) | The IP family used to assign Kubernetes pod and service addresses. Valid values are `ipv4` (default) and `ipv6` | `string` | `null` | no |
|
||||
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of associated EKS cluster | `string` | `null` | no |
|
||||
| <a name="input_cluster_primary_security_group_id"></a> [cluster\_primary\_security\_group\_id](#input\_cluster\_primary\_security\_group\_id) | The ID of the EKS cluster primary security group to associate with the instance(s). This is the security group that is automatically created by the EKS service | `string` | `null` | no |
|
||||
| <a name="input_cluster_security_group_id"></a> [cluster\_security\_group\_id](#input\_cluster\_security\_group\_id) | Cluster control plane security group ID | `string` | `null` | no |
|
||||
| <a name="input_cluster_service_ipv4_cidr"></a> [cluster\_service\_ipv4\_cidr](#input\_cluster\_service\_ipv4\_cidr) | The CIDR block to assign Kubernetes service IP addresses from. If you don't specify a block, Kubernetes assigns addresses from either the 10.100.0.0/16 or 172.20.0.0/16 CIDR blocks | `string` | `null` | no |
|
||||
| <a name="input_cluster_version"></a> [cluster\_version](#input\_cluster\_version) | Kubernetes version. Defaults to EKS Cluster Kubernetes version | `string` | `null` | no |
|
||||
| <a name="input_cpu_options"></a> [cpu\_options](#input\_cpu\_options) | The CPU options for the instance | `map(string)` | `{}` | no |
|
||||
| <a name="input_create"></a> [create](#input\_create) | Determines whether to create EKS managed node group or not | `bool` | `true` | no |
|
||||
| <a name="input_create_iam_role"></a> [create\_iam\_role](#input\_create\_iam\_role) | Determines whether an IAM role is created or to use an existing IAM role | `bool` | `true` | no |
|
||||
| <a name="input_create_launch_template"></a> [create\_launch\_template](#input\_create\_launch\_template) | Determines whether to create a launch template or not. If set to `false`, EKS will use its own default launch template | `bool` | `true` | no |
|
||||
| <a name="input_create_security_group"></a> [create\_security\_group](#input\_create\_security\_group) | Determines whether to create a security group | `bool` | `true` | no |
|
||||
| <a name="input_credit_specification"></a> [credit\_specification](#input\_credit\_specification) | Customize the credit specification of the instance | `map(string)` | `{}` | no |
|
||||
| <a name="input_desired_size"></a> [desired\_size](#input\_desired\_size) | Desired number of instances/nodes | `number` | `1` | no |
|
||||
| <a name="input_disable_api_termination"></a> [disable\_api\_termination](#input\_disable\_api\_termination) | If true, enables EC2 instance termination protection | `bool` | `null` | no |
|
||||
| <a name="input_disk_size"></a> [disk\_size](#input\_disk\_size) | Disk size in GiB for nodes. Defaults to `20` | `number` | `null` | no |
|
||||
| <a name="input_disk_size"></a> [disk\_size](#input\_disk\_size) | Disk size in GiB for nodes. Defaults to `20`. Only valid when `use_custom_launch_template` = `false` | `number` | `null` | no |
|
||||
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | If true, the launched EC2 instance(s) will be EBS-optimized | `bool` | `null` | no |
|
||||
| <a name="input_elastic_gpu_specifications"></a> [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | The elastic GPU to attach to the instance | `map(string)` | `{}` | no |
|
||||
| <a name="input_elastic_gpu_specifications"></a> [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | The elastic GPU to attach to the instance | `any` | `{}` | no |
|
||||
| <a name="input_elastic_inference_accelerator"></a> [elastic\_inference\_accelerator](#input\_elastic\_inference\_accelerator) | Configuration block containing an Elastic Inference Accelerator to attach to the instance | `map(string)` | `{}` | no |
|
||||
| <a name="input_enable_bootstrap_user_data"></a> [enable\_bootstrap\_user\_data](#input\_enable\_bootstrap\_user\_data) | Determines whether the bootstrap configurations are populated within the user data template. Only valid when using a custom AMI via `ami_id` | `bool` | `false` | no |
|
||||
| <a name="input_enable_monitoring"></a> [enable\_monitoring](#input\_enable\_monitoring) | Enables/disables detailed monitoring | `bool` | `true` | no |
|
||||
| <a name="input_enclave_options"></a> [enclave\_options](#input\_enclave\_options) | Enable Nitro Enclaves on launched instances | `map(string)` | `{}` | no |
|
||||
| <a name="input_force_update_version"></a> [force\_update\_version](#input\_force\_update\_version) | Force version update if existing pods are unable to be drained due to a pod disruption budget issue | `bool` | `null` | no |
|
||||
| <a name="input_iam_role_additional_policies"></a> [iam\_role\_additional\_policies](#input\_iam\_role\_additional\_policies) | Additional policies to be added to the IAM role | `list(string)` | `[]` | no |
|
||||
| <a name="input_iam_role_additional_policies"></a> [iam\_role\_additional\_policies](#input\_iam\_role\_additional\_policies) | Additional policies to be added to the IAM role | `map(string)` | `{}` | no |
|
||||
| <a name="input_iam_role_arn"></a> [iam\_role\_arn](#input\_iam\_role\_arn) | Existing IAM role ARN for the node group. Required if `create_iam_role` is set to `false` | `string` | `null` | no |
|
||||
| <a name="input_iam_role_attach_cni_policy"></a> [iam\_role\_attach\_cni\_policy](#input\_iam\_role\_attach\_cni\_policy) | Whether to attach the `AmazonEKS_CNI_Policy`/`AmazonEKS_CNI_IPv6_Policy` IAM policy to the IAM IAM role. WARNING: If set `false` the permissions must be assigned to the `aws-node` DaemonSet pods via another method or nodes will not be able to join the cluster | `bool` | `true` | no |
|
||||
| <a name="input_iam_role_description"></a> [iam\_role\_description](#input\_iam\_role\_description) | Description of the role | `string` | `null` | no |
|
||||
@@ -133,11 +141,13 @@ module "eks_managed_node_group" {
|
||||
| <a name="input_labels"></a> [labels](#input\_labels) | Key-value map of Kubernetes labels. Only labels that are applied with the EKS API are managed by this argument. Other Kubernetes labels applied to the EKS Node Group will not be managed | `map(string)` | `null` | no |
|
||||
| <a name="input_launch_template_default_version"></a> [launch\_template\_default\_version](#input\_launch\_template\_default\_version) | Default version of the launch template | `string` | `null` | no |
|
||||
| <a name="input_launch_template_description"></a> [launch\_template\_description](#input\_launch\_template\_description) | Description of the launch template | `string` | `null` | no |
|
||||
| <a name="input_launch_template_name"></a> [launch\_template\_name](#input\_launch\_template\_name) | Launch template name - either to be created (`var.create_launch_template` = `true`) or existing (`var.create_launch_template` = `false`) | `string` | `""` | no |
|
||||
| <a name="input_launch_template_id"></a> [launch\_template\_id](#input\_launch\_template\_id) | The ID of an existing launch template to use. Required when `create_launch_template` = `false` and `use_custom_launch_template` = `true` | `string` | `""` | no |
|
||||
| <a name="input_launch_template_name"></a> [launch\_template\_name](#input\_launch\_template\_name) | Name of launch template to be created | `string` | `null` | no |
|
||||
| <a name="input_launch_template_tags"></a> [launch\_template\_tags](#input\_launch\_template\_tags) | A map of additional tags to add to the tag\_specifications of launch template created | `map(string)` | `{}` | no |
|
||||
| <a name="input_launch_template_use_name_prefix"></a> [launch\_template\_use\_name\_prefix](#input\_launch\_template\_use\_name\_prefix) | Determines whether to use `launch_template_name` as is or create a unique name beginning with the `launch_template_name` as the prefix | `bool` | `true` | no |
|
||||
| <a name="input_launch_template_version"></a> [launch\_template\_version](#input\_launch\_template\_version) | Launch template version number. The default is `$Default` | `string` | `null` | no |
|
||||
| <a name="input_license_specifications"></a> [license\_specifications](#input\_license\_specifications) | A list of license specifications to associate with | `map(string)` | `{}` | no |
|
||||
| <a name="input_license_specifications"></a> [license\_specifications](#input\_license\_specifications) | A map of license specifications to associate with | `any` | `{}` | no |
|
||||
| <a name="input_maintenance_options"></a> [maintenance\_options](#input\_maintenance\_options) | The maintenance options for the instance | `any` | `{}` | no |
|
||||
| <a name="input_max_size"></a> [max\_size](#input\_max\_size) | Maximum number of instances/nodes | `number` | `3` | no |
|
||||
| <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Customize the metadata options for the instance | `map(string)` | <pre>{<br> "http_endpoint": "enabled",<br> "http_put_response_hop_limit": 2,<br> "http_tokens": "required"<br>}</pre> | no |
|
||||
| <a name="input_min_size"></a> [min\_size](#input\_min\_size) | Minimum number of instances/nodes | `number` | `0` | no |
|
||||
@@ -147,22 +157,18 @@ module "eks_managed_node_group" {
|
||||
| <a name="input_platform"></a> [platform](#input\_platform) | Identifies if the OS platform is `bottlerocket` or `linux` based; `windows` is not supported | `string` | `"linux"` | no |
|
||||
| <a name="input_post_bootstrap_user_data"></a> [post\_bootstrap\_user\_data](#input\_post\_bootstrap\_user\_data) | User data that is appended to the user data script after of the EKS bootstrap script. Not used when `platform` = `bottlerocket` | `string` | `""` | no |
|
||||
| <a name="input_pre_bootstrap_user_data"></a> [pre\_bootstrap\_user\_data](#input\_pre\_bootstrap\_user\_data) | User data that is injected into the user data script ahead of the EKS bootstrap script. Not used when `platform` = `bottlerocket` | `string` | `""` | no |
|
||||
| <a name="input_private_dns_name_options"></a> [private\_dns\_name\_options](#input\_private\_dns\_name\_options) | The options for the instance hostname. The default values are inherited from the subnet | `map(string)` | `{}` | no |
|
||||
| <a name="input_ram_disk_id"></a> [ram\_disk\_id](#input\_ram\_disk\_id) | The ID of the ram disk | `string` | `null` | no |
|
||||
| <a name="input_remote_access"></a> [remote\_access](#input\_remote\_access) | Configuration block with remote access settings | `any` | `{}` | no |
|
||||
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | Description for the security group created | `string` | `"EKS managed node group security group"` | no |
|
||||
| <a name="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name) | Name to use on security group created | `string` | `null` | no |
|
||||
| <a name="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules) | List of security group rules to add to the security group created | `any` | `{}` | no |
|
||||
| <a name="input_security_group_tags"></a> [security\_group\_tags](#input\_security\_group\_tags) | A map of additional tags to add to the security group created | `map(string)` | `{}` | no |
|
||||
| <a name="input_security_group_use_name_prefix"></a> [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Determines whether the security group name (`security_group_name`) is used as a prefix | `bool` | `true` | no |
|
||||
| <a name="input_remote_access"></a> [remote\_access](#input\_remote\_access) | Configuration block with remote access settings. Only valid when `use_custom_launch_template` = `false` | `any` | `{}` | no |
|
||||
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | Identifiers of EC2 Subnets to associate with the EKS Node Group. These subnets must have the following resource tag: `kubernetes.io/cluster/CLUSTER_NAME` | `list(string)` | `null` | no |
|
||||
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
|
||||
| <a name="input_taints"></a> [taints](#input\_taints) | The Kubernetes taints to be applied to the nodes in the node group. Maximum of 50 taints per node group | `any` | `{}` | no |
|
||||
| <a name="input_timeouts"></a> [timeouts](#input\_timeouts) | Create, update, and delete timeout configurations for the node group | `map(string)` | `{}` | no |
|
||||
| <a name="input_update_config"></a> [update\_config](#input\_update\_config) | Configuration block of settings for max unavailable resources during node group updates | `map(string)` | `{}` | no |
|
||||
| <a name="input_update_config"></a> [update\_config](#input\_update\_config) | Configuration block of settings for max unavailable resources during node group updates | `map(string)` | <pre>{<br> "max_unavailable_percentage": 33<br>}</pre> | no |
|
||||
| <a name="input_update_launch_template_default_version"></a> [update\_launch\_template\_default\_version](#input\_update\_launch\_template\_default\_version) | Whether to update the launch templates default version on each update. Conflicts with `launch_template_default_version` | `bool` | `true` | no |
|
||||
| <a name="input_use_custom_launch_template"></a> [use\_custom\_launch\_template](#input\_use\_custom\_launch\_template) | Determines whether to use a custom launch template or not. If set to `false`, EKS will use its own default launch template | `bool` | `true` | no |
|
||||
| <a name="input_use_name_prefix"></a> [use\_name\_prefix](#input\_use\_name\_prefix) | Determines whether to use `name` as is or create a unique name beginning with the `name` as the prefix | `bool` | `true` | no |
|
||||
| <a name="input_user_data_template_path"></a> [user\_data\_template\_path](#input\_user\_data\_template\_path) | Path to a local, custom user data template file to use when rendering user data | `string` | `""` | no |
|
||||
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | ID of the VPC where the security group/nodes will be provisioned | `string` | `null` | no |
|
||||
| <a name="input_vpc_security_group_ids"></a> [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | A list of security group IDs to associate | `list(string)` | `[]` | no |
|
||||
|
||||
## Outputs
|
||||
@@ -183,6 +189,4 @@ module "eks_managed_node_group" {
|
||||
| <a name="output_node_group_resources"></a> [node\_group\_resources](#output\_node\_group\_resources) | List of objects containing information about underlying resources |
|
||||
| <a name="output_node_group_status"></a> [node\_group\_status](#output\_node\_group\_status) | Status of the EKS Node Group |
|
||||
| <a name="output_node_group_taints"></a> [node\_group\_taints](#output\_node\_group\_taints) | List of objects containing information about taints applied to the node group |
|
||||
| <a name="output_security_group_arn"></a> [security\_group\_arn](#output\_security\_group\_arn) | Amazon Resource Name (ARN) of the security group |
|
||||
| <a name="output_security_group_id"></a> [security\_group\_id](#output\_security\_group\_id) | ID of the security group |
|
||||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
data "aws_partition" "current" {}
|
||||
|
||||
data "aws_caller_identity" "current" {}
|
||||
|
||||
################################################################################
|
||||
@@ -30,75 +29,51 @@ module "user_data" {
|
||||
################################################################################
|
||||
|
||||
locals {
|
||||
# There are 4 scenarios here that have to be considered for `use_custom_launch_template`:
|
||||
# 1. `var.create_launch_template = false && var.launch_template_name == ""` => EKS MNG will use its own default LT
|
||||
# 2. `var.create_launch_template = false && var.launch_template_name == "something"` => User provided custom LT will be used
|
||||
# 3. `var.create_launch_template = true && var.launch_template_name == ""` => Custom LT will be used, module will provide a default name
|
||||
# 4. `var.create_launch_template = true && var.launch_template_name == "something"` => Custom LT will be used, LT name is provided by user
|
||||
use_custom_launch_template = var.create_launch_template || var.launch_template_name != ""
|
||||
|
||||
launch_template_name_int = coalesce(var.launch_template_name, "${var.name}-eks-node-group")
|
||||
|
||||
security_group_ids = compact(concat([try(aws_security_group.this[0].id, ""), var.cluster_primary_security_group_id], var.vpc_security_group_ids))
|
||||
launch_template_name = coalesce(var.launch_template_name, "${var.name}-eks-node-group")
|
||||
security_group_ids = compact(concat([var.cluster_primary_security_group_id], var.vpc_security_group_ids))
|
||||
}
|
||||
|
||||
resource "aws_launch_template" "this" {
|
||||
count = var.create && var.create_launch_template ? 1 : 0
|
||||
|
||||
name = var.launch_template_use_name_prefix ? null : local.launch_template_name_int
|
||||
name_prefix = var.launch_template_use_name_prefix ? "${local.launch_template_name_int}-" : null
|
||||
description = var.launch_template_description
|
||||
|
||||
ebs_optimized = var.ebs_optimized
|
||||
image_id = var.ami_id
|
||||
# # Set on node group instead
|
||||
# instance_type = var.launch_template_instance_type
|
||||
key_name = var.key_name
|
||||
user_data = module.user_data.user_data
|
||||
|
||||
vpc_security_group_ids = length(var.network_interfaces) > 0 ? [] : local.security_group_ids
|
||||
|
||||
default_version = var.launch_template_default_version
|
||||
update_default_version = var.update_launch_template_default_version
|
||||
disable_api_termination = var.disable_api_termination
|
||||
# Set on EKS managed node group, will fail if set here
|
||||
# https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html#launch-template-basics
|
||||
# instance_initiated_shutdown_behavior = var.instance_initiated_shutdown_behavior
|
||||
kernel_id = var.kernel_id
|
||||
ram_disk_id = var.ram_disk_id
|
||||
count = var.create && var.create_launch_template && var.use_custom_launch_template ? 1 : 0
|
||||
|
||||
dynamic "block_device_mappings" {
|
||||
for_each = var.block_device_mappings
|
||||
|
||||
content {
|
||||
device_name = block_device_mappings.value.device_name
|
||||
no_device = lookup(block_device_mappings.value, "no_device", null)
|
||||
virtual_name = lookup(block_device_mappings.value, "virtual_name", null)
|
||||
device_name = try(block_device_mappings.value.device_name, null)
|
||||
|
||||
dynamic "ebs" {
|
||||
for_each = flatten([lookup(block_device_mappings.value, "ebs", [])])
|
||||
for_each = try([block_device_mappings.value.ebs], [])
|
||||
|
||||
content {
|
||||
delete_on_termination = lookup(ebs.value, "delete_on_termination", null)
|
||||
encrypted = lookup(ebs.value, "encrypted", null)
|
||||
kms_key_id = lookup(ebs.value, "kms_key_id", null)
|
||||
iops = lookup(ebs.value, "iops", null)
|
||||
throughput = lookup(ebs.value, "throughput", null)
|
||||
snapshot_id = lookup(ebs.value, "snapshot_id", null)
|
||||
volume_size = lookup(ebs.value, "volume_size", null)
|
||||
volume_type = lookup(ebs.value, "volume_type", null)
|
||||
delete_on_termination = try(ebs.value.delete_on_termination, null)
|
||||
encrypted = try(ebs.value.encrypted, null)
|
||||
iops = try(ebs.value.iops, null)
|
||||
kms_key_id = try(ebs.value.kms_key_id, null)
|
||||
snapshot_id = try(ebs.value.snapshot_id, null)
|
||||
throughput = try(ebs.value.throughput, null)
|
||||
volume_size = try(ebs.value.volume_size, null)
|
||||
volume_type = try(ebs.value.volume_type, null)
|
||||
}
|
||||
}
|
||||
|
||||
no_device = try(block_device_mappings.value.no_device, null)
|
||||
virtual_name = try(block_device_mappings.value.virtual_name, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "capacity_reservation_specification" {
|
||||
for_each = length(var.capacity_reservation_specification) > 0 ? [var.capacity_reservation_specification] : []
|
||||
|
||||
content {
|
||||
capacity_reservation_preference = lookup(capacity_reservation_specification.value, "capacity_reservation_preference", null)
|
||||
capacity_reservation_preference = try(capacity_reservation_specification.value.capacity_reservation_preference, null)
|
||||
|
||||
dynamic "capacity_reservation_target" {
|
||||
for_each = try([capacity_reservation_specification.value.capacity_reservation_target], [])
|
||||
|
||||
content {
|
||||
capacity_reservation_id = lookup(capacity_reservation_target.value, "capacity_reservation_id", null)
|
||||
capacity_reservation_id = try(capacity_reservation_target.value.capacity_reservation_id, null)
|
||||
capacity_reservation_resource_group_arn = try(capacity_reservation_target.value.capacity_reservation_resource_group_arn, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,21 +81,29 @@ resource "aws_launch_template" "this" {
|
||||
|
||||
dynamic "cpu_options" {
|
||||
for_each = length(var.cpu_options) > 0 ? [var.cpu_options] : []
|
||||
|
||||
content {
|
||||
core_count = cpu_options.value.core_count
|
||||
threads_per_core = cpu_options.value.threads_per_core
|
||||
core_count = try(cpu_options.value.core_count, null)
|
||||
threads_per_core = try(cpu_options.value.threads_per_core, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "credit_specification" {
|
||||
for_each = length(var.credit_specification) > 0 ? [var.credit_specification] : []
|
||||
|
||||
content {
|
||||
cpu_credits = credit_specification.value.cpu_credits
|
||||
cpu_credits = try(credit_specification.value.cpu_credits, null)
|
||||
}
|
||||
}
|
||||
|
||||
default_version = var.launch_template_default_version
|
||||
description = var.launch_template_description
|
||||
disable_api_termination = var.disable_api_termination
|
||||
ebs_optimized = var.ebs_optimized
|
||||
|
||||
dynamic "elastic_gpu_specifications" {
|
||||
for_each = length(var.elastic_gpu_specifications) > 0 ? [var.elastic_gpu_specifications] : []
|
||||
for_each = var.elastic_gpu_specifications
|
||||
|
||||
content {
|
||||
type = elastic_gpu_specifications.value.type
|
||||
}
|
||||
@@ -128,6 +111,7 @@ resource "aws_launch_template" "this" {
|
||||
|
||||
dynamic "elastic_inference_accelerator" {
|
||||
for_each = length(var.elastic_inference_accelerator) > 0 ? [var.elastic_inference_accelerator] : []
|
||||
|
||||
content {
|
||||
type = elastic_inference_accelerator.value.type
|
||||
}
|
||||
@@ -135,6 +119,7 @@ resource "aws_launch_template" "this" {
|
||||
|
||||
dynamic "enclave_options" {
|
||||
for_each = length(var.enclave_options) > 0 ? [var.enclave_options] : []
|
||||
|
||||
content {
|
||||
enabled = enclave_options.value.enabled
|
||||
}
|
||||
@@ -143,7 +128,8 @@ resource "aws_launch_template" "this" {
|
||||
# Set on EKS managed node group, will fail if set here
|
||||
# https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html#launch-template-basics
|
||||
# dynamic "hibernation_options" {
|
||||
# for_each = var.hibernation_options != null ? [var.hibernation_options] : []
|
||||
# for_each = length(var.hibernation_options) > 0 ? [var.hibernation_options] : []
|
||||
|
||||
# content {
|
||||
# configured = hibernation_options.value.configured
|
||||
# }
|
||||
@@ -159,104 +145,154 @@ resource "aws_launch_template" "this" {
|
||||
# }
|
||||
# }
|
||||
|
||||
image_id = var.ami_id
|
||||
# Set on EKS managed node group, will fail if set here
|
||||
# https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html#launch-template-basics
|
||||
# instance_initiated_shutdown_behavior = var.instance_initiated_shutdown_behavior
|
||||
|
||||
dynamic "instance_market_options" {
|
||||
for_each = length(var.instance_market_options) > 0 ? [var.instance_market_options] : []
|
||||
|
||||
content {
|
||||
market_type = instance_market_options.value.market_type
|
||||
market_type = try(instance_market_options.value.market_type, null)
|
||||
|
||||
dynamic "spot_options" {
|
||||
for_each = length(lookup(instance_market_options.value, "spot_options", {})) > 0 ? [instance_market_options.value.spot_options] : []
|
||||
for_each = try([instance_market_options.value.spot_options], [])
|
||||
|
||||
content {
|
||||
block_duration_minutes = lookup(spot_options.value, "block_duration_minutes", null)
|
||||
instance_interruption_behavior = lookup(spot_options.value, "instance_interruption_behavior", null)
|
||||
max_price = lookup(spot_options.value, "max_price", null)
|
||||
spot_instance_type = lookup(spot_options.value, "spot_instance_type", null)
|
||||
valid_until = lookup(spot_options.value, "valid_until", null)
|
||||
block_duration_minutes = try(spot_options.value.block_duration_minutes, null)
|
||||
instance_interruption_behavior = try(spot_options.value.instance_interruption_behavior, null)
|
||||
max_price = try(spot_options.value.max_price, null)
|
||||
spot_instance_type = try(spot_options.value.spot_instance_type, null)
|
||||
valid_until = try(spot_options.value.valid_until, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# # Set on node group instead
|
||||
# instance_type = var.launch_template_instance_type
|
||||
kernel_id = var.kernel_id
|
||||
key_name = var.key_name
|
||||
|
||||
dynamic "license_specification" {
|
||||
for_each = length(var.license_specifications) > 0 ? [var.license_specifications] : []
|
||||
for_each = length(var.license_specifications) > 0 ? var.license_specifications : {}
|
||||
|
||||
content {
|
||||
license_configuration_arn = license_specifications.value.license_configuration_arn
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "maintenance_options" {
|
||||
for_each = length(var.maintenance_options) > 0 ? [var.maintenance_options] : []
|
||||
|
||||
content {
|
||||
auto_recovery = try(maintenance_options.value.auto_recovery, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "metadata_options" {
|
||||
for_each = length(var.metadata_options) > 0 ? [var.metadata_options] : []
|
||||
|
||||
content {
|
||||
http_endpoint = lookup(metadata_options.value, "http_endpoint", null)
|
||||
http_tokens = lookup(metadata_options.value, "http_tokens", null)
|
||||
http_put_response_hop_limit = lookup(metadata_options.value, "http_put_response_hop_limit", null)
|
||||
http_protocol_ipv6 = lookup(metadata_options.value, "http_protocol_ipv6", null)
|
||||
instance_metadata_tags = lookup(metadata_options.value, "instance_metadata_tags", null)
|
||||
http_endpoint = try(metadata_options.value.http_endpoint, null)
|
||||
http_protocol_ipv6 = try(metadata_options.value.http_protocol_ipv6, null)
|
||||
http_put_response_hop_limit = try(metadata_options.value.http_put_response_hop_limit, null)
|
||||
http_tokens = try(metadata_options.value.http_tokens, null)
|
||||
instance_metadata_tags = try(metadata_options.value.instance_metadata_tags, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "monitoring" {
|
||||
for_each = var.enable_monitoring != null ? [1] : []
|
||||
for_each = var.enable_monitoring ? [1] : []
|
||||
|
||||
content {
|
||||
enabled = var.enable_monitoring
|
||||
}
|
||||
}
|
||||
|
||||
name = var.launch_template_use_name_prefix ? null : local.launch_template_name
|
||||
name_prefix = var.launch_template_use_name_prefix ? "${local.launch_template_name}-" : null
|
||||
|
||||
dynamic "network_interfaces" {
|
||||
for_each = var.network_interfaces
|
||||
content {
|
||||
associate_carrier_ip_address = lookup(network_interfaces.value, "associate_carrier_ip_address", null)
|
||||
associate_public_ip_address = lookup(network_interfaces.value, "associate_public_ip_address", null)
|
||||
delete_on_termination = lookup(network_interfaces.value, "delete_on_termination", null)
|
||||
description = lookup(network_interfaces.value, "description", null)
|
||||
device_index = lookup(network_interfaces.value, "device_index", null)
|
||||
interface_type = lookup(network_interfaces.value, "interface_type", null)
|
||||
associate_carrier_ip_address = try(network_interfaces.value.associate_carrier_ip_address, null)
|
||||
associate_public_ip_address = try(network_interfaces.value.associate_public_ip_address, null)
|
||||
delete_on_termination = try(network_interfaces.value.delete_on_termination, null)
|
||||
description = try(network_interfaces.value.description, null)
|
||||
device_index = try(network_interfaces.value.device_index, null)
|
||||
interface_type = try(network_interfaces.value.interface_type, null)
|
||||
ipv4_address_count = try(network_interfaces.value.ipv4_address_count, null)
|
||||
ipv4_addresses = try(network_interfaces.value.ipv4_addresses, [])
|
||||
ipv4_address_count = lookup(network_interfaces.value, "ipv4_address_count", null)
|
||||
ipv4_prefix_count = try(network_interfaces.value.ipv4_prefix_count, null)
|
||||
ipv4_prefixes = try(network_interfaces.value.ipv4_prefixes, null)
|
||||
ipv6_address_count = try(network_interfaces.value.ipv6_address_count, null)
|
||||
ipv6_addresses = try(network_interfaces.value.ipv6_addresses, [])
|
||||
ipv6_address_count = lookup(network_interfaces.value, "ipv6_address_count", null)
|
||||
network_interface_id = lookup(network_interfaces.value, "network_interface_id", null)
|
||||
private_ip_address = lookup(network_interfaces.value, "private_ip_address", null)
|
||||
security_groups = compact(concat(try(network_interfaces.value.security_groups, []), local.security_group_ids))
|
||||
ipv6_prefix_count = try(network_interfaces.value.ipv6_prefix_count, null)
|
||||
ipv6_prefixes = try(network_interfaces.value.ipv6_prefixes, [])
|
||||
network_card_index = try(network_interfaces.value.network_card_index, null)
|
||||
network_interface_id = try(network_interfaces.value.network_interface_id, null)
|
||||
private_ip_address = try(network_interfaces.value.private_ip_address, null)
|
||||
# Ref: https://github.com/hashicorp/terraform-provider-aws/issues/4570
|
||||
security_groups = compact(concat(try(network_interfaces.value.security_groups, []), local.security_group_ids))
|
||||
# Set on EKS managed node group, will fail if set here
|
||||
# https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html#launch-template-basics
|
||||
# subnet_id = lookup(network_interfaces.value, "subnet_id", null)
|
||||
# subnet_id = try(network_interfaces.value.subnet_id, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "placement" {
|
||||
for_each = length(var.placement) > 0 ? [var.placement] : []
|
||||
|
||||
content {
|
||||
affinity = lookup(placement.value, "affinity", null)
|
||||
availability_zone = lookup(placement.value, "availability_zone", null)
|
||||
group_name = lookup(placement.value, "group_name", null)
|
||||
host_id = lookup(placement.value, "host_id", null)
|
||||
spread_domain = lookup(placement.value, "spread_domain", null)
|
||||
tenancy = lookup(placement.value, "tenancy", null)
|
||||
partition_number = lookup(placement.value, "partition_number", null)
|
||||
affinity = try(placement.value.affinity, null)
|
||||
availability_zone = try(placement.value.availability_zone, null)
|
||||
group_name = try(placement.value.group_name, null)
|
||||
host_id = try(placement.value.host_id, null)
|
||||
host_resource_group_arn = try(placement.value.host_resource_group_arn, null)
|
||||
partition_number = try(placement.value.partition_number, null)
|
||||
spread_domain = try(placement.value.spread_domain, null)
|
||||
tenancy = try(placement.value.tenancy, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "private_dns_name_options" {
|
||||
for_each = length(var.private_dns_name_options) > 0 ? [var.private_dns_name_options] : []
|
||||
|
||||
content {
|
||||
enable_resource_name_dns_aaaa_record = try(private_dns_name_options.value.enable_resource_name_dns_aaaa_record, null)
|
||||
enable_resource_name_dns_a_record = try(private_dns_name_options.value.enable_resource_name_dns_a_record, null)
|
||||
hostname_type = try(private_dns_name_options.value.hostname_type, null)
|
||||
}
|
||||
}
|
||||
|
||||
ram_disk_id = var.ram_disk_id
|
||||
|
||||
dynamic "tag_specifications" {
|
||||
for_each = toset(["instance", "volume", "network-interface"])
|
||||
|
||||
content {
|
||||
resource_type = tag_specifications.key
|
||||
tags = merge(var.tags, { Name = var.name }, var.launch_template_tags)
|
||||
}
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
update_default_version = var.update_launch_template_default_version
|
||||
user_data = module.user_data.user_data
|
||||
vpc_security_group_ids = length(var.network_interfaces) > 0 ? [] : local.security_group_ids
|
||||
|
||||
# Prevent premature access of security group roles and policies by pods that
|
||||
tags = var.tags
|
||||
|
||||
# Prevent premature access of policies by pods that
|
||||
# require permissions on create/destroy that depend on nodes
|
||||
depends_on = [
|
||||
aws_security_group_rule.this,
|
||||
aws_iam_role_policy_attachment.this,
|
||||
]
|
||||
|
||||
tags = var.tags
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -264,7 +300,7 @@ resource "aws_launch_template" "this" {
|
||||
################################################################################
|
||||
|
||||
locals {
|
||||
launch_template_name = try(aws_launch_template.this[0].name, var.launch_template_name, null)
|
||||
launch_template_id = var.create && var.create_launch_template ? aws_launch_template.this[0].id : var.launch_template_id
|
||||
# Change order to allow users to set version priority before using defaults
|
||||
launch_template_version = coalesce(var.launch_template_version, try(aws_launch_template.this[0].default_version, "$Default"))
|
||||
}
|
||||
@@ -293,21 +329,23 @@ resource "aws_eks_node_group" "this" {
|
||||
version = var.ami_id != "" ? null : var.cluster_version
|
||||
|
||||
capacity_type = var.capacity_type
|
||||
disk_size = local.use_custom_launch_template ? null : var.disk_size # if using LT, set disk size on LT or else it will error here
|
||||
disk_size = var.use_custom_launch_template ? null : var.disk_size # if using a custom LT, set disk size on custom LT or else it will error here
|
||||
force_update_version = var.force_update_version
|
||||
instance_types = var.instance_types
|
||||
labels = var.labels
|
||||
|
||||
dynamic "launch_template" {
|
||||
for_each = local.use_custom_launch_template ? [1] : []
|
||||
for_each = var.use_custom_launch_template ? [1] : []
|
||||
|
||||
content {
|
||||
name = local.launch_template_name
|
||||
id = local.launch_template_id
|
||||
version = local.launch_template_version
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "remote_access" {
|
||||
for_each = length(var.remote_access) > 0 ? [var.remote_access] : []
|
||||
|
||||
content {
|
||||
ec2_ssh_key = try(remote_access.value.ec2_ssh_key, null)
|
||||
source_security_group_ids = try(remote_access.value.source_security_group_ids, [])
|
||||
@@ -316,15 +354,17 @@ resource "aws_eks_node_group" "this" {
|
||||
|
||||
dynamic "taint" {
|
||||
for_each = var.taints
|
||||
|
||||
content {
|
||||
key = taint.value.key
|
||||
value = lookup(taint.value, "value")
|
||||
value = try(taint.value.value, null)
|
||||
effect = taint.value.effect
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "update_config" {
|
||||
for_each = length(var.update_config) > 0 ? [var.update_config] : []
|
||||
|
||||
content {
|
||||
max_unavailable_percentage = try(update_config.value.max_unavailable_percentage, null)
|
||||
max_unavailable = try(update_config.value.max_unavailable, null)
|
||||
@@ -350,68 +390,14 @@ resource "aws_eks_node_group" "this" {
|
||||
)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Security Group
|
||||
################################################################################
|
||||
|
||||
locals {
|
||||
security_group_name = coalesce(var.security_group_name, "${var.name}-eks-node-group")
|
||||
create_security_group = var.create && var.create_security_group
|
||||
}
|
||||
|
||||
resource "aws_security_group" "this" {
|
||||
count = local.create_security_group ? 1 : 0
|
||||
|
||||
name = var.security_group_use_name_prefix ? null : local.security_group_name
|
||||
name_prefix = var.security_group_use_name_prefix ? "${local.security_group_name}-" : null
|
||||
description = var.security_group_description
|
||||
vpc_id = var.vpc_id
|
||||
|
||||
tags = merge(
|
||||
var.tags,
|
||||
{ "Name" = local.security_group_name },
|
||||
var.security_group_tags
|
||||
)
|
||||
|
||||
# https://github.com/hashicorp/terraform-provider-aws/issues/2445
|
||||
# https://github.com/hashicorp/terraform-provider-aws/issues/9692
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_security_group_rule" "this" {
|
||||
for_each = { for k, v in var.security_group_rules : k => v if local.create_security_group }
|
||||
|
||||
# Required
|
||||
security_group_id = aws_security_group.this[0].id
|
||||
protocol = each.value.protocol
|
||||
from_port = each.value.from_port
|
||||
to_port = each.value.to_port
|
||||
type = each.value.type
|
||||
|
||||
# Optional
|
||||
description = try(each.value.description, null)
|
||||
cidr_blocks = try(each.value.cidr_blocks, null)
|
||||
ipv6_cidr_blocks = try(each.value.ipv6_cidr_blocks, null)
|
||||
prefix_list_ids = try(each.value.prefix_list_ids, [])
|
||||
self = try(each.value.self, null)
|
||||
source_security_group_id = try(
|
||||
each.value.source_security_group_id,
|
||||
try(each.value.source_cluster_security_group, false) ? var.cluster_security_group_id : null
|
||||
)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# IAM Role
|
||||
################################################################################
|
||||
|
||||
locals {
|
||||
iam_role_name = coalesce(var.iam_role_name, "${var.name}-eks-node-group")
|
||||
|
||||
iam_role_name = coalesce(var.iam_role_name, "${var.name}-eks-node-group")
|
||||
iam_role_policy_prefix = "arn:${data.aws_partition.current.partition}:iam::aws:policy"
|
||||
|
||||
cni_policy = var.cluster_ip_family == "ipv6" ? "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:policy/AmazonEKS_CNI_IPv6_Policy" : "${local.iam_role_policy_prefix}/AmazonEKS_CNI_Policy"
|
||||
cni_policy = var.cluster_ip_family == "ipv6" ? "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:policy/AmazonEKS_CNI_IPv6_Policy" : "${local.iam_role_policy_prefix}/AmazonEKS_CNI_Policy"
|
||||
}
|
||||
|
||||
data "aws_iam_policy_document" "assume_role_policy" {
|
||||
@@ -445,11 +431,18 @@ resource "aws_iam_role" "this" {
|
||||
|
||||
# Policies attached ref https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_node_group
|
||||
resource "aws_iam_role_policy_attachment" "this" {
|
||||
for_each = var.create && var.create_iam_role ? toset(compact(distinct(concat([
|
||||
for_each = { for k, v in toset(compact([
|
||||
"${local.iam_role_policy_prefix}/AmazonEKSWorkerNodePolicy",
|
||||
"${local.iam_role_policy_prefix}/AmazonEC2ContainerRegistryReadOnly",
|
||||
var.iam_role_attach_cni_policy ? local.cni_policy : "",
|
||||
], var.iam_role_additional_policies)))) : toset([])
|
||||
])) : k => v if var.create && var.create_iam_role }
|
||||
|
||||
policy_arn = each.value
|
||||
role = aws_iam_role.this[0].name
|
||||
}
|
||||
|
||||
resource "aws_iam_role_policy_attachment" "additional" {
|
||||
for_each = { for k, v in var.iam_role_additional_policies : k => v if var.create && var.create_iam_role }
|
||||
|
||||
policy_arn = each.value
|
||||
role = aws_iam_role.this[0].name
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
|
||||
output "launch_template_id" {
|
||||
description = "The ID of the launch template"
|
||||
value = try(aws_launch_template.this[0].id, "")
|
||||
value = try(aws_launch_template.this[0].id, null)
|
||||
}
|
||||
|
||||
output "launch_template_arn" {
|
||||
description = "The ARN of the launch template"
|
||||
value = try(aws_launch_template.this[0].arn, "")
|
||||
value = try(aws_launch_template.this[0].arn, null)
|
||||
}
|
||||
|
||||
output "launch_template_latest_version" {
|
||||
description = "The latest version of the launch template"
|
||||
value = try(aws_launch_template.this[0].latest_version, "")
|
||||
value = try(aws_launch_template.this[0].latest_version, null)
|
||||
}
|
||||
|
||||
output "launch_template_name" {
|
||||
description = "The name of the launch template"
|
||||
value = try(aws_launch_template.this[0].name, "")
|
||||
value = try(aws_launch_template.this[0].name, null)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -28,17 +28,17 @@ output "launch_template_name" {
|
||||
|
||||
output "node_group_arn" {
|
||||
description = "Amazon Resource Name (ARN) of the EKS Node Group"
|
||||
value = try(aws_eks_node_group.this[0].arn, "")
|
||||
value = try(aws_eks_node_group.this[0].arn, null)
|
||||
}
|
||||
|
||||
output "node_group_id" {
|
||||
description = "EKS Cluster name and EKS Node Group name separated by a colon (`:`)"
|
||||
value = try(aws_eks_node_group.this[0].id, "")
|
||||
value = try(aws_eks_node_group.this[0].id, null)
|
||||
}
|
||||
|
||||
output "node_group_resources" {
|
||||
description = "List of objects containing information about underlying resources"
|
||||
value = try(aws_eks_node_group.this[0].resources, "")
|
||||
value = try(aws_eks_node_group.this[0].resources, null)
|
||||
}
|
||||
|
||||
output "node_group_autoscaling_group_names" {
|
||||
@@ -48,7 +48,7 @@ output "node_group_autoscaling_group_names" {
|
||||
|
||||
output "node_group_status" {
|
||||
description = "Status of the EKS Node Group"
|
||||
value = try(aws_eks_node_group.this[0].arn, "")
|
||||
value = try(aws_eks_node_group.this[0].arn, null)
|
||||
}
|
||||
|
||||
output "node_group_labels" {
|
||||
@@ -61,27 +61,13 @@ output "node_group_taints" {
|
||||
value = try(aws_eks_node_group.this[0].taint, [])
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Security Group
|
||||
################################################################################
|
||||
|
||||
output "security_group_arn" {
|
||||
description = "Amazon Resource Name (ARN) of the security group"
|
||||
value = try(aws_security_group.this[0].arn, "")
|
||||
}
|
||||
|
||||
output "security_group_id" {
|
||||
description = "ID of the security group"
|
||||
value = try(aws_security_group.this[0].id, "")
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# IAM Role
|
||||
################################################################################
|
||||
|
||||
output "iam_role_name" {
|
||||
description = "The name of the IAM role"
|
||||
value = try(aws_iam_role.this[0].name, "")
|
||||
value = try(aws_iam_role.this[0].name, null)
|
||||
}
|
||||
|
||||
output "iam_role_arn" {
|
||||
@@ -91,5 +77,5 @@ output "iam_role_arn" {
|
||||
|
||||
output "iam_role_unique_id" {
|
||||
description = "Stable and unique string identifying the IAM role"
|
||||
value = try(aws_iam_role.this[0].unique_id, "")
|
||||
value = try(aws_iam_role.this[0].unique_id, null)
|
||||
}
|
||||
|
||||
@@ -84,12 +84,24 @@ variable "create_launch_template" {
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "launch_template_name" {
|
||||
description = "Launch template name - either to be created (`var.create_launch_template` = `true`) or existing (`var.create_launch_template` = `false`)"
|
||||
variable "use_custom_launch_template" {
|
||||
description = "Determines whether to use a custom launch template or not. If set to `false`, EKS will use its own default launch template"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "launch_template_id" {
|
||||
description = "The ID of an existing launch template to use. Required when `create_launch_template` = `false` and `use_custom_launch_template` = `true`"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "launch_template_name" {
|
||||
description = "Name of launch template to be created"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "launch_template_use_name_prefix" {
|
||||
description = "Determines whether to use `launch_template_name` as is or create a unique name beginning with the `launch_template_name` as the prefix"
|
||||
type = bool
|
||||
@@ -188,7 +200,7 @@ variable "credit_specification" {
|
||||
|
||||
variable "elastic_gpu_specifications" {
|
||||
description = "The elastic GPU to attach to the instance"
|
||||
type = map(string)
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
@@ -210,9 +222,15 @@ variable "instance_market_options" {
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "maintenance_options" {
|
||||
description = "The maintenance options for the instance"
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "license_specifications" {
|
||||
description = "A list of license specifications to associate with"
|
||||
type = map(string)
|
||||
description = "A map of license specifications to associate with"
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
@@ -244,6 +262,12 @@ variable "placement" {
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "private_dns_name_options" {
|
||||
description = "The options for the instance hostname. The default values are inherited from the subnet"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "launch_template_tags" {
|
||||
description = "A map of additional tags to add to the tag_specifications of launch template created"
|
||||
type = map(string)
|
||||
@@ -309,7 +333,7 @@ variable "capacity_type" {
|
||||
}
|
||||
|
||||
variable "disk_size" {
|
||||
description = "Disk size in GiB for nodes. Defaults to `20`"
|
||||
description = "Disk size in GiB for nodes. Defaults to `20`. Only valid when `use_custom_launch_template` = `false`"
|
||||
type = number
|
||||
default = null
|
||||
}
|
||||
@@ -345,7 +369,7 @@ variable "launch_template_version" {
|
||||
}
|
||||
|
||||
variable "remote_access" {
|
||||
description = "Configuration block with remote access settings"
|
||||
description = "Configuration block with remote access settings. Only valid when `use_custom_launch_template` = `false`"
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
@@ -359,7 +383,9 @@ variable "taints" {
|
||||
variable "update_config" {
|
||||
description = "Configuration block of settings for max unavailable resources during node group updates"
|
||||
type = map(string)
|
||||
default = {}
|
||||
default = {
|
||||
max_unavailable_percentage = 33
|
||||
}
|
||||
}
|
||||
|
||||
variable "timeouts" {
|
||||
@@ -368,58 +394,6 @@ variable "timeouts" {
|
||||
default = {}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Security Group
|
||||
################################################################################
|
||||
|
||||
variable "create_security_group" {
|
||||
description = "Determines whether to create a security group"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "security_group_name" {
|
||||
description = "Name to use on security group created"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "security_group_use_name_prefix" {
|
||||
description = "Determines whether the security group name (`security_group_name`) is used as a prefix"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "security_group_description" {
|
||||
description = "Description for the security group created"
|
||||
type = string
|
||||
default = "EKS managed node group security group"
|
||||
}
|
||||
|
||||
variable "vpc_id" {
|
||||
description = "ID of the VPC where the security group/nodes will be provisioned"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "security_group_rules" {
|
||||
description = "List of security group rules to add to the security group created"
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "cluster_security_group_id" {
|
||||
description = "Cluster control plane security group ID"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "security_group_tags" {
|
||||
description = "A map of additional tags to add to the security group created"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# IAM Role
|
||||
################################################################################
|
||||
@@ -480,8 +454,8 @@ variable "iam_role_attach_cni_policy" {
|
||||
|
||||
variable "iam_role_additional_policies" {
|
||||
description = "Additional policies to be added to the IAM role"
|
||||
type = list(string)
|
||||
default = []
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "iam_role_tags" {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
terraform {
|
||||
required_version = ">= 0.13.1"
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = ">= 3.72"
|
||||
version = ">= 4.45"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ Configuration in this directory creates a Fargate EKS Profile
|
||||
module "fargate_profile" {
|
||||
source = "terraform-aws-modules/eks/aws//modules/fargate-profile"
|
||||
|
||||
name = "separate-fargate-profile"
|
||||
cluster_name = "my-cluster"
|
||||
name = "separate-fargate-profile"
|
||||
cluster_name = "my-cluster"
|
||||
|
||||
subnet_ids = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
|
||||
selectors = [{
|
||||
@@ -28,14 +28,14 @@ module "fargate_profile" {
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.72 |
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.45 |
|
||||
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.72 |
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.45 |
|
||||
|
||||
## Modules
|
||||
|
||||
@@ -47,6 +47,7 @@ No modules.
|
||||
|------|------|
|
||||
| [aws_eks_fargate_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_fargate_profile) | resource |
|
||||
| [aws_iam_role.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
|
||||
| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
||||
| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
||||
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
|
||||
| [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
||||
@@ -60,7 +61,7 @@ No modules.
|
||||
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the EKS cluster | `string` | `null` | no |
|
||||
| <a name="input_create"></a> [create](#input\_create) | Determines whether to create Fargate profile or not | `bool` | `true` | no |
|
||||
| <a name="input_create_iam_role"></a> [create\_iam\_role](#input\_create\_iam\_role) | Determines whether an IAM role is created or to use an existing IAM role | `bool` | `true` | no |
|
||||
| <a name="input_iam_role_additional_policies"></a> [iam\_role\_additional\_policies](#input\_iam\_role\_additional\_policies) | Additional policies to be added to the IAM role | `list(string)` | `[]` | no |
|
||||
| <a name="input_iam_role_additional_policies"></a> [iam\_role\_additional\_policies](#input\_iam\_role\_additional\_policies) | Additional policies to be added to the IAM role | `map(string)` | `{}` | no |
|
||||
| <a name="input_iam_role_arn"></a> [iam\_role\_arn](#input\_iam\_role\_arn) | Existing IAM role ARN for the Fargate profile. Required if `create_iam_role` is set to `false` | `string` | `null` | no |
|
||||
| <a name="input_iam_role_attach_cni_policy"></a> [iam\_role\_attach\_cni\_policy](#input\_iam\_role\_attach\_cni\_policy) | Whether to attach the `AmazonEKS_CNI_Policy`/`AmazonEKS_CNI_IPv6_Policy` IAM policy to the IAM IAM role. WARNING: If set `false` the permissions must be assigned to the `aws-node` DaemonSet pods via another method or nodes will not be able to join the cluster | `bool` | `true` | no |
|
||||
| <a name="input_iam_role_description"></a> [iam\_role\_description](#input\_iam\_role\_description) | Description of the role | `string` | `null` | no |
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
data "aws_partition" "current" {}
|
||||
|
||||
data "aws_caller_identity" "current" {}
|
||||
|
||||
locals {
|
||||
iam_role_name = coalesce(var.iam_role_name, var.name, "fargate-profile")
|
||||
|
||||
iam_role_name = coalesce(var.iam_role_name, var.name, "fargate-profile")
|
||||
iam_role_policy_prefix = "arn:${data.aws_partition.current.partition}:iam::aws:policy"
|
||||
|
||||
cni_policy = var.cluster_ip_family == "ipv6" ? "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:policy/AmazonEKS_CNI_IPv6_Policy" : "${local.iam_role_policy_prefix}/AmazonEKS_CNI_Policy"
|
||||
cni_policy = var.cluster_ip_family == "ipv6" ? "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:policy/AmazonEKS_CNI_IPv6_Policy" : "${local.iam_role_policy_prefix}/AmazonEKS_CNI_Policy"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -44,10 +41,17 @@ resource "aws_iam_role" "this" {
|
||||
}
|
||||
|
||||
resource "aws_iam_role_policy_attachment" "this" {
|
||||
for_each = var.create && var.create_iam_role ? toset(compact(distinct(concat([
|
||||
for_each = { for k, v in toset(compact([
|
||||
"${local.iam_role_policy_prefix}/AmazonEKSFargatePodExecutionRolePolicy",
|
||||
var.iam_role_attach_cni_policy ? local.cni_policy : "",
|
||||
], var.iam_role_additional_policies)))) : toset([])
|
||||
])) : k => v if var.create && var.create_iam_role }
|
||||
|
||||
policy_arn = each.value
|
||||
role = aws_iam_role.this[0].name
|
||||
}
|
||||
|
||||
resource "aws_iam_role_policy_attachment" "additional" {
|
||||
for_each = { for k, v in var.iam_role_additional_policies : k => v if var.create && var.create_iam_role }
|
||||
|
||||
policy_arn = each.value
|
||||
role = aws_iam_role.this[0].name
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
output "iam_role_name" {
|
||||
description = "The name of the IAM role"
|
||||
value = try(aws_iam_role.this[0].name, "")
|
||||
value = try(aws_iam_role.this[0].name, null)
|
||||
}
|
||||
|
||||
output "iam_role_arn" {
|
||||
@@ -14,7 +14,7 @@ output "iam_role_arn" {
|
||||
|
||||
output "iam_role_unique_id" {
|
||||
description = "Stable and unique string identifying the IAM role"
|
||||
value = try(aws_iam_role.this[0].unique_id, "")
|
||||
value = try(aws_iam_role.this[0].unique_id, null)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -23,20 +23,20 @@ output "iam_role_unique_id" {
|
||||
|
||||
output "fargate_profile_arn" {
|
||||
description = "Amazon Resource Name (ARN) of the EKS Fargate Profile"
|
||||
value = try(aws_eks_fargate_profile.this[0].arn, "")
|
||||
value = try(aws_eks_fargate_profile.this[0].arn, null)
|
||||
}
|
||||
|
||||
output "fargate_profile_id" {
|
||||
description = "EKS Cluster name and EKS Fargate Profile name separated by a colon (`:`)"
|
||||
value = try(aws_eks_fargate_profile.this[0].id, "")
|
||||
value = try(aws_eks_fargate_profile.this[0].id, null)
|
||||
}
|
||||
|
||||
output "fargate_profile_status" {
|
||||
description = "Status of the EKS Fargate Profile"
|
||||
value = try(aws_eks_fargate_profile.this[0].status, "")
|
||||
value = try(aws_eks_fargate_profile.this[0].status, null)
|
||||
}
|
||||
|
||||
output "fargate_profile_pod_execution_role_arn" {
|
||||
description = "Amazon Resource Name (ARN) of the EKS Fargate Profile Pod execution role ARN"
|
||||
value = try(aws_eks_fargate_profile.this[0].pod_execution_role_arn, "")
|
||||
value = try(aws_eks_fargate_profile.this[0].pod_execution_role_arn, null)
|
||||
}
|
||||
|
||||
@@ -70,8 +70,8 @@ variable "iam_role_attach_cni_policy" {
|
||||
|
||||
variable "iam_role_additional_policies" {
|
||||
description = "Additional policies to be added to the IAM role"
|
||||
type = list(string)
|
||||
default = []
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "iam_role_tags" {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
terraform {
|
||||
required_version = ">= 0.13.1"
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = ">= 3.72"
|
||||
version = ">= 4.45"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,14 +99,14 @@ module "karpenter" {
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.72 |
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.45 |
|
||||
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.72 |
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.45 |
|
||||
|
||||
## Modules
|
||||
|
||||
|
||||
@@ -261,11 +261,14 @@ locals {
|
||||
resource "aws_cloudwatch_event_rule" "this" {
|
||||
for_each = { for k, v in local.events : k => v if local.enable_spot_termination }
|
||||
|
||||
name = "Karpenter${each.value.name}-${var.cluster_name}"
|
||||
name_prefix = "Karpenter${each.value.name}-"
|
||||
description = each.value.description
|
||||
event_pattern = jsonencode(each.value.event_pattern)
|
||||
|
||||
tags = var.tags
|
||||
tags = merge(
|
||||
{ "ClusterName" : var.cluster_name },
|
||||
var.tags,
|
||||
)
|
||||
}
|
||||
|
||||
resource "aws_cloudwatch_event_target" "this" {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
terraform {
|
||||
required_version = ">= 0.13.1"
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = ">= 3.72"
|
||||
version = ">= 4.45"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,11 @@ module "self_managed_node_group" {
|
||||
|
||||
vpc_id = "vpc-1234556abcdef"
|
||||
subnet_ids = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
|
||||
// The following variables are necessary if you decide to use the module outside of the parent EKS module context.
|
||||
// Without it, the security groups of the nodes are empty and thus won't join the cluster.
|
||||
vpc_security_group_ids = [
|
||||
# cluster_security_group_id,
|
||||
module.eks.cluster_primary_security_group_id,
|
||||
module.eks.cluster_security_group_id,
|
||||
]
|
||||
|
||||
min_size = 1
|
||||
@@ -39,14 +42,14 @@ module "self_managed_node_group" {
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.72 |
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.45 |
|
||||
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.72 |
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.45 |
|
||||
|
||||
## Modules
|
||||
|
||||
@@ -62,13 +65,11 @@ module "self_managed_node_group" {
|
||||
| [aws_autoscaling_schedule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_schedule) | resource |
|
||||
| [aws_iam_instance_profile.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource |
|
||||
| [aws_iam_role.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
|
||||
| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
||||
| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
||||
| [aws_launch_template.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template) | resource |
|
||||
| [aws_security_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
|
||||
| [aws_security_group_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
|
||||
| [aws_ami.eks_default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
|
||||
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
|
||||
| [aws_default_tags.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/default_tags) | data source |
|
||||
| [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
||||
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
|
||||
|
||||
@@ -88,32 +89,33 @@ module "self_managed_node_group" {
|
||||
| <a name="input_cluster_ip_family"></a> [cluster\_ip\_family](#input\_cluster\_ip\_family) | The IP family used to assign Kubernetes pod and service addresses. Valid values are `ipv4` (default) and `ipv6` | `string` | `null` | no |
|
||||
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of associated EKS cluster | `string` | `""` | no |
|
||||
| <a name="input_cluster_primary_security_group_id"></a> [cluster\_primary\_security\_group\_id](#input\_cluster\_primary\_security\_group\_id) | The ID of the EKS cluster primary security group to associate with the instance(s). This is the security group that is automatically created by the EKS service | `string` | `null` | no |
|
||||
| <a name="input_cluster_security_group_id"></a> [cluster\_security\_group\_id](#input\_cluster\_security\_group\_id) | Cluster control plane security group ID | `string` | `null` | no |
|
||||
| <a name="input_cluster_version"></a> [cluster\_version](#input\_cluster\_version) | Kubernetes cluster version - used to lookup default AMI ID if one is not provided | `string` | `null` | no |
|
||||
| <a name="input_context"></a> [context](#input\_context) | Reserved | `string` | `null` | no |
|
||||
| <a name="input_cpu_options"></a> [cpu\_options](#input\_cpu\_options) | The CPU options for the instance | `map(string)` | `{}` | no |
|
||||
| <a name="input_create"></a> [create](#input\_create) | Determines whether to create self managed node group or not | `bool` | `true` | no |
|
||||
| <a name="input_create_autoscaling_group"></a> [create\_autoscaling\_group](#input\_create\_autoscaling\_group) | Determines whether to create autoscaling group or not | `bool` | `true` | no |
|
||||
| <a name="input_create_iam_instance_profile"></a> [create\_iam\_instance\_profile](#input\_create\_iam\_instance\_profile) | Determines whether an IAM instance profile is created or to use an existing IAM instance profile | `bool` | `true` | no |
|
||||
| <a name="input_create_launch_template"></a> [create\_launch\_template](#input\_create\_launch\_template) | Determines whether to create launch template or not | `bool` | `true` | no |
|
||||
| <a name="input_create_schedule"></a> [create\_schedule](#input\_create\_schedule) | Determines whether to create autoscaling group schedule or not | `bool` | `true` | no |
|
||||
| <a name="input_create_security_group"></a> [create\_security\_group](#input\_create\_security\_group) | Determines whether to create a security group | `bool` | `true` | no |
|
||||
| <a name="input_credit_specification"></a> [credit\_specification](#input\_credit\_specification) | Customize the credit specification of the instance | `map(string)` | `{}` | no |
|
||||
| <a name="input_default_cooldown"></a> [default\_cooldown](#input\_default\_cooldown) | The amount of time, in seconds, after a scaling activity completes before another scaling activity can start | `number` | `null` | no |
|
||||
| <a name="input_default_instance_warmup"></a> [default\_instance\_warmup](#input\_default\_instance\_warmup) | Amount of time, in seconds, until a newly launched instance can contribute to the Amazon CloudWatch metrics. This delay lets an instance finish initializing before Amazon EC2 Auto Scaling aggregates instance metrics, resulting in more reliable usage data | `number` | `null` | no |
|
||||
| <a name="input_delete_timeout"></a> [delete\_timeout](#input\_delete\_timeout) | Delete timeout to wait for destroying autoscaling group | `string` | `null` | no |
|
||||
| <a name="input_desired_size"></a> [desired\_size](#input\_desired\_size) | The number of Amazon EC2 instances that should be running in the autoscaling group | `number` | `1` | no |
|
||||
| <a name="input_disable_api_termination"></a> [disable\_api\_termination](#input\_disable\_api\_termination) | If true, enables EC2 instance termination protection | `bool` | `null` | no |
|
||||
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | If true, the launched EC2 instance will be EBS-optimized | `bool` | `null` | no |
|
||||
| <a name="input_elastic_gpu_specifications"></a> [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | The elastic GPU to attach to the instance | `map(string)` | `{}` | no |
|
||||
| <a name="input_elastic_gpu_specifications"></a> [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | The elastic GPU to attach to the instance | `any` | `{}` | no |
|
||||
| <a name="input_elastic_inference_accelerator"></a> [elastic\_inference\_accelerator](#input\_elastic\_inference\_accelerator) | Configuration block containing an Elastic Inference Accelerator to attach to the instance | `map(string)` | `{}` | no |
|
||||
| <a name="input_enable_monitoring"></a> [enable\_monitoring](#input\_enable\_monitoring) | Enables/disables detailed monitoring | `bool` | `true` | no |
|
||||
| <a name="input_enabled_metrics"></a> [enabled\_metrics](#input\_enabled\_metrics) | A list of metrics to collect. The allowed values are `GroupDesiredCapacity`, `GroupInServiceCapacity`, `GroupPendingCapacity`, `GroupMinSize`, `GroupMaxSize`, `GroupInServiceInstances`, `GroupPendingInstances`, `GroupStandbyInstances`, `GroupStandbyCapacity`, `GroupTerminatingCapacity`, `GroupTerminatingInstances`, `GroupTotalCapacity`, `GroupTotalInstances` | `list(string)` | `[]` | no |
|
||||
| <a name="input_enclave_options"></a> [enclave\_options](#input\_enclave\_options) | Enable Nitro Enclaves on launched instances | `map(string)` | `{}` | no |
|
||||
| <a name="input_force_delete"></a> [force\_delete](#input\_force\_delete) | Allows deleting the Auto Scaling Group without waiting for all instances in the pool to terminate. You can force an Auto Scaling Group to delete even if it's in the process of scaling a resource. Normally, Terraform drains all the instances before deleting the group. This bypasses that behavior and potentially leaves resources dangling | `bool` | `null` | no |
|
||||
| <a name="input_force_delete_warm_pool"></a> [force\_delete\_warm\_pool](#input\_force\_delete\_warm\_pool) | Allows deleting the Auto Scaling Group without waiting for all instances in the warm pool to terminate | `bool` | `null` | no |
|
||||
| <a name="input_health_check_grace_period"></a> [health\_check\_grace\_period](#input\_health\_check\_grace\_period) | Time (in seconds) after instance comes into service before checking health | `number` | `null` | no |
|
||||
| <a name="input_health_check_type"></a> [health\_check\_type](#input\_health\_check\_type) | `EC2` or `ELB`. Controls how health checking is done | `string` | `null` | no |
|
||||
| <a name="input_hibernation_options"></a> [hibernation\_options](#input\_hibernation\_options) | The hibernation options for the instance | `map(string)` | `{}` | no |
|
||||
| <a name="input_iam_instance_profile_arn"></a> [iam\_instance\_profile\_arn](#input\_iam\_instance\_profile\_arn) | Amazon Resource Name (ARN) of an existing IAM instance profile that provides permissions for the node group. Required if `create_iam_instance_profile` = `false` | `string` | `null` | no |
|
||||
| <a name="input_iam_role_additional_policies"></a> [iam\_role\_additional\_policies](#input\_iam\_role\_additional\_policies) | Additional policies to be added to the IAM role | `list(string)` | `[]` | no |
|
||||
| <a name="input_iam_role_additional_policies"></a> [iam\_role\_additional\_policies](#input\_iam\_role\_additional\_policies) | Additional policies to be added to the IAM role | `map(string)` | `{}` | no |
|
||||
| <a name="input_iam_role_attach_cni_policy"></a> [iam\_role\_attach\_cni\_policy](#input\_iam\_role\_attach\_cni\_policy) | Whether to attach the `AmazonEKS_CNI_Policy`/`AmazonEKS_CNI_IPv6_Policy` IAM policy to the IAM IAM role. WARNING: If set `false` the permissions must be assigned to the `aws-node` DaemonSet pods via another method or nodes will not be able to join the cluster | `bool` | `true` | no |
|
||||
| <a name="input_iam_role_description"></a> [iam\_role\_description](#input\_iam\_role\_description) | Description of the role | `string` | `null` | no |
|
||||
| <a name="input_iam_role_name"></a> [iam\_role\_name](#input\_iam\_role\_name) | Name to use on IAM role created | `string` | `null` | no |
|
||||
@@ -124,17 +126,20 @@ module "self_managed_node_group" {
|
||||
| <a name="input_initial_lifecycle_hooks"></a> [initial\_lifecycle\_hooks](#input\_initial\_lifecycle\_hooks) | One or more Lifecycle Hooks to attach to the Auto Scaling Group before instances are launched. The syntax is exactly the same as the separate `aws_autoscaling_lifecycle_hook` resource, without the `autoscaling_group_name` attribute. Please note that this will only work when creating a new Auto Scaling Group. For all other use-cases, please use `aws_autoscaling_lifecycle_hook` resource | `list(map(string))` | `[]` | no |
|
||||
| <a name="input_instance_initiated_shutdown_behavior"></a> [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Shutdown behavior for the instance. Can be `stop` or `terminate`. (Default: `stop`) | `string` | `null` | no |
|
||||
| <a name="input_instance_market_options"></a> [instance\_market\_options](#input\_instance\_market\_options) | The market (purchasing) option for the instance | `any` | `{}` | no |
|
||||
| <a name="input_instance_refresh"></a> [instance\_refresh](#input\_instance\_refresh) | If this block is configured, start an Instance Refresh when this Auto Scaling Group is updated | `any` | `{}` | no |
|
||||
| <a name="input_instance_refresh"></a> [instance\_refresh](#input\_instance\_refresh) | If this block is configured, start an Instance Refresh when this Auto Scaling Group is updated | `any` | <pre>{<br> "preferences": {<br> "min_healthy_percentage": 66<br> },<br> "strategy": "Rolling"<br>}</pre> | no |
|
||||
| <a name="input_instance_requirements"></a> [instance\_requirements](#input\_instance\_requirements) | The attribute requirements for the type of instance. If present then `instance_type` cannot be present | `any` | `{}` | no |
|
||||
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The type of the instance to launch | `string` | `""` | no |
|
||||
| <a name="input_kernel_id"></a> [kernel\_id](#input\_kernel\_id) | The kernel ID | `string` | `null` | no |
|
||||
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | The key name that should be used for the instance | `string` | `null` | no |
|
||||
| <a name="input_launch_template_default_version"></a> [launch\_template\_default\_version](#input\_launch\_template\_default\_version) | Default Version of the launch template | `string` | `null` | no |
|
||||
| <a name="input_launch_template_description"></a> [launch\_template\_description](#input\_launch\_template\_description) | Description of the launch template | `string` | `null` | no |
|
||||
| <a name="input_launch_template_name"></a> [launch\_template\_name](#input\_launch\_template\_name) | Launch template name - either to be created (`var.create_launch_template` = `true`) or existing (`var.create_launch_template` = `false`) | `string` | `null` | no |
|
||||
| <a name="input_launch_template_id"></a> [launch\_template\_id](#input\_launch\_template\_id) | The ID of an existing launch template to use. Required when `create_launch_template` = `false` | `string` | `""` | no |
|
||||
| <a name="input_launch_template_name"></a> [launch\_template\_name](#input\_launch\_template\_name) | Name of launch template to be created | `string` | `null` | no |
|
||||
| <a name="input_launch_template_tags"></a> [launch\_template\_tags](#input\_launch\_template\_tags) | A map of additional tags to add to the tag\_specifications of launch template created | `map(string)` | `{}` | no |
|
||||
| <a name="input_launch_template_use_name_prefix"></a> [launch\_template\_use\_name\_prefix](#input\_launch\_template\_use\_name\_prefix) | Determines whether to use `launch_template_name` as is or create a unique name beginning with the `launch_template_name` as the prefix | `bool` | `true` | no |
|
||||
| <a name="input_launch_template_version"></a> [launch\_template\_version](#input\_launch\_template\_version) | Launch template version. Can be version number, `$Latest`, or `$Default` | `string` | `null` | no |
|
||||
| <a name="input_license_specifications"></a> [license\_specifications](#input\_license\_specifications) | A list of license specifications to associate with | `map(string)` | `{}` | no |
|
||||
| <a name="input_license_specifications"></a> [license\_specifications](#input\_license\_specifications) | A map of license specifications to associate with | `any` | `{}` | no |
|
||||
| <a name="input_maintenance_options"></a> [maintenance\_options](#input\_maintenance\_options) | The maintenance options for the instance | `any` | `{}` | no |
|
||||
| <a name="input_max_instance_lifetime"></a> [max\_instance\_lifetime](#input\_max\_instance\_lifetime) | The maximum amount of time, in seconds, that an instance can be in service, values must be either equal to 0 or between 604800 and 31536000 seconds | `number` | `null` | no |
|
||||
| <a name="input_max_size"></a> [max\_size](#input\_max\_size) | The maximum size of the autoscaling group | `number` | `3` | no |
|
||||
| <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Customize the metadata options for the instance | `map(string)` | <pre>{<br> "http_endpoint": "enabled",<br> "http_put_response_hop_limit": 2,<br> "http_tokens": "required"<br>}</pre> | no |
|
||||
@@ -149,14 +154,10 @@ module "self_managed_node_group" {
|
||||
| <a name="input_platform"></a> [platform](#input\_platform) | Identifies if the OS platform is `bottlerocket`, `linux`, or `windows` based | `string` | `"linux"` | no |
|
||||
| <a name="input_post_bootstrap_user_data"></a> [post\_bootstrap\_user\_data](#input\_post\_bootstrap\_user\_data) | User data that is appended to the user data script after of the EKS bootstrap script. Not used when `platform` = `bottlerocket` | `string` | `""` | no |
|
||||
| <a name="input_pre_bootstrap_user_data"></a> [pre\_bootstrap\_user\_data](#input\_pre\_bootstrap\_user\_data) | User data that is injected into the user data script ahead of the EKS bootstrap script. Not used when `platform` = `bottlerocket` | `string` | `""` | no |
|
||||
| <a name="input_private_dns_name_options"></a> [private\_dns\_name\_options](#input\_private\_dns\_name\_options) | The options for the instance hostname. The default values are inherited from the subnet | `map(string)` | `{}` | no |
|
||||
| <a name="input_protect_from_scale_in"></a> [protect\_from\_scale\_in](#input\_protect\_from\_scale\_in) | Allows setting instance protection. The autoscaling group will not select instances with this setting for termination during scale in events. | `bool` | `false` | no |
|
||||
| <a name="input_ram_disk_id"></a> [ram\_disk\_id](#input\_ram\_disk\_id) | The ID of the ram disk | `string` | `null` | no |
|
||||
| <a name="input_schedules"></a> [schedules](#input\_schedules) | Map of autoscaling group schedule to create | `map(any)` | `{}` | no |
|
||||
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | Description for the security group created | `string` | `"EKS self-managed node group security group"` | no |
|
||||
| <a name="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name) | Name to use on security group created | `string` | `null` | no |
|
||||
| <a name="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules) | List of security group rules to add to the security group created | `any` | `{}` | no |
|
||||
| <a name="input_security_group_tags"></a> [security\_group\_tags](#input\_security\_group\_tags) | A map of additional tags to add to the security group created | `map(string)` | `{}` | no |
|
||||
| <a name="input_security_group_use_name_prefix"></a> [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Determines whether the security group name (`security_group_name`) is used as a prefix | `bool` | `true` | no |
|
||||
| <a name="input_service_linked_role_arn"></a> [service\_linked\_role\_arn](#input\_service\_linked\_role\_arn) | The ARN of the service-linked role that the ASG will use to call other AWS services | `string` | `null` | no |
|
||||
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | A list of subnet IDs to launch resources in. Subnets automatically determine which availability zones the group will reside. Conflicts with `availability_zones` | `list(string)` | `null` | no |
|
||||
| <a name="input_suspended_processes"></a> [suspended\_processes](#input\_suspended\_processes) | A list of processes to suspend for the Auto Scaling Group. The allowed values are `Launch`, `Terminate`, `HealthCheck`, `ReplaceUnhealthy`, `AZRebalance`, `AlarmNotification`, `ScheduledActions`, `AddToLoadBalancer`. Note that if you suspend either the `Launch` or `Terminate` process types, it can prevent your Auto Scaling Group from functioning properly | `list(string)` | `[]` | no |
|
||||
@@ -164,11 +165,9 @@ module "self_managed_node_group" {
|
||||
| <a name="input_target_group_arns"></a> [target\_group\_arns](#input\_target\_group\_arns) | A set of `aws_alb_target_group` ARNs, for use with Application or Network Load Balancing | `list(string)` | `[]` | no |
|
||||
| <a name="input_termination_policies"></a> [termination\_policies](#input\_termination\_policies) | A list of policies to decide how the instances in the Auto Scaling Group should be terminated. The allowed values are `OldestInstance`, `NewestInstance`, `OldestLaunchConfiguration`, `ClosestToNextInstanceHour`, `OldestLaunchTemplate`, `AllocationStrategy`, `Default` | `list(string)` | `[]` | no |
|
||||
| <a name="input_update_launch_template_default_version"></a> [update\_launch\_template\_default\_version](#input\_update\_launch\_template\_default\_version) | Whether to update Default Version each update. Conflicts with `launch_template_default_version` | `bool` | `true` | no |
|
||||
| <a name="input_use_default_tags"></a> [use\_default\_tags](#input\_use\_default\_tags) | Enables/disables the use of provider default tags in the tag\_specifications of the Auto Scaling group | `bool` | `false` | no |
|
||||
| <a name="input_use_mixed_instances_policy"></a> [use\_mixed\_instances\_policy](#input\_use\_mixed\_instances\_policy) | Determines whether to use a mixed instances policy in the autoscaling group or not | `bool` | `false` | no |
|
||||
| <a name="input_use_name_prefix"></a> [use\_name\_prefix](#input\_use\_name\_prefix) | Determines whether to use `name` as is or create a unique name beginning with the `name` as the prefix | `bool` | `true` | no |
|
||||
| <a name="input_user_data_template_path"></a> [user\_data\_template\_path](#input\_user\_data\_template\_path) | Path to a local, custom user data template file to use when rendering user data | `string` | `""` | no |
|
||||
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | ID of the VPC where the security group/nodes will be provisioned | `string` | `null` | no |
|
||||
| <a name="input_vpc_security_group_ids"></a> [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | A list of security group IDs to associate | `list(string)` | `[]` | no |
|
||||
| <a name="input_wait_for_capacity_timeout"></a> [wait\_for\_capacity\_timeout](#input\_wait\_for\_capacity\_timeout) | A maximum duration that Terraform should wait for ASG instances to be healthy before timing out. (See also Waiting for Capacity below.) Setting this to '0' causes Terraform to skip all Capacity Waiting behavior. | `string` | `null` | no |
|
||||
| <a name="input_wait_for_elb_capacity"></a> [wait\_for\_elb\_capacity](#input\_wait\_for\_elb\_capacity) | Setting this will cause Terraform to wait for exactly this number of healthy instances in all attached load balancers on both create and update operations. Takes precedence over `min_elb_capacity` behavior. | `number` | `null` | no |
|
||||
@@ -202,7 +201,5 @@ module "self_managed_node_group" {
|
||||
| <a name="output_launch_template_latest_version"></a> [launch\_template\_latest\_version](#output\_launch\_template\_latest\_version) | The latest version of the launch template |
|
||||
| <a name="output_launch_template_name"></a> [launch\_template\_name](#output\_launch\_template\_name) | The name of the launch template |
|
||||
| <a name="output_platform"></a> [platform](#output\_platform) | Identifies if the OS platform is `bottlerocket`, `linux`, or `windows` based |
|
||||
| <a name="output_security_group_arn"></a> [security\_group\_arn](#output\_security\_group\_arn) | Amazon Resource Name (ARN) of the security group |
|
||||
| <a name="output_security_group_id"></a> [security\_group\_id](#output\_security\_group\_id) | ID of the security group |
|
||||
| <a name="output_user_data"></a> [user\_data](#output\_user\_data) | Base64 encoded user data |
|
||||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
data "aws_partition" "current" {}
|
||||
|
||||
data "aws_caller_identity" "current" {}
|
||||
|
||||
data "aws_default_tags" "current" {}
|
||||
|
||||
data "aws_ami" "eks_default" {
|
||||
count = var.create ? 1 : 0
|
||||
|
||||
@@ -43,65 +40,51 @@ module "user_data" {
|
||||
################################################################################
|
||||
|
||||
locals {
|
||||
launch_template_name_int = coalesce(var.launch_template_name, "${var.name}-node-group")
|
||||
|
||||
security_group_ids = compact(concat([try(aws_security_group.this[0].id, ""), var.cluster_primary_security_group_id], var.vpc_security_group_ids))
|
||||
launch_template_name = coalesce(var.launch_template_name, "${var.name}-node-group")
|
||||
security_group_ids = compact(concat([var.cluster_primary_security_group_id], var.vpc_security_group_ids))
|
||||
}
|
||||
|
||||
resource "aws_launch_template" "this" {
|
||||
count = var.create && var.create_launch_template ? 1 : 0
|
||||
|
||||
name = var.launch_template_use_name_prefix ? null : local.launch_template_name_int
|
||||
name_prefix = var.launch_template_use_name_prefix ? "${local.launch_template_name_int}-" : null
|
||||
description = var.launch_template_description
|
||||
|
||||
ebs_optimized = var.ebs_optimized
|
||||
image_id = coalesce(var.ami_id, data.aws_ami.eks_default[0].image_id)
|
||||
instance_type = var.instance_type
|
||||
key_name = var.key_name
|
||||
user_data = module.user_data.user_data
|
||||
|
||||
vpc_security_group_ids = length(var.network_interfaces) > 0 ? [] : local.security_group_ids
|
||||
|
||||
default_version = var.launch_template_default_version
|
||||
update_default_version = var.update_launch_template_default_version
|
||||
disable_api_termination = var.disable_api_termination
|
||||
instance_initiated_shutdown_behavior = var.instance_initiated_shutdown_behavior
|
||||
kernel_id = var.kernel_id
|
||||
ram_disk_id = var.ram_disk_id
|
||||
|
||||
dynamic "block_device_mappings" {
|
||||
for_each = var.block_device_mappings
|
||||
|
||||
content {
|
||||
device_name = block_device_mappings.value.device_name
|
||||
no_device = lookup(block_device_mappings.value, "no_device", null)
|
||||
virtual_name = lookup(block_device_mappings.value, "virtual_name", null)
|
||||
device_name = try(block_device_mappings.value.device_name, null)
|
||||
|
||||
dynamic "ebs" {
|
||||
for_each = flatten([lookup(block_device_mappings.value, "ebs", [])])
|
||||
for_each = try([block_device_mappings.value.ebs], [])
|
||||
|
||||
content {
|
||||
delete_on_termination = lookup(ebs.value, "delete_on_termination", null)
|
||||
encrypted = lookup(ebs.value, "encrypted", null)
|
||||
kms_key_id = lookup(ebs.value, "kms_key_id", null)
|
||||
iops = lookup(ebs.value, "iops", null)
|
||||
throughput = lookup(ebs.value, "throughput", null)
|
||||
snapshot_id = lookup(ebs.value, "snapshot_id", null)
|
||||
volume_size = lookup(ebs.value, "volume_size", null)
|
||||
volume_type = lookup(ebs.value, "volume_type", null)
|
||||
delete_on_termination = try(ebs.value.delete_on_termination, null)
|
||||
encrypted = try(ebs.value.encrypted, null)
|
||||
iops = try(ebs.value.iops, null)
|
||||
kms_key_id = try(ebs.value.kms_key_id, null)
|
||||
snapshot_id = try(ebs.value.snapshot_id, null)
|
||||
throughput = try(ebs.value.throughput, null)
|
||||
volume_size = try(ebs.value.volume_size, null)
|
||||
volume_type = try(ebs.value.volume_type, null)
|
||||
}
|
||||
}
|
||||
|
||||
no_device = try(block_device_mappings.value.no_device, null)
|
||||
virtual_name = try(block_device_mappings.value.virtual_name, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "capacity_reservation_specification" {
|
||||
for_each = length(var.capacity_reservation_specification) > 0 ? [var.capacity_reservation_specification] : []
|
||||
|
||||
content {
|
||||
capacity_reservation_preference = lookup(capacity_reservation_specification.value, "capacity_reservation_preference", null)
|
||||
capacity_reservation_preference = try(capacity_reservation_specification.value.capacity_reservation_preference, null)
|
||||
|
||||
dynamic "capacity_reservation_target" {
|
||||
for_each = try([capacity_reservation_specification.value.capacity_reservation_target], [])
|
||||
|
||||
content {
|
||||
capacity_reservation_id = lookup(capacity_reservation_target.value, "capacity_reservation_id", null)
|
||||
capacity_reservation_id = try(capacity_reservation_target.value.capacity_reservation_id, null)
|
||||
capacity_reservation_resource_group_arn = try(capacity_reservation_target.value.capacity_reservation_resource_group_arn, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,21 +92,29 @@ resource "aws_launch_template" "this" {
|
||||
|
||||
dynamic "cpu_options" {
|
||||
for_each = length(var.cpu_options) > 0 ? [var.cpu_options] : []
|
||||
|
||||
content {
|
||||
core_count = cpu_options.value.core_count
|
||||
threads_per_core = cpu_options.value.threads_per_core
|
||||
core_count = try(cpu_options.value.core_count, null)
|
||||
threads_per_core = try(cpu_options.value.threads_per_core, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "credit_specification" {
|
||||
for_each = length(var.credit_specification) > 0 ? [var.credit_specification] : []
|
||||
|
||||
content {
|
||||
cpu_credits = credit_specification.value.cpu_credits
|
||||
cpu_credits = try(credit_specification.value.cpu_credits, null)
|
||||
}
|
||||
}
|
||||
|
||||
default_version = var.launch_template_default_version
|
||||
description = var.launch_template_description
|
||||
disable_api_termination = var.disable_api_termination
|
||||
ebs_optimized = var.ebs_optimized
|
||||
|
||||
dynamic "elastic_gpu_specifications" {
|
||||
for_each = length(var.elastic_gpu_specifications) > 0 ? [var.elastic_gpu_specifications] : []
|
||||
for_each = var.elastic_gpu_specifications
|
||||
|
||||
content {
|
||||
type = elastic_gpu_specifications.value.type
|
||||
}
|
||||
@@ -131,6 +122,7 @@ resource "aws_launch_template" "this" {
|
||||
|
||||
dynamic "elastic_inference_accelerator" {
|
||||
for_each = length(var.elastic_inference_accelerator) > 0 ? [var.elastic_inference_accelerator] : []
|
||||
|
||||
content {
|
||||
type = elastic_inference_accelerator.value.type
|
||||
}
|
||||
@@ -138,6 +130,7 @@ resource "aws_launch_template" "this" {
|
||||
|
||||
dynamic "enclave_options" {
|
||||
for_each = length(var.enclave_options) > 0 ? [var.enclave_options] : []
|
||||
|
||||
content {
|
||||
enabled = enclave_options.value.enabled
|
||||
}
|
||||
@@ -145,6 +138,7 @@ resource "aws_launch_template" "this" {
|
||||
|
||||
dynamic "hibernation_options" {
|
||||
for_each = length(var.hibernation_options) > 0 ? [var.hibernation_options] : []
|
||||
|
||||
content {
|
||||
configured = hibernation_options.value.configured
|
||||
}
|
||||
@@ -154,102 +148,245 @@ resource "aws_launch_template" "this" {
|
||||
arn = var.create_iam_instance_profile ? aws_iam_instance_profile.this[0].arn : var.iam_instance_profile_arn
|
||||
}
|
||||
|
||||
image_id = coalesce(var.ami_id, data.aws_ami.eks_default[0].image_id)
|
||||
instance_initiated_shutdown_behavior = var.instance_initiated_shutdown_behavior
|
||||
|
||||
dynamic "instance_market_options" {
|
||||
for_each = length(var.instance_market_options) > 0 ? [var.instance_market_options] : []
|
||||
|
||||
content {
|
||||
market_type = instance_market_options.value.market_type
|
||||
market_type = try(instance_market_options.value.market_type, null)
|
||||
|
||||
dynamic "spot_options" {
|
||||
for_each = length(lookup(instance_market_options.value, "spot_options", {})) > 0 ? [instance_market_options.value.spot_options] : []
|
||||
for_each = try([instance_market_options.value.spot_options], [])
|
||||
|
||||
content {
|
||||
block_duration_minutes = lookup(spot_options.value, "block_duration_minutes", null)
|
||||
instance_interruption_behavior = lookup(spot_options.value, "instance_interruption_behavior", null)
|
||||
max_price = lookup(spot_options.value, "max_price", null)
|
||||
spot_instance_type = lookup(spot_options.value, "spot_instance_type", null)
|
||||
valid_until = lookup(spot_options.value, "valid_until", null)
|
||||
block_duration_minutes = try(spot_options.value.block_duration_minutes, null)
|
||||
instance_interruption_behavior = try(spot_options.value.instance_interruption_behavior, null)
|
||||
max_price = try(spot_options.value.max_price, null)
|
||||
spot_instance_type = try(spot_options.value.spot_instance_type, null)
|
||||
valid_until = try(spot_options.value.valid_until, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "instance_requirements" {
|
||||
for_each = length(var.instance_requirements) > 0 ? [var.instance_requirements] : []
|
||||
|
||||
content {
|
||||
|
||||
dynamic "accelerator_count" {
|
||||
for_each = try([instance_requirements.value.accelerator_count], [])
|
||||
|
||||
content {
|
||||
max = try(accelerator_count.value.max, null)
|
||||
min = try(accelerator_count.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
accelerator_manufacturers = try(instance_requirements.value.accelerator_manufacturers, [])
|
||||
accelerator_names = try(instance_requirements.value.accelerator_names, [])
|
||||
|
||||
dynamic "accelerator_total_memory_mib" {
|
||||
for_each = try([instance_requirements.value.accelerator_total_memory_mib], [])
|
||||
|
||||
content {
|
||||
max = try(accelerator_total_memory_mib.value.max, null)
|
||||
min = try(accelerator_total_memory_mib.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
accelerator_types = try(instance_requirements.value.accelerator_types, [])
|
||||
bare_metal = try(instance_requirements.value.bare_metal, null)
|
||||
|
||||
dynamic "baseline_ebs_bandwidth_mbps" {
|
||||
for_each = try([instance_requirements.value.baseline_ebs_bandwidth_mbps], [])
|
||||
|
||||
content {
|
||||
max = try(baseline_ebs_bandwidth_mbps.value.max, null)
|
||||
min = try(baseline_ebs_bandwidth_mbps.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
burstable_performance = try(instance_requirements.value.burstable_performance, null)
|
||||
cpu_manufacturers = try(instance_requirements.value.cpu_manufacturers, [])
|
||||
excluded_instance_types = try(instance_requirements.value.excluded_instance_types, [])
|
||||
instance_generations = try(instance_requirements.value.instance_generations, [])
|
||||
local_storage = try(instance_requirements.value.local_storage, null)
|
||||
local_storage_types = try(instance_requirements.value.local_storage_types, [])
|
||||
|
||||
dynamic "memory_gib_per_vcpu" {
|
||||
for_each = try([instance_requirements.value.memory_gib_per_vcpu], [])
|
||||
|
||||
content {
|
||||
max = try(memory_gib_per_vcpu.value.max, null)
|
||||
min = try(memory_gib_per_vcpu.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "memory_mib" {
|
||||
for_each = [instance_requirements.value.memory_mib]
|
||||
|
||||
content {
|
||||
max = try(memory_mib.value.max, null)
|
||||
min = memory_mib.value.min
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "network_interface_count" {
|
||||
for_each = try([instance_requirements.value.network_interface_count], [])
|
||||
|
||||
content {
|
||||
max = try(network_interface_count.value.max, null)
|
||||
min = try(network_interface_count.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
on_demand_max_price_percentage_over_lowest_price = try(instance_requirements.value.on_demand_max_price_percentage_over_lowest_price, null)
|
||||
require_hibernate_support = try(instance_requirements.value.require_hibernate_support, null)
|
||||
spot_max_price_percentage_over_lowest_price = try(instance_requirements.value.spot_max_price_percentage_over_lowest_price, null)
|
||||
|
||||
dynamic "total_local_storage_gb" {
|
||||
for_each = try([instance_requirements.value.total_local_storage_gb], [])
|
||||
|
||||
content {
|
||||
max = try(total_local_storage_gb.value.max, null)
|
||||
min = try(total_local_storage_gb.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "vcpu_count" {
|
||||
for_each = [instance_requirements.value.vcpu_count]
|
||||
|
||||
content {
|
||||
max = try(vcpu_count.value.max, null)
|
||||
min = vcpu_count.value.min
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
instance_type = var.instance_type
|
||||
kernel_id = var.kernel_id
|
||||
key_name = var.key_name
|
||||
|
||||
dynamic "license_specification" {
|
||||
for_each = length(var.license_specifications) > 0 ? [var.license_specifications] : []
|
||||
for_each = length(var.license_specifications) > 0 ? var.license_specifications : {}
|
||||
|
||||
content {
|
||||
license_configuration_arn = license_specifications.value.license_configuration_arn
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "maintenance_options" {
|
||||
for_each = length(var.maintenance_options) > 0 ? [var.maintenance_options] : []
|
||||
|
||||
content {
|
||||
auto_recovery = try(maintenance_options.value.auto_recovery, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "metadata_options" {
|
||||
for_each = length(var.metadata_options) > 0 ? [var.metadata_options] : []
|
||||
|
||||
content {
|
||||
http_endpoint = lookup(metadata_options.value, "http_endpoint", null)
|
||||
http_tokens = lookup(metadata_options.value, "http_tokens", null)
|
||||
http_put_response_hop_limit = lookup(metadata_options.value, "http_put_response_hop_limit", null)
|
||||
http_protocol_ipv6 = lookup(metadata_options.value, "http_protocol_ipv6", null)
|
||||
instance_metadata_tags = lookup(metadata_options.value, "instance_metadata_tags", null)
|
||||
http_endpoint = try(metadata_options.value.http_endpoint, null)
|
||||
http_protocol_ipv6 = try(metadata_options.value.http_protocol_ipv6, null)
|
||||
http_put_response_hop_limit = try(metadata_options.value.http_put_response_hop_limit, null)
|
||||
http_tokens = try(metadata_options.value.http_tokens, null)
|
||||
instance_metadata_tags = try(metadata_options.value.instance_metadata_tags, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "monitoring" {
|
||||
for_each = var.enable_monitoring != null ? [1] : []
|
||||
for_each = var.enable_monitoring ? [1] : []
|
||||
|
||||
content {
|
||||
enabled = var.enable_monitoring
|
||||
}
|
||||
}
|
||||
|
||||
name = var.launch_template_use_name_prefix ? null : local.launch_template_name
|
||||
name_prefix = var.launch_template_use_name_prefix ? "${local.launch_template_name}-" : null
|
||||
|
||||
dynamic "network_interfaces" {
|
||||
for_each = var.network_interfaces
|
||||
content {
|
||||
associate_carrier_ip_address = lookup(network_interfaces.value, "associate_carrier_ip_address", null)
|
||||
associate_public_ip_address = lookup(network_interfaces.value, "associate_public_ip_address", null)
|
||||
delete_on_termination = lookup(network_interfaces.value, "delete_on_termination", null)
|
||||
description = lookup(network_interfaces.value, "description", null)
|
||||
device_index = lookup(network_interfaces.value, "device_index", null)
|
||||
interface_type = lookup(network_interfaces.value, "interface_type", null)
|
||||
associate_carrier_ip_address = try(network_interfaces.value.associate_carrier_ip_address, null)
|
||||
associate_public_ip_address = try(network_interfaces.value.associate_public_ip_address, null)
|
||||
delete_on_termination = try(network_interfaces.value.delete_on_termination, null)
|
||||
description = try(network_interfaces.value.description, null)
|
||||
device_index = try(network_interfaces.value.device_index, null)
|
||||
interface_type = try(network_interfaces.value.interface_type, null)
|
||||
ipv4_address_count = try(network_interfaces.value.ipv4_address_count, null)
|
||||
ipv4_addresses = try(network_interfaces.value.ipv4_addresses, [])
|
||||
ipv4_address_count = lookup(network_interfaces.value, "ipv4_address_count", null)
|
||||
ipv4_prefix_count = try(network_interfaces.value.ipv4_prefix_count, null)
|
||||
ipv4_prefixes = try(network_interfaces.value.ipv4_prefixes, null)
|
||||
ipv6_address_count = try(network_interfaces.value.ipv6_address_count, null)
|
||||
ipv6_addresses = try(network_interfaces.value.ipv6_addresses, [])
|
||||
ipv6_address_count = lookup(network_interfaces.value, "ipv6_address_count", null)
|
||||
network_interface_id = lookup(network_interfaces.value, "network_interface_id", null)
|
||||
private_ip_address = lookup(network_interfaces.value, "private_ip_address", null)
|
||||
security_groups = compact(concat(try(network_interfaces.value.security_groups, []), local.security_group_ids))
|
||||
subnet_id = lookup(network_interfaces.value, "subnet_id", null)
|
||||
ipv6_prefix_count = try(network_interfaces.value.ipv6_prefix_count, null)
|
||||
ipv6_prefixes = try(network_interfaces.value.ipv6_prefixes, [])
|
||||
network_card_index = try(network_interfaces.value.network_card_index, null)
|
||||
network_interface_id = try(network_interfaces.value.network_interface_id, null)
|
||||
private_ip_address = try(network_interfaces.value.private_ip_address, null)
|
||||
# Ref: https://github.com/hashicorp/terraform-provider-aws/issues/4570
|
||||
security_groups = compact(concat(try(network_interfaces.value.security_groups, []), local.security_group_ids))
|
||||
subnet_id = try(network_interfaces.value.subnet_id, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "placement" {
|
||||
for_each = length(var.placement) > 0 ? [var.placement] : []
|
||||
|
||||
content {
|
||||
affinity = lookup(placement.value, "affinity", null)
|
||||
availability_zone = lookup(placement.value, "availability_zone", null)
|
||||
group_name = lookup(placement.value, "group_name", null)
|
||||
host_id = lookup(placement.value, "host_id", null)
|
||||
spread_domain = lookup(placement.value, "spread_domain", null)
|
||||
tenancy = lookup(placement.value, "tenancy", null)
|
||||
partition_number = lookup(placement.value, "partition_number", null)
|
||||
affinity = try(placement.value.affinity, null)
|
||||
availability_zone = try(placement.value.availability_zone, null)
|
||||
group_name = try(placement.value.group_name, null)
|
||||
host_id = try(placement.value.host_id, null)
|
||||
host_resource_group_arn = try(placement.value.host_resource_group_arn, null)
|
||||
partition_number = try(placement.value.partition_number, null)
|
||||
spread_domain = try(placement.value.spread_domain, null)
|
||||
tenancy = try(placement.value.tenancy, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "private_dns_name_options" {
|
||||
for_each = length(var.private_dns_name_options) > 0 ? [var.private_dns_name_options] : []
|
||||
|
||||
content {
|
||||
enable_resource_name_dns_aaaa_record = try(private_dns_name_options.value.enable_resource_name_dns_aaaa_record, null)
|
||||
enable_resource_name_dns_a_record = try(private_dns_name_options.value.enable_resource_name_dns_a_record, null)
|
||||
hostname_type = try(private_dns_name_options.value.hostname_type, null)
|
||||
}
|
||||
}
|
||||
|
||||
ram_disk_id = var.ram_disk_id
|
||||
|
||||
dynamic "tag_specifications" {
|
||||
for_each = toset(["instance", "volume", "network-interface"])
|
||||
|
||||
content {
|
||||
resource_type = tag_specifications.key
|
||||
tags = merge(var.tags, { Name = var.name }, var.launch_template_tags)
|
||||
}
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
update_default_version = var.update_launch_template_default_version
|
||||
user_data = module.user_data.user_data
|
||||
vpc_security_group_ids = length(var.network_interfaces) > 0 ? [] : local.security_group_ids
|
||||
|
||||
# Prevent premature access of security group roles and policies by pods that
|
||||
tags = var.tags
|
||||
|
||||
# Prevent premature access of policies by pods that
|
||||
# require permissions on create/destroy that depend on nodes
|
||||
depends_on = [
|
||||
aws_security_group_rule.this,
|
||||
aws_iam_role_policy_attachment.this,
|
||||
]
|
||||
|
||||
tags = var.tags
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -257,7 +394,7 @@ resource "aws_launch_template" "this" {
|
||||
################################################################################
|
||||
|
||||
locals {
|
||||
launch_template_name = try(aws_launch_template.this[0].name, var.launch_template_name)
|
||||
launch_template_id = var.create && var.create_launch_template ? aws_launch_template.this[0].id : var.launch_template_id
|
||||
# Change order to allow users to set version priority before using defaults
|
||||
launch_template_version = coalesce(var.launch_template_version, try(aws_launch_template.this[0].default_version, "$Default"))
|
||||
}
|
||||
@@ -265,123 +402,215 @@ locals {
|
||||
resource "aws_autoscaling_group" "this" {
|
||||
count = var.create && var.create_autoscaling_group ? 1 : 0
|
||||
|
||||
name = var.use_name_prefix ? null : var.name
|
||||
name_prefix = var.use_name_prefix ? "${var.name}-" : null
|
||||
|
||||
dynamic "launch_template" {
|
||||
for_each = var.use_mixed_instances_policy ? [] : [1]
|
||||
|
||||
content {
|
||||
name = local.launch_template_name
|
||||
version = local.launch_template_version
|
||||
}
|
||||
}
|
||||
|
||||
availability_zones = var.availability_zones
|
||||
vpc_zone_identifier = var.subnet_ids
|
||||
|
||||
min_size = var.min_size
|
||||
max_size = var.max_size
|
||||
desired_capacity = var.desired_size
|
||||
availability_zones = var.availability_zones
|
||||
capacity_rebalance = var.capacity_rebalance
|
||||
min_elb_capacity = var.min_elb_capacity
|
||||
wait_for_elb_capacity = var.wait_for_elb_capacity
|
||||
wait_for_capacity_timeout = var.wait_for_capacity_timeout
|
||||
context = var.context
|
||||
default_cooldown = var.default_cooldown
|
||||
protect_from_scale_in = var.protect_from_scale_in
|
||||
|
||||
target_group_arns = var.target_group_arns
|
||||
placement_group = var.placement_group
|
||||
health_check_type = var.health_check_type
|
||||
default_instance_warmup = var.default_instance_warmup
|
||||
desired_capacity = var.desired_size
|
||||
enabled_metrics = var.enabled_metrics
|
||||
force_delete = var.force_delete
|
||||
force_delete_warm_pool = var.force_delete_warm_pool
|
||||
health_check_grace_period = var.health_check_grace_period
|
||||
|
||||
force_delete = var.force_delete
|
||||
termination_policies = var.termination_policies
|
||||
suspended_processes = var.suspended_processes
|
||||
max_instance_lifetime = var.max_instance_lifetime
|
||||
|
||||
enabled_metrics = var.enabled_metrics
|
||||
metrics_granularity = var.metrics_granularity
|
||||
service_linked_role_arn = var.service_linked_role_arn
|
||||
health_check_type = var.health_check_type
|
||||
|
||||
dynamic "initial_lifecycle_hook" {
|
||||
for_each = var.initial_lifecycle_hooks
|
||||
|
||||
content {
|
||||
name = initial_lifecycle_hook.value.name
|
||||
default_result = lookup(initial_lifecycle_hook.value, "default_result", null)
|
||||
heartbeat_timeout = lookup(initial_lifecycle_hook.value, "heartbeat_timeout", null)
|
||||
default_result = try(initial_lifecycle_hook.value.default_result, null)
|
||||
heartbeat_timeout = try(initial_lifecycle_hook.value.heartbeat_timeout, null)
|
||||
lifecycle_transition = initial_lifecycle_hook.value.lifecycle_transition
|
||||
notification_metadata = lookup(initial_lifecycle_hook.value, "notification_metadata", null)
|
||||
notification_target_arn = lookup(initial_lifecycle_hook.value, "notification_target_arn", null)
|
||||
role_arn = lookup(initial_lifecycle_hook.value, "role_arn", null)
|
||||
name = initial_lifecycle_hook.value.name
|
||||
notification_metadata = try(initial_lifecycle_hook.value.notification_metadata, null)
|
||||
notification_target_arn = try(initial_lifecycle_hook.value.notification_target_arn, null)
|
||||
role_arn = try(initial_lifecycle_hook.value.role_arn, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "instance_refresh" {
|
||||
for_each = length(var.instance_refresh) > 0 ? [var.instance_refresh] : []
|
||||
content {
|
||||
strategy = instance_refresh.value.strategy
|
||||
triggers = lookup(instance_refresh.value, "triggers", null)
|
||||
|
||||
content {
|
||||
dynamic "preferences" {
|
||||
for_each = length(lookup(instance_refresh.value, "preferences", {})) > 0 ? [instance_refresh.value.preferences] : []
|
||||
for_each = try([instance_refresh.value.preferences], [])
|
||||
|
||||
content {
|
||||
instance_warmup = lookup(preferences.value, "instance_warmup", null)
|
||||
min_healthy_percentage = lookup(preferences.value, "min_healthy_percentage", null)
|
||||
checkpoint_delay = lookup(preferences.value, "checkpoint_delay", null)
|
||||
checkpoint_percentages = lookup(preferences.value, "checkpoint_percentages", null)
|
||||
checkpoint_delay = try(preferences.value.checkpoint_delay, null)
|
||||
checkpoint_percentages = try(preferences.value.checkpoint_percentages, null)
|
||||
instance_warmup = try(preferences.value.instance_warmup, null)
|
||||
min_healthy_percentage = try(preferences.value.min_healthy_percentage, null)
|
||||
skip_matching = try(preferences.value.skip_matching, null)
|
||||
}
|
||||
}
|
||||
|
||||
strategy = instance_refresh.value.strategy
|
||||
triggers = try(instance_refresh.value.triggers, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "launch_template" {
|
||||
for_each = var.use_mixed_instances_policy ? [] : [1]
|
||||
|
||||
content {
|
||||
id = local.launch_template_id
|
||||
version = local.launch_template_version
|
||||
}
|
||||
}
|
||||
|
||||
max_instance_lifetime = var.max_instance_lifetime
|
||||
max_size = var.max_size
|
||||
metrics_granularity = var.metrics_granularity
|
||||
min_elb_capacity = var.min_elb_capacity
|
||||
min_size = var.min_size
|
||||
|
||||
dynamic "mixed_instances_policy" {
|
||||
for_each = var.use_mixed_instances_policy ? [var.mixed_instances_policy] : []
|
||||
|
||||
content {
|
||||
dynamic "instances_distribution" {
|
||||
for_each = try([mixed_instances_policy.value.instances_distribution], [])
|
||||
|
||||
content {
|
||||
on_demand_allocation_strategy = lookup(instances_distribution.value, "on_demand_allocation_strategy", null)
|
||||
on_demand_base_capacity = lookup(instances_distribution.value, "on_demand_base_capacity", null)
|
||||
on_demand_percentage_above_base_capacity = lookup(instances_distribution.value, "on_demand_percentage_above_base_capacity", null)
|
||||
spot_allocation_strategy = lookup(instances_distribution.value, "spot_allocation_strategy", null)
|
||||
spot_instance_pools = lookup(instances_distribution.value, "spot_instance_pools", null)
|
||||
spot_max_price = lookup(instances_distribution.value, "spot_max_price", null)
|
||||
on_demand_allocation_strategy = try(instances_distribution.value.on_demand_allocation_strategy, null)
|
||||
on_demand_base_capacity = try(instances_distribution.value.on_demand_base_capacity, null)
|
||||
on_demand_percentage_above_base_capacity = try(instances_distribution.value.on_demand_percentage_above_base_capacity, null)
|
||||
spot_allocation_strategy = try(instances_distribution.value.spot_allocation_strategy, null)
|
||||
spot_instance_pools = try(instances_distribution.value.spot_instance_pools, null)
|
||||
spot_max_price = try(instances_distribution.value.spot_max_price, null)
|
||||
}
|
||||
}
|
||||
|
||||
launch_template {
|
||||
launch_template_specification {
|
||||
launch_template_name = local.launch_template_name
|
||||
version = local.launch_template_version
|
||||
launch_template_id = local.launch_template_id
|
||||
version = local.launch_template_version
|
||||
}
|
||||
|
||||
dynamic "override" {
|
||||
for_each = try(mixed_instances_policy.value.override, [])
|
||||
content {
|
||||
instance_type = lookup(override.value, "instance_type", null)
|
||||
weighted_capacity = lookup(override.value, "weighted_capacity", null)
|
||||
|
||||
dynamic "launch_template_specification" {
|
||||
for_each = length(lookup(override.value, "launch_template_specification", {})) > 0 ? override.value.launch_template_specification : []
|
||||
content {
|
||||
dynamic "instance_requirements" {
|
||||
for_each = try([override.value.instance_requirements], [])
|
||||
|
||||
content {
|
||||
launch_template_id = lookup(launch_template_specification.value, "launch_template_id", null)
|
||||
|
||||
dynamic "accelerator_count" {
|
||||
for_each = try([instance_requirements.value.accelerator_count], [])
|
||||
|
||||
content {
|
||||
max = try(accelerator_count.value.max, null)
|
||||
min = try(accelerator_count.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
accelerator_manufacturers = try(instance_requirements.value.accelerator_manufacturers, [])
|
||||
accelerator_names = try(instance_requirements.value.accelerator_names, [])
|
||||
|
||||
dynamic "accelerator_total_memory_mib" {
|
||||
for_each = try([instance_requirements.value.accelerator_total_memory_mib], [])
|
||||
|
||||
content {
|
||||
max = try(accelerator_total_memory_mib.value.max, null)
|
||||
min = try(accelerator_total_memory_mib.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
accelerator_types = try(instance_requirements.value.accelerator_types, [])
|
||||
bare_metal = try(instance_requirements.value.bare_metal, null)
|
||||
|
||||
dynamic "baseline_ebs_bandwidth_mbps" {
|
||||
for_each = try([instance_requirements.value.baseline_ebs_bandwidth_mbps], [])
|
||||
|
||||
content {
|
||||
max = try(baseline_ebs_bandwidth_mbps.value.max, null)
|
||||
min = try(baseline_ebs_bandwidth_mbps.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
burstable_performance = try(instance_requirements.value.burstable_performance, null)
|
||||
cpu_manufacturers = try(instance_requirements.value.cpu_manufacturers, [])
|
||||
excluded_instance_types = try(instance_requirements.value.excluded_instance_types, [])
|
||||
instance_generations = try(instance_requirements.value.instance_generations, [])
|
||||
local_storage = try(instance_requirements.value.local_storage, null)
|
||||
local_storage_types = try(instance_requirements.value.local_storage_types, [])
|
||||
|
||||
dynamic "memory_gib_per_vcpu" {
|
||||
for_each = try([instance_requirements.value.memory_gib_per_vcpu], [])
|
||||
|
||||
content {
|
||||
max = try(memory_gib_per_vcpu.value.max, null)
|
||||
min = try(memory_gib_per_vcpu.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "memory_mib" {
|
||||
for_each = [instance_requirements.value.memory_mib]
|
||||
|
||||
content {
|
||||
max = try(memory_mib.value.max, null)
|
||||
min = memory_mib.value.min
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "network_interface_count" {
|
||||
for_each = try([instance_requirements.value.network_interface_count], [])
|
||||
|
||||
content {
|
||||
max = try(network_interface_count.value.max, null)
|
||||
min = try(network_interface_count.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
on_demand_max_price_percentage_over_lowest_price = try(instance_requirements.value.on_demand_max_price_percentage_over_lowest_price, null)
|
||||
require_hibernate_support = try(instance_requirements.value.require_hibernate_support, null)
|
||||
spot_max_price_percentage_over_lowest_price = try(instance_requirements.value.spot_max_price_percentage_over_lowest_price, null)
|
||||
|
||||
dynamic "total_local_storage_gb" {
|
||||
for_each = try([instance_requirements.value.total_local_storage_gb], [])
|
||||
|
||||
content {
|
||||
max = try(total_local_storage_gb.value.max, null)
|
||||
min = try(total_local_storage_gb.value.min, null)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "vcpu_count" {
|
||||
for_each = [instance_requirements.value.vcpu_count]
|
||||
|
||||
content {
|
||||
max = try(vcpu_count.value.max, null)
|
||||
min = vcpu_count.value.min
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
instance_type = try(override.value.instance_type, null)
|
||||
|
||||
dynamic "launch_template_specification" {
|
||||
for_each = try([override.value.launch_template_specification], [])
|
||||
|
||||
content {
|
||||
launch_template_id = try(launch_template_specification.value.launch_template_id, null)
|
||||
version = try(launch_template_specification.value.version, null)
|
||||
}
|
||||
}
|
||||
|
||||
weighted_capacity = try(override.value.weighted_capacity, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "warm_pool" {
|
||||
for_each = length(var.warm_pool) > 0 ? [var.warm_pool] : []
|
||||
content {
|
||||
pool_state = lookup(warm_pool.value, "pool_state", null)
|
||||
min_size = lookup(warm_pool.value, "min_size", null)
|
||||
max_group_prepared_capacity = lookup(warm_pool.value, "max_group_prepared_capacity", null)
|
||||
}
|
||||
}
|
||||
name = var.use_name_prefix ? null : var.name
|
||||
name_prefix = var.use_name_prefix ? "${var.name}-" : null
|
||||
placement_group = var.placement_group
|
||||
protect_from_scale_in = var.protect_from_scale_in
|
||||
service_linked_role_arn = var.service_linked_role_arn
|
||||
suspended_processes = var.suspended_processes
|
||||
|
||||
dynamic "tag" {
|
||||
for_each = merge(
|
||||
@@ -390,7 +619,7 @@ resource "aws_autoscaling_group" "this" {
|
||||
"kubernetes.io/cluster/${var.cluster_name}" = "owned"
|
||||
"k8s.io/cluster/${var.cluster_name}" = "owned"
|
||||
},
|
||||
var.use_default_tags ? merge(data.aws_default_tags.current.tags, var.tags) : var.tags
|
||||
var.tags
|
||||
)
|
||||
|
||||
content {
|
||||
@@ -410,6 +639,30 @@ resource "aws_autoscaling_group" "this" {
|
||||
}
|
||||
}
|
||||
|
||||
target_group_arns = var.target_group_arns
|
||||
termination_policies = var.termination_policies
|
||||
vpc_zone_identifier = var.subnet_ids
|
||||
wait_for_capacity_timeout = var.wait_for_capacity_timeout
|
||||
wait_for_elb_capacity = var.wait_for_elb_capacity
|
||||
|
||||
dynamic "warm_pool" {
|
||||
for_each = length(var.warm_pool) > 0 ? [var.warm_pool] : []
|
||||
|
||||
content {
|
||||
dynamic "instance_reuse_policy" {
|
||||
for_each = try([warm_pool.value.instance_reuse_policy], [])
|
||||
|
||||
content {
|
||||
reuse_on_scale_in = try(instance_reuse_policy.value.reuse_on_scale_in, null)
|
||||
}
|
||||
}
|
||||
|
||||
max_group_prepared_capacity = try(warm_pool.value.max_group_prepared_capacity, null)
|
||||
min_size = try(warm_pool.value.min_size, null)
|
||||
pool_state = try(warm_pool.value.pool_state, null)
|
||||
}
|
||||
}
|
||||
|
||||
timeouts {
|
||||
delete = var.delete_timeout
|
||||
}
|
||||
@@ -432,70 +685,16 @@ resource "aws_autoscaling_schedule" "this" {
|
||||
scheduled_action_name = each.key
|
||||
autoscaling_group_name = aws_autoscaling_group.this[0].name
|
||||
|
||||
min_size = lookup(each.value, "min_size", null)
|
||||
max_size = lookup(each.value, "max_size", null)
|
||||
desired_capacity = lookup(each.value, "desired_size", null)
|
||||
start_time = lookup(each.value, "start_time", null)
|
||||
end_time = lookup(each.value, "end_time", null)
|
||||
time_zone = lookup(each.value, "time_zone", null)
|
||||
min_size = try(each.value.min_size, null)
|
||||
max_size = try(each.value.max_size, null)
|
||||
desired_capacity = try(each.value.desired_size, null)
|
||||
start_time = try(each.value.start_time, null)
|
||||
end_time = try(each.value.end_time, null)
|
||||
time_zone = try(each.value.time_zone, null)
|
||||
|
||||
# [Minute] [Hour] [Day_of_Month] [Month_of_Year] [Day_of_Week]
|
||||
# Cron examples: https://crontab.guru/examples.html
|
||||
recurrence = lookup(each.value, "recurrence", null)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Security Group
|
||||
################################################################################
|
||||
|
||||
locals {
|
||||
security_group_name = coalesce(var.security_group_name, "${var.name}-node-group")
|
||||
create_security_group = var.create && var.create_security_group
|
||||
}
|
||||
|
||||
resource "aws_security_group" "this" {
|
||||
count = local.create_security_group ? 1 : 0
|
||||
|
||||
name = var.security_group_use_name_prefix ? null : local.security_group_name
|
||||
name_prefix = var.security_group_use_name_prefix ? "${local.security_group_name}-" : null
|
||||
description = var.security_group_description
|
||||
vpc_id = var.vpc_id
|
||||
|
||||
tags = merge(
|
||||
var.tags,
|
||||
{
|
||||
"Name" = local.security_group_name
|
||||
},
|
||||
var.security_group_tags
|
||||
)
|
||||
|
||||
# https://github.com/hashicorp/terraform-provider-aws/issues/2445
|
||||
# https://github.com/hashicorp/terraform-provider-aws/issues/9692
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_security_group_rule" "this" {
|
||||
for_each = { for k, v in var.security_group_rules : k => v if local.create_security_group }
|
||||
|
||||
# Required
|
||||
security_group_id = aws_security_group.this[0].id
|
||||
protocol = each.value.protocol
|
||||
from_port = each.value.from_port
|
||||
to_port = each.value.to_port
|
||||
type = each.value.type
|
||||
|
||||
# Optional
|
||||
description = try(each.value.description, null)
|
||||
cidr_blocks = try(each.value.cidr_blocks, null)
|
||||
ipv6_cidr_blocks = try(each.value.ipv6_cidr_blocks, null)
|
||||
prefix_list_ids = try(each.value.prefix_list_ids, [])
|
||||
self = try(each.value.self, null)
|
||||
source_security_group_id = try(
|
||||
each.value.source_security_group_id,
|
||||
try(each.value.source_cluster_security_group, false) ? var.cluster_security_group_id : null
|
||||
)
|
||||
recurrence = try(each.value.recurrence, null)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -503,11 +702,9 @@ resource "aws_security_group_rule" "this" {
|
||||
################################################################################
|
||||
|
||||
locals {
|
||||
iam_role_name = coalesce(var.iam_role_name, "${var.name}-node-group")
|
||||
|
||||
iam_role_name = coalesce(var.iam_role_name, "${var.name}-node-group")
|
||||
iam_role_policy_prefix = "arn:${data.aws_partition.current.partition}:iam::aws:policy"
|
||||
|
||||
cni_policy = var.cluster_ip_family == "ipv6" ? "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:policy/AmazonEKS_CNI_IPv6_Policy" : "${local.iam_role_policy_prefix}/AmazonEKS_CNI_Policy"
|
||||
cni_policy = var.cluster_ip_family == "ipv6" ? "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:policy/AmazonEKS_CNI_IPv6_Policy" : "${local.iam_role_policy_prefix}/AmazonEKS_CNI_Policy"
|
||||
}
|
||||
|
||||
data "aws_iam_policy_document" "assume_role_policy" {
|
||||
@@ -540,17 +737,23 @@ resource "aws_iam_role" "this" {
|
||||
}
|
||||
|
||||
resource "aws_iam_role_policy_attachment" "this" {
|
||||
for_each = var.create && var.create_iam_instance_profile ? toset(compact(distinct(concat([
|
||||
for_each = { for k, v in toset(compact([
|
||||
"${local.iam_role_policy_prefix}/AmazonEKSWorkerNodePolicy",
|
||||
"${local.iam_role_policy_prefix}/AmazonEC2ContainerRegistryReadOnly",
|
||||
var.iam_role_attach_cni_policy ? local.cni_policy : "",
|
||||
], var.iam_role_additional_policies)))) : toset([])
|
||||
])) : k => v if var.create && var.create_iam_instance_profile }
|
||||
|
||||
policy_arn = each.value
|
||||
role = aws_iam_role.this[0].name
|
||||
}
|
||||
|
||||
resource "aws_iam_role_policy_attachment" "additional" {
|
||||
for_each = { for k, v in var.iam_role_additional_policies : k => v if var.create && var.create_iam_instance_profile }
|
||||
|
||||
policy_arn = each.value
|
||||
role = aws_iam_role.this[0].name
|
||||
}
|
||||
|
||||
# Only self-managed node group requires instance profile
|
||||
resource "aws_iam_instance_profile" "this" {
|
||||
count = var.create && var.create_iam_instance_profile ? 1 : 0
|
||||
|
||||
@@ -560,9 +763,9 @@ resource "aws_iam_instance_profile" "this" {
|
||||
name_prefix = var.iam_role_use_name_prefix ? "${local.iam_role_name}-" : null
|
||||
path = var.iam_role_path
|
||||
|
||||
tags = merge(var.tags, var.iam_role_tags)
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
|
||||
tags = merge(var.tags, var.iam_role_tags)
|
||||
}
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
|
||||
output "launch_template_id" {
|
||||
description = "The ID of the launch template"
|
||||
value = try(aws_launch_template.this[0].id, "")
|
||||
value = try(aws_launch_template.this[0].id, null)
|
||||
}
|
||||
|
||||
output "launch_template_arn" {
|
||||
description = "The ARN of the launch template"
|
||||
value = try(aws_launch_template.this[0].arn, "")
|
||||
value = try(aws_launch_template.this[0].arn, null)
|
||||
}
|
||||
|
||||
output "launch_template_latest_version" {
|
||||
description = "The latest version of the launch template"
|
||||
value = try(aws_launch_template.this[0].latest_version, "")
|
||||
value = try(aws_launch_template.this[0].latest_version, null)
|
||||
}
|
||||
|
||||
output "launch_template_name" {
|
||||
description = "The name of the launch template"
|
||||
value = try(aws_launch_template.this[0].name, "")
|
||||
value = try(aws_launch_template.this[0].name, null)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -28,57 +28,57 @@ output "launch_template_name" {
|
||||
|
||||
output "autoscaling_group_arn" {
|
||||
description = "The ARN for this autoscaling group"
|
||||
value = try(aws_autoscaling_group.this[0].arn, "")
|
||||
value = try(aws_autoscaling_group.this[0].arn, null)
|
||||
}
|
||||
|
||||
output "autoscaling_group_id" {
|
||||
description = "The autoscaling group id"
|
||||
value = try(aws_autoscaling_group.this[0].id, "")
|
||||
value = try(aws_autoscaling_group.this[0].id, null)
|
||||
}
|
||||
|
||||
output "autoscaling_group_name" {
|
||||
description = "The autoscaling group name"
|
||||
value = try(aws_autoscaling_group.this[0].name, "")
|
||||
value = try(aws_autoscaling_group.this[0].name, null)
|
||||
}
|
||||
|
||||
output "autoscaling_group_min_size" {
|
||||
description = "The minimum size of the autoscaling group"
|
||||
value = try(aws_autoscaling_group.this[0].min_size, "")
|
||||
value = try(aws_autoscaling_group.this[0].min_size, null)
|
||||
}
|
||||
|
||||
output "autoscaling_group_max_size" {
|
||||
description = "The maximum size of the autoscaling group"
|
||||
value = try(aws_autoscaling_group.this[0].max_size, "")
|
||||
value = try(aws_autoscaling_group.this[0].max_size, null)
|
||||
}
|
||||
|
||||
output "autoscaling_group_desired_capacity" {
|
||||
description = "The number of Amazon EC2 instances that should be running in the group"
|
||||
value = try(aws_autoscaling_group.this[0].desired_capacity, "")
|
||||
value = try(aws_autoscaling_group.this[0].desired_capacity, null)
|
||||
}
|
||||
|
||||
output "autoscaling_group_default_cooldown" {
|
||||
description = "Time between a scaling activity and the succeeding scaling activity"
|
||||
value = try(aws_autoscaling_group.this[0].default_cooldown, "")
|
||||
value = try(aws_autoscaling_group.this[0].default_cooldown, null)
|
||||
}
|
||||
|
||||
output "autoscaling_group_health_check_grace_period" {
|
||||
description = "Time after instance comes into service before checking health"
|
||||
value = try(aws_autoscaling_group.this[0].health_check_grace_period, "")
|
||||
value = try(aws_autoscaling_group.this[0].health_check_grace_period, null)
|
||||
}
|
||||
|
||||
output "autoscaling_group_health_check_type" {
|
||||
description = "EC2 or ELB. Controls how health checking is done"
|
||||
value = try(aws_autoscaling_group.this[0].health_check_type, "")
|
||||
value = try(aws_autoscaling_group.this[0].health_check_type, null)
|
||||
}
|
||||
|
||||
output "autoscaling_group_availability_zones" {
|
||||
description = "The availability zones of the autoscaling group"
|
||||
value = try(aws_autoscaling_group.this[0].availability_zones, "")
|
||||
value = try(aws_autoscaling_group.this[0].availability_zones, null)
|
||||
}
|
||||
|
||||
output "autoscaling_group_vpc_zone_identifier" {
|
||||
description = "The VPC zone identifier"
|
||||
value = try(aws_autoscaling_group.this[0].vpc_zone_identifier, "")
|
||||
value = try(aws_autoscaling_group.this[0].vpc_zone_identifier, null)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -90,37 +90,23 @@ output "autoscaling_group_schedule_arns" {
|
||||
value = { for k, v in aws_autoscaling_schedule.this : k => v.arn }
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Security Group
|
||||
################################################################################
|
||||
|
||||
output "security_group_arn" {
|
||||
description = "Amazon Resource Name (ARN) of the security group"
|
||||
value = try(aws_security_group.this[0].arn, "")
|
||||
}
|
||||
|
||||
output "security_group_id" {
|
||||
description = "ID of the security group"
|
||||
value = try(aws_security_group.this[0].id, "")
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# IAM Role
|
||||
################################################################################
|
||||
|
||||
output "iam_role_name" {
|
||||
description = "The name of the IAM role"
|
||||
value = try(aws_iam_role.this[0].name, "")
|
||||
value = try(aws_iam_role.this[0].name, null)
|
||||
}
|
||||
|
||||
output "iam_role_arn" {
|
||||
description = "The Amazon Resource Name (ARN) specifying the IAM role"
|
||||
value = try(aws_iam_role.this[0].arn, "")
|
||||
value = try(aws_iam_role.this[0].arn, null)
|
||||
}
|
||||
|
||||
output "iam_role_unique_id" {
|
||||
description = "Stable and unique string identifying the IAM role"
|
||||
value = try(aws_iam_role.this[0].unique_id, "")
|
||||
value = try(aws_iam_role.this[0].unique_id, null)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -134,12 +120,12 @@ output "iam_instance_profile_arn" {
|
||||
|
||||
output "iam_instance_profile_id" {
|
||||
description = "Instance profile's ID"
|
||||
value = try(aws_iam_instance_profile.this[0].id, "")
|
||||
value = try(aws_iam_instance_profile.this[0].id, null)
|
||||
}
|
||||
|
||||
output "iam_instance_profile_unique" {
|
||||
description = "Stable and unique string identifying the IAM instance profile"
|
||||
value = try(aws_iam_instance_profile.this[0].unique_id, "")
|
||||
value = try(aws_iam_instance_profile.this[0].unique_id, null)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -153,10 +139,10 @@ output "platform" {
|
||||
|
||||
output "image_id" {
|
||||
description = "ID of the image"
|
||||
value = try(aws_launch_template.this[0].image_id, "")
|
||||
value = try(aws_launch_template.this[0].image_id, null)
|
||||
}
|
||||
|
||||
output "user_data" {
|
||||
description = "Base64 encoded user data"
|
||||
value = try(module.user_data.user_data, "")
|
||||
value = try(module.user_data.user_data, null)
|
||||
}
|
||||
|
||||
@@ -72,8 +72,14 @@ variable "create_launch_template" {
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "launch_template_id" {
|
||||
description = "The ID of an existing launch template to use. Required when `create_launch_template` = `false`"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "launch_template_name" {
|
||||
description = "Launch template name - either to be created (`var.create_launch_template` = `true`) or existing (`var.create_launch_template` = `false`)"
|
||||
description = "Name of launch template to be created"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
@@ -152,7 +158,7 @@ variable "credit_specification" {
|
||||
|
||||
variable "elastic_gpu_specifications" {
|
||||
description = "The elastic GPU to attach to the instance"
|
||||
type = map(string)
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
@@ -180,9 +186,15 @@ variable "instance_market_options" {
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "maintenance_options" {
|
||||
description = "The maintenance options for the instance"
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "license_specifications" {
|
||||
description = "A list of license specifications to associate with"
|
||||
type = map(string)
|
||||
description = "A map of license specifications to associate with"
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
@@ -198,6 +210,12 @@ variable "placement" {
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "private_dns_name_options" {
|
||||
description = "The options for the instance hostname. The default values are inherited from the subnet"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "ebs_optimized" {
|
||||
description = "If true, the launched EC2 instance will be EBS-optimized"
|
||||
type = bool
|
||||
@@ -216,6 +234,12 @@ variable "cluster_version" {
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "instance_requirements" {
|
||||
description = "The attribute requirements for the type of instance. If present then `instance_type` cannot be present"
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "instance_type" {
|
||||
description = "The type of the instance to launch"
|
||||
type = string
|
||||
@@ -320,6 +344,12 @@ variable "desired_size" {
|
||||
default = 1
|
||||
}
|
||||
|
||||
variable "context" {
|
||||
description = "Reserved"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "capacity_rebalance" {
|
||||
description = "Indicates whether capacity rebalance is enabled"
|
||||
type = bool
|
||||
@@ -350,6 +380,12 @@ variable "default_cooldown" {
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "default_instance_warmup" {
|
||||
description = "Amount of time, in seconds, until a newly launched instance can contribute to the Amazon CloudWatch metrics. This delay lets an instance finish initializing before Amazon EC2 Auto Scaling aggregates instance metrics, resulting in more reliable usage data"
|
||||
type = number
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "protect_from_scale_in" {
|
||||
description = "Allows setting instance protection. The autoscaling group will not select instances with this setting for termination during scale in events."
|
||||
type = bool
|
||||
@@ -386,6 +422,12 @@ variable "force_delete" {
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "force_delete_warm_pool" {
|
||||
description = "Allows deleting the Auto Scaling Group without waiting for all instances in the warm pool to terminate"
|
||||
type = bool
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "termination_policies" {
|
||||
description = "A list of policies to decide how the instances in the Auto Scaling Group should be terminated. The allowed values are `OldestInstance`, `NewestInstance`, `OldestLaunchConfiguration`, `ClosestToNextInstanceHour`, `OldestLaunchTemplate`, `AllocationStrategy`, `Default`"
|
||||
type = list(string)
|
||||
@@ -431,7 +473,12 @@ variable "initial_lifecycle_hooks" {
|
||||
variable "instance_refresh" {
|
||||
description = "If this block is configured, start an Instance Refresh when this Auto Scaling Group is updated"
|
||||
type = any
|
||||
default = {}
|
||||
default = {
|
||||
strategy = "Rolling"
|
||||
preferences = {
|
||||
min_healthy_percentage = 66
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "use_mixed_instances_policy" {
|
||||
@@ -458,12 +505,6 @@ variable "delete_timeout" {
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "use_default_tags" {
|
||||
description = "Enables/disables the use of provider default tags in the tag_specifications of the Auto Scaling group"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "autoscaling_group_tags" {
|
||||
description = "A map of additional tags to add to the autoscaling group created. Tags are applied to the autoscaling group only and are NOT propagated to instances"
|
||||
type = map(string)
|
||||
@@ -486,58 +527,6 @@ variable "schedules" {
|
||||
default = {}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Security Group
|
||||
################################################################################
|
||||
|
||||
variable "create_security_group" {
|
||||
description = "Determines whether to create a security group"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "security_group_name" {
|
||||
description = "Name to use on security group created"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "security_group_use_name_prefix" {
|
||||
description = "Determines whether the security group name (`security_group_name`) is used as a prefix"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "security_group_description" {
|
||||
description = "Description for the security group created"
|
||||
type = string
|
||||
default = "EKS self-managed node group security group"
|
||||
}
|
||||
|
||||
variable "vpc_id" {
|
||||
description = "ID of the VPC where the security group/nodes will be provisioned"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "security_group_rules" {
|
||||
description = "List of security group rules to add to the security group created"
|
||||
type = any
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "cluster_security_group_id" {
|
||||
description = "Cluster control plane security group ID"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "security_group_tags" {
|
||||
description = "A map of additional tags to add to the security group created"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# IAM Role
|
||||
################################################################################
|
||||
@@ -598,8 +587,8 @@ variable "iam_role_attach_cni_policy" {
|
||||
|
||||
variable "iam_role_additional_policies" {
|
||||
description = "Additional policies to be added to the IAM role"
|
||||
type = list(string)
|
||||
default = []
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "iam_role_tags" {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
terraform {
|
||||
required_version = ">= 0.13.1"
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = ">= 3.72"
|
||||
version = ">= 4.45"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user