terraform-aws-eks-autoscaling Latest Release Slack Community Discourse Forum

BioAnalyze Logo

Terraform module to provision an EKS cluster on AWS. It is meant to be a wrapper around the cloudposse/terraform-aws-eks, cloudposse/terraform-aws-eks-node-group, and terraform-aws-eks-workers. For in depth cluster customization see these modules individually.


This project is part of the "BioAnalyze" project, which aims to make High Performance Compute Architecture accessible to everyone.

It's 100% Open Source and licensed under the APACHE2.

Data Science Infrastructure on AWS

BioAnalyze Logo

IMPORTANT: We do not pin modules to versions in our examples because of the difficulty of keeping the versions in the documentation in sync with the latest released versions. We highly recommend that in your code you pin the version to the exact version you are using so that your infrastructure remains stable, and update versions in a systematic way so that they do not catch you by surprise.

Also, because of a bug in the Terraform registry (hashicorp/terraform#21417), the registry shows many of our inputs as required when in fact they are optional. The table below correctly indicates which inputs are required.

For a complete example, see examples/complete.

For automated tests of the complete example using bats and Terratest (which tests and deploys the example on AWS), see test.

module "example" {
  source = "dabble-of-devops-biodeploy/eks-autoscaling/aws"

  region = var.region
  vpc_id = var.vpc_id
  subnet_ids = var.subnet_ids

  oidc_provider_enabled = true
  cluster_encryption_config_enabled = true

  context = module.this.context
}

Examples

Here is an example of using this module:

Makefile Targets

Available targets:

  help                                Help screen
  help/all                            Display help for all targets
  help/short                          This help short screen
  lint                                Lint terraform code

Requirements

Name Version
terraform >= 0.13
aws ~> 3.0
local >= 1.2
random >= 2.2

Providers

Name Version
aws 3.49.0
helm 2.2.0
null 3.1.0
template 2.2.0

Modules

Name Source Version
eks_cluster cloudposse/eks-cluster/aws >= 0.41.0
eks_node_group cloudposse/eks-node-group/aws 0.24.0
iam_assumable_role_admin terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc 3.6.0
label cloudposse/label/null 0.24.1
this cloudposse/label/null 0.24.1

Resources

Name Type
aws_iam_policy.cluster_autoscaler resource
helm_release.autoscaler resource
helm_release.cert-manager resource
null_resource.kubectl_update resource
aws_availability_zones.available data source
aws_caller_identity.current data source
aws_eks_cluster.cluster data source
aws_eks_cluster_auth.cluster data source
aws_iam_policy_document.cluster_autoscaler data source
null_data_source.wait_for_cluster_and_kubernetes_configmap data source
template_file.autoscaler data source

Inputs

Name Description Type Default Required
additional_tag_map Additional tags for appending to tags_as_list_of_maps. Not added to tags. map(string) {} no
attributes Additional attributes (e.g. 1) list(string) [] no
cert_manager_version Cert Manager Helm Chart Version. If you are changing either this version of the kubernetes version make sure that the versions are compatible. For more information see: https://cert-manager.io/docs/installation/helm/ string "v1.5.4" no
cluster_encryption_config_enabled Set to true to enable Cluster Encryption Configuration bool true no
cluster_encryption_config_kms_key_deletion_window_in_days Cluster Encryption Config KMS Key Resource argument - key deletion windows in days post destruction number 10 no
cluster_encryption_config_kms_key_enable_key_rotation Cluster Encryption Config KMS Key Resource argument - enable kms key rotation bool true no
cluster_encryption_config_kms_key_id KMS Key ID to use for cluster encryption config string "" no
cluster_encryption_config_kms_key_policy Cluster Encryption Config KMS Key Resource argument - key policy string null no
cluster_encryption_config_resources Cluster Encryption Config Resources to encrypt, e.g. ['secrets'] list(any)
[
"secrets"
]
no
cluster_log_retention_period Number of days to retain cluster logs. Requires enabled_cluster_log_types to be set. See https://docs.aws.amazon.com/en_us/eks/latest/userguide/control-plane-logs.html. number 7 no
context Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
any
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
}
no
delimiter Delimiter to be used between namespace, environment, stage, name and attributes.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
string null no
eks_node_group_autoscaling_enabled n/a bool false no
eks_node_groups EKS Worker Groups
list(object({
instance_types = list(string)
desired_size = number
min_size = number
max_size = number
disk_size = number
name = string
}))
[
{
"desired_size": 1,
"disk_size": 20,
"instance_types": [
"t3a.medium"
],
"max_size": 2,
"min_size": 1,
"name": "worker-group-1"
}
]
no
eks_worker_group_autoscaling_policies_enabled Whether to create aws_autoscaling_policy and aws_cloudwatch_metric_alarm resources to control Auto Scaling bool false no
eks_workers_role_arns List of Role ARNs of the worker nodes list(string) [] no
enabled Set to false to prevent the module from creating any resources bool null no
enabled_cluster_log_types A list of the desired control plane logging to enable. For more information, see https://docs.aws.amazon.com/en_us/eks/latest/userguide/control-plane-logs.html. Possible values [api, audit, authenticator, controllerManager, scheduler] list(string)
[
"audit"
]
no
environment Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' string null no
id_length_limit Limit id to this many characters (minimum 6).
Set to 0 for unlimited length.
Set to null for default, which is 0.
Does not affect id_full.
number null no
install_cert_manager n/a bool true no
kubernetes_labels Key-value mapping 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) {} no
kubernetes_version Desired Kubernetes master version. If you do not specify a value, the latest available version is used string "1.17" no
label_key_case The letter case of label keys (tag names) (i.e. name, namespace, environment, stage, attributes) to use in tags.
Possible values: lower, title, upper.
Default value: title.
string null no
label_order The naming order of the id output and Name tag.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 5 elements, but at least one must be present.
list(string) null no
label_value_case The letter case of output label values (also used in tags and id).
Possible values: lower, title, upper and none (no transformation).
Default value: lower.
string null no
local_exec_interpreter shell to use for local_exec list(string)
[
"/bin/sh",
"-c"
]
no
map_additional_aws_accounts Additional AWS account numbers to add to config-map-aws-auth ConfigMap list(string) [] no
map_additional_iam_roles Additional IAM roles to add to config-map-aws-auth ConfigMap
list(object({
rolearn = string
username = string
groups = list(string)
}))
[] no
map_additional_iam_users Additional IAM users to add to config-map-aws-auth ConfigMap
list(object({
userarn = string
username = string
groups = list(string)
}))
[] no
name Solution name, e.g. 'app' or 'jenkins' string null no
namespace Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' string null no
oidc_provider_enabled Create an IAM OIDC identity provider for the cluster, then you can create IAM roles to associate with a service account in the cluster, instead of using kiam or kube2iam. For more information, see https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html bool true no
regex_replace_chars Regex to replace chars with empty string in namespace, environment, stage and name.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
string null no
region AWS Region string "us-east-1" no
stage Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' string null no
subnet_ids Public Subnet Ids list(string) n/a yes
tags Additional tags (e.g. map('BusinessUnit','XYZ') map(string) {} no
vpc_id VPC ID for the cluster VPC ID string n/a yes

Outputs

Name Description
aws_iam_policy_cluster_autoscaler n/a
cluster_autoscaler_iam_policy n/a
eks_cluster All values from the EKS Cluster
eks_cluster_arn n/a
eks_cluster_id EKS Cluster ID
eks_cluster_identity_oidc_issuer The OIDC Identity issuer for the cluster
eks_cluster_name n/a
eks_cluster_node_groups n/a
get_kubectl Get your kubectl
id ID of the created example
region AWS Region of the cluster

Share the Love

Like this project? Please give it a ★ on our GitHub! (it helps a lot)

Related Projects

Check out these related projects.

References

For additional context, refer to some of these links.

  • Terraform Standard Module Structure - HashiCorp's standard module structure is a file and directory layout we recommend for reusable modules distributed in separate repositories.
  • Terraform Module Requirements - HashiCorp's guidance on all the requirements for publishing a module. Meeting the requirements for publishing a module is extremely easy.
  • Terraform random_integer Resource - The resource random_integer generates random values from a given range, described by the min and max attributes of a given resource.
  • Terraform Version Pinning - The required_version setting can be used to constrain which versions of the Terraform CLI can be used with your configuration

Help

Got a question? We got answers.

File a GitHub issue, send us an jillian@dabbleofdevops.com.

Bioinformatics Infrastructure on AWS for Startups

I'll help you build your data science cloud infrastructure from the ground up so you can own it using open source software. Then I'll show you how to operate it and stick around for as long as you need us.

Learn More

Work directly with me via email, slack, and video conferencing.

  • Scientific Workflow Automation and Optimization. Got workflows that are giving you trouble? Let's work together to ensure that your analyses run with or without your scientists being fully caffeinated.
  • High Performance Compute Infrastructure. Highly available, auto scaling clusters to analyze all the (bioinformatics related!) things. All setups are completely integrated with your workflow system of choice, whether that is Airflow, Prefect, Snakemake or Nextflow.
  • Kubernetes and AWS Batch Setup for Apache Airflow Orchestrate your Bioinformatics Workflows with Apache Airflow. Get full auditing, SLA, logging and monitoring for your workflows running on AWS Batch.
  • High Performance Compute Setup that Int You'll have built-in governance with accountability and audit logs for all changes.
  • Docker Images Get advice and hands on training for your team to build complex software stacks onto docker images.
  • Training. You'll receive hands-on training so your team can operate what we build.
  • Questions. You'll have a direct line of communication between our teams via a Shared Slack channel.
  • Troubleshooting. You'll get help to triage when things aren't working.
  • Bug Fixes. We'll rapidly work with you to fix any bugs in our projects.

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Developing

If you are interested in being a contributor and want to get involved in developing this project or help out with other projects, I would love to hear from you! Shoot me an email at jillian@dabbleofdevops.com.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Pull Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

Copyrights

Copyright © 2020-2021 Dabble of DevOps, SCorp

License

License

See LICENSE for full details.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.

Trademarks

All other trademarks referenced herein are the property of their respective owners.

Contributors

Jillian Rowe
Jillian Rowe

Learn more at Dabble of DevOps