mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-01-11 14:30:55 +01:00
* Support adding additional cluster dns ranges to bottlerocket template * Add example for multiple dns ips * fmt, and tf docs * fix: Use a list by default for cluster-dns-ip --------- Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
673 lines
21 KiB
HCL
673 lines
21 KiB
HCL
variable "create" {
|
|
description = "Determines whether to create self managed node group or not"
|
|
type = bool
|
|
default = true
|
|
}
|
|
|
|
variable "tags" {
|
|
description = "A map of tags to add to all resources"
|
|
type = map(string)
|
|
default = {}
|
|
}
|
|
|
|
variable "platform" {
|
|
description = "[DEPRECATED - use `ami_type` instead. Will be removed in `v21.0`] Identifies the OS platform as `bottlerocket`, `linux` (AL2), `al2023`, or `windows`"
|
|
type = string
|
|
default = "linux"
|
|
}
|
|
|
|
################################################################################
|
|
# User Data
|
|
################################################################################
|
|
|
|
variable "cluster_name" {
|
|
description = "Name of associated EKS cluster"
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "cluster_endpoint" {
|
|
description = "Endpoint of associated EKS cluster"
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "cluster_auth_base64" {
|
|
description = "Base64 encoded CA of associated EKS cluster"
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "cluster_service_cidr" {
|
|
description = "The CIDR block (IPv4 or IPv6) used by the cluster to assign Kubernetes service IP addresses. This is derived from the cluster itself"
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "cluster_ip_family" {
|
|
description = "The IP family used to assign Kubernetes pod and service addresses. Valid values are `ipv4` (default) and `ipv6`"
|
|
type = string
|
|
default = "ipv4"
|
|
}
|
|
|
|
variable "additional_cluster_dns_ips" {
|
|
description = "Additional DNS IP addresses to use for the cluster. Only used when `ami_type` = `BOTTLEROCKET_*`"
|
|
type = list(string)
|
|
default = []
|
|
}
|
|
|
|
variable "pre_bootstrap_user_data" {
|
|
description = "User data that is injected into the user data script ahead of the EKS bootstrap script. Not used when `ami_type` = `BOTTLEROCKET_*`"
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "post_bootstrap_user_data" {
|
|
description = "User data that is appended to the user data script after of the EKS bootstrap script. Not used when `ami_type` = `BOTTLEROCKET_*`"
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "bootstrap_extra_args" {
|
|
description = "Additional arguments passed to the bootstrap script. When `ami_type` = `BOTTLEROCKET_*`; these are additional [settings](https://github.com/bottlerocket-os/bottlerocket#settings) that are provided to the Bottlerocket user data"
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "user_data_template_path" {
|
|
description = "Path to a local, custom user data template file to use when rendering user data"
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "cloudinit_pre_nodeadm" {
|
|
description = "Array of cloud-init document parts that are created before the nodeadm document part"
|
|
type = list(object({
|
|
content = string
|
|
content_type = optional(string)
|
|
filename = optional(string)
|
|
merge_type = optional(string)
|
|
}))
|
|
default = []
|
|
}
|
|
|
|
variable "cloudinit_post_nodeadm" {
|
|
description = "Array of cloud-init document parts that are created after the nodeadm document part"
|
|
type = list(object({
|
|
content = string
|
|
content_type = optional(string)
|
|
filename = optional(string)
|
|
merge_type = optional(string)
|
|
}))
|
|
default = []
|
|
}
|
|
|
|
################################################################################
|
|
# Launch template
|
|
################################################################################
|
|
|
|
variable "create_launch_template" {
|
|
description = "Determines whether to create launch template or not"
|
|
type = bool
|
|
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 = "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
|
|
default = true
|
|
}
|
|
|
|
variable "launch_template_description" {
|
|
description = "Description of the launch template"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "launch_template_default_version" {
|
|
description = "Default Version of the launch template"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "update_launch_template_default_version" {
|
|
description = "Whether to update Default Version each update. Conflicts with `launch_template_default_version`"
|
|
type = bool
|
|
default = true
|
|
}
|
|
|
|
variable "disable_api_termination" {
|
|
description = "If true, enables EC2 instance termination protection"
|
|
type = bool
|
|
default = null
|
|
}
|
|
|
|
variable "instance_initiated_shutdown_behavior" {
|
|
description = "Shutdown behavior for the instance. Can be `stop` or `terminate`. (Default: `stop`)"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "kernel_id" {
|
|
description = "The kernel ID"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "ram_disk_id" {
|
|
description = "The ID of the ram disk"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "block_device_mappings" {
|
|
description = "Specify volumes to attach to the instance besides the volumes specified by the AMI"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
variable "capacity_reservation_specification" {
|
|
description = "Targeting for EC2 capacity reservations"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
variable "cpu_options" {
|
|
description = "The CPU options for the instance"
|
|
type = map(string)
|
|
default = {}
|
|
}
|
|
|
|
variable "credit_specification" {
|
|
description = "Customize the credit specification of the instance"
|
|
type = map(string)
|
|
default = {}
|
|
}
|
|
|
|
variable "elastic_gpu_specifications" {
|
|
description = "The elastic GPU to attach to the instance"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
variable "elastic_inference_accelerator" {
|
|
description = "Configuration block containing an Elastic Inference Accelerator to attach to the instance"
|
|
type = map(string)
|
|
default = {}
|
|
}
|
|
|
|
variable "enclave_options" {
|
|
description = "Enable Nitro Enclaves on launched instances"
|
|
type = map(string)
|
|
default = {}
|
|
}
|
|
|
|
variable "hibernation_options" {
|
|
description = "The hibernation options for the instance"
|
|
type = map(string)
|
|
default = {}
|
|
}
|
|
|
|
variable "instance_market_options" {
|
|
description = "The market (purchasing) option for the instance"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
variable "maintenance_options" {
|
|
description = "The maintenance options for the instance"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
variable "license_specifications" {
|
|
description = "A map of license specifications to associate with"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
variable "network_interfaces" {
|
|
description = "Customize network interfaces to be attached at instance boot time"
|
|
type = list(any)
|
|
default = []
|
|
}
|
|
|
|
variable "placement" {
|
|
description = "The placement of the instance"
|
|
type = map(string)
|
|
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
|
|
default = null
|
|
}
|
|
|
|
variable "ami_id" {
|
|
description = "The AMI from which to launch the instance"
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "ami_type" {
|
|
description = "Type of Amazon Machine Image (AMI) associated with the node group. See the [AWS documentation](https://docs.aws.amazon.com/eks/latest/APIReference/API_Nodegroup.html#AmazonEKS-Type-Nodegroup-amiType) for valid values"
|
|
type = string
|
|
default = "AL2_x86_64"
|
|
}
|
|
|
|
variable "cluster_version" {
|
|
description = "Kubernetes cluster version - used to lookup default AMI ID if one is not provided"
|
|
type = string
|
|
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
|
|
default = ""
|
|
}
|
|
|
|
variable "key_name" {
|
|
description = "The key name that should be used for the instance"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "vpc_security_group_ids" {
|
|
description = "A list of security group IDs to associate"
|
|
type = list(string)
|
|
default = []
|
|
}
|
|
|
|
variable "cluster_primary_security_group_id" {
|
|
description = "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"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "enable_monitoring" {
|
|
description = "Enables/disables detailed monitoring"
|
|
type = bool
|
|
default = true
|
|
}
|
|
|
|
variable "enable_efa_support" {
|
|
description = "Determines whether to enable Elastic Fabric Adapter (EFA) support"
|
|
type = bool
|
|
default = false
|
|
}
|
|
|
|
variable "metadata_options" {
|
|
description = "Customize the metadata options for the instance"
|
|
type = map(string)
|
|
default = {
|
|
http_endpoint = "enabled"
|
|
http_tokens = "required"
|
|
http_put_response_hop_limit = 2
|
|
}
|
|
}
|
|
|
|
variable "launch_template_tags" {
|
|
description = "A map of additional tags to add to the tag_specifications of launch template created"
|
|
type = map(string)
|
|
default = {}
|
|
}
|
|
|
|
variable "tag_specifications" {
|
|
description = "The tags to apply to the resources during launch"
|
|
type = list(string)
|
|
default = ["instance", "volume", "network-interface"]
|
|
}
|
|
|
|
################################################################################
|
|
# Autoscaling group
|
|
################################################################################
|
|
|
|
variable "create_autoscaling_group" {
|
|
description = "Determines whether to create autoscaling group or not"
|
|
type = bool
|
|
default = true
|
|
}
|
|
|
|
variable "name" {
|
|
description = "Name of the Self managed Node Group"
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "use_name_prefix" {
|
|
description = "Determines whether to use `name` as is or create a unique name beginning with the `name` as the prefix"
|
|
type = bool
|
|
default = true
|
|
}
|
|
|
|
variable "launch_template_version" {
|
|
description = "Launch template version. Can be version number, `$Latest`, or `$Default`"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "availability_zones" {
|
|
description = "A list of one or more availability zones for the group. Used for EC2-Classic and default subnets when not specified with `subnet_ids` argument. Conflicts with `subnet_ids`"
|
|
type = list(string)
|
|
default = null
|
|
}
|
|
|
|
variable "subnet_ids" {
|
|
description = "A list of subnet IDs to launch resources in. Subnets automatically determine which availability zones the group will reside. Conflicts with `availability_zones`"
|
|
type = list(string)
|
|
default = null
|
|
}
|
|
|
|
variable "min_size" {
|
|
description = "The minimum size of the autoscaling group"
|
|
type = number
|
|
default = 0
|
|
}
|
|
|
|
variable "max_size" {
|
|
description = "The maximum size of the autoscaling group"
|
|
type = number
|
|
default = 3
|
|
}
|
|
|
|
variable "desired_size" {
|
|
description = "The number of Amazon EC2 instances that should be running in the autoscaling group"
|
|
type = number
|
|
default = 1
|
|
}
|
|
|
|
variable "context" {
|
|
description = "Reserved"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "capacity_rebalance" {
|
|
description = "Indicates whether capacity rebalance is enabled"
|
|
type = bool
|
|
default = null
|
|
}
|
|
|
|
variable "min_elb_capacity" {
|
|
description = "Setting this causes Terraform to wait for this number of instances to show up healthy in the ELB only on creation. Updates will not wait on ELB instance number changes"
|
|
type = number
|
|
default = null
|
|
}
|
|
|
|
variable "wait_for_elb_capacity" {
|
|
description = "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."
|
|
type = number
|
|
default = null
|
|
}
|
|
|
|
variable "wait_for_capacity_timeout" {
|
|
description = "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."
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "default_cooldown" {
|
|
description = "The amount of time, in seconds, after a scaling activity completes before another scaling activity can start"
|
|
type = number
|
|
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
|
|
default = false
|
|
}
|
|
|
|
variable "target_group_arns" {
|
|
description = "A set of `aws_alb_target_group` ARNs, for use with Application or Network Load Balancing"
|
|
type = list(string)
|
|
default = []
|
|
}
|
|
|
|
variable "placement_group" {
|
|
description = "The name of the placement group into which you'll launch your instances, if any"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "health_check_type" {
|
|
description = "`EC2` or `ELB`. Controls how health checking is done"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "health_check_grace_period" {
|
|
description = "Time (in seconds) after instance comes into service before checking health"
|
|
type = number
|
|
default = null
|
|
}
|
|
|
|
variable "force_delete" {
|
|
description = "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"
|
|
type = bool
|
|
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)
|
|
default = []
|
|
}
|
|
|
|
variable "suspended_processes" {
|
|
description = "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"
|
|
type = list(string)
|
|
default = []
|
|
}
|
|
|
|
variable "max_instance_lifetime" {
|
|
description = "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"
|
|
type = number
|
|
default = null
|
|
}
|
|
|
|
variable "enabled_metrics" {
|
|
description = "A list of metrics to collect. The allowed values are `GroupDesiredCapacity`, `GroupInServiceCapacity`, `GroupPendingCapacity`, `GroupMinSize`, `GroupMaxSize`, `GroupInServiceInstances`, `GroupPendingInstances`, `GroupStandbyInstances`, `GroupStandbyCapacity`, `GroupTerminatingCapacity`, `GroupTerminatingInstances`, `GroupTotalCapacity`, `GroupTotalInstances`"
|
|
type = list(string)
|
|
default = []
|
|
}
|
|
|
|
variable "metrics_granularity" {
|
|
description = "The granularity to associate with the metrics to collect. The only valid value is `1Minute`"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "service_linked_role_arn" {
|
|
description = "The ARN of the service-linked role that the ASG will use to call other AWS services"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "initial_lifecycle_hooks" {
|
|
description = "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"
|
|
type = list(map(string))
|
|
default = []
|
|
}
|
|
|
|
variable "instance_maintenance_policy" {
|
|
description = "If this block is configured, add a instance maintenance policy to the specified Auto Scaling group"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
variable "instance_refresh" {
|
|
description = "If this block is configured, start an Instance Refresh when this Auto Scaling Group is updated"
|
|
type = any
|
|
default = {
|
|
strategy = "Rolling"
|
|
preferences = {
|
|
min_healthy_percentage = 66
|
|
}
|
|
}
|
|
}
|
|
|
|
variable "use_mixed_instances_policy" {
|
|
description = "Determines whether to use a mixed instances policy in the autoscaling group or not"
|
|
type = bool
|
|
default = false
|
|
}
|
|
|
|
variable "mixed_instances_policy" {
|
|
description = "Configuration block containing settings to define launch targets for Auto Scaling groups"
|
|
type = any
|
|
default = null
|
|
}
|
|
|
|
variable "warm_pool" {
|
|
description = "If this block is configured, add a Warm Pool to the specified Auto Scaling group"
|
|
type = any
|
|
default = {}
|
|
}
|
|
|
|
variable "delete_timeout" {
|
|
description = "Delete timeout to wait for destroying autoscaling group"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
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)
|
|
default = {}
|
|
}
|
|
|
|
################################################################################
|
|
# IAM Role
|
|
################################################################################
|
|
|
|
variable "create_iam_instance_profile" {
|
|
description = "Determines whether an IAM instance profile is created or to use an existing IAM instance profile"
|
|
type = bool
|
|
default = true
|
|
}
|
|
|
|
variable "iam_instance_profile_arn" {
|
|
description = "Amazon Resource Name (ARN) of an existing IAM instance profile that provides permissions for the node group. Required if `create_iam_instance_profile` = `false`"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "iam_role_name" {
|
|
description = "Name to use on IAM role created"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "iam_role_use_name_prefix" {
|
|
description = "Determines whether cluster IAM role name (`iam_role_name`) is used as a prefix"
|
|
type = bool
|
|
default = true
|
|
}
|
|
|
|
variable "iam_role_path" {
|
|
description = "IAM role path"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "iam_role_description" {
|
|
description = "Description of the role"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "iam_role_permissions_boundary" {
|
|
description = "ARN of the policy that is used to set the permissions boundary for the IAM role"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
variable "iam_role_attach_cni_policy" {
|
|
description = "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"
|
|
type = bool
|
|
default = true
|
|
}
|
|
|
|
variable "iam_role_additional_policies" {
|
|
description = "Additional policies to be added to the IAM role"
|
|
type = map(string)
|
|
default = {}
|
|
}
|
|
|
|
variable "iam_role_tags" {
|
|
description = "A map of additional tags to add to the IAM role created"
|
|
type = map(string)
|
|
default = {}
|
|
}
|
|
|
|
################################################################################
|
|
# Access Entry
|
|
################################################################################
|
|
|
|
variable "create_access_entry" {
|
|
description = "Determines whether an access entry is created for the IAM role used by the nodegroup"
|
|
type = bool
|
|
default = true
|
|
}
|
|
|
|
variable "iam_role_arn" {
|
|
description = "ARN of the IAM role used by the instance profile. Required when `create_access_entry = true` and `create_iam_instance_profile = false`"
|
|
type = string
|
|
default = null
|
|
}
|
|
|
|
################################################################################
|
|
# Autoscaling group schedule
|
|
################################################################################
|
|
|
|
variable "create_schedule" {
|
|
description = "Determines whether to create autoscaling group schedule or not"
|
|
type = bool
|
|
default = true
|
|
}
|
|
|
|
variable "schedules" {
|
|
description = "Map of autoscaling group schedule to create"
|
|
type = map(any)
|
|
default = {}
|
|
}
|