├── test ├── .gitignore ├── src │ ├── .gitignore │ ├── go.mod │ ├── Makefile │ └── examples_complete_test.go ├── Makefile.alpine └── Makefile ├── .github ├── ISSUE_TEMPLATE │ ├── question.md │ ├── config.yml │ ├── bug_report.md │ └── feature_request.md ├── renovate.json ├── PULL_REQUEST_TEMPLATE.md ├── workflows │ ├── auto-release.yml │ ├── validate-codeowners.yml │ ├── chatops.yml │ ├── auto-context.yml │ └── auto-format.yml ├── auto-release.yml ├── CODEOWNERS └── mergify.yml ├── .gitignore ├── versions.tf ├── docs ├── targets.md └── terraform.md ├── examples └── complete │ ├── versions.tf │ ├── fixtures.us-east-2.tfvars │ ├── variables.tf │ ├── main.tf │ ├── outputs.tf │ └── context.tf ├── Makefile ├── userdata.tpl ├── outputs.tf ├── README.yaml ├── main.tf ├── context.tf ├── LICENSE ├── variables.tf └── README.md /test/.gitignore: -------------------------------------------------------------------------------- 1 | .test-harness 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/src/.gitignore: -------------------------------------------------------------------------------- 1 | .gopath 2 | vendor/ 3 | -------------------------------------------------------------------------------- /test/Makefile.alpine: -------------------------------------------------------------------------------- 1 | ifneq (,$(wildcard /sbin/apk)) 2 | ## Install all dependencies for alpine 3 | deps:: init 4 | @apk add --update terraform-docs@cloudposse json2hcl@cloudposse 5 | endif 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Local .terraform directories 2 | **/.terraform/* 3 | 4 | # .tfstate files 5 | *.tfstate 6 | *.tfstate.* 7 | **/.terraform.lock.hcl 8 | 9 | **/.idea 10 | **/*.iml 11 | 12 | **/.build-harness 13 | **/build-harness 14 | 15 | # vim editor 16 | *.swp 17 | -------------------------------------------------------------------------------- /test/src/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/cloudposse/terraform-aws-eks-workers 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/gruntwork-io/terratest v0.31.4 7 | github.com/stretchr/testify v1.4.0 8 | golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect 9 | ) 10 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", 4 | ":preserveSemverRanges" 5 | ], 6 | "labels": ["auto-update"], 7 | "enabledManagers": ["terraform"], 8 | "terraform": { 9 | "ignorePaths": ["**/context.tf", "examples/**"] 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 2.0" 8 | } 9 | template = { 10 | source = "gxben/template" 11 | version = "2.2.0-m1" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /docs/targets.md: -------------------------------------------------------------------------------- 1 | 2 | ## Makefile Targets 3 | ```text 4 | Available targets: 5 | 6 | help Help screen 7 | help/all Display help for all targets 8 | help/short This help short screen 9 | lint Lint terraform code 10 | 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /examples/complete/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.12.26" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 2.0" 8 | } 9 | template = { 10 | source = "hashicorp/template" 11 | version = ">= 2.0" 12 | } 13 | local = { 14 | source = "hashicorp/local" 15 | version = ">= 1.3" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL := /bin/bash 2 | 3 | # List of targets the `readme` target should call before generating the readme 4 | export README_DEPS ?= docs/targets.md docs/terraform.md 5 | 6 | -include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness) 7 | 8 | ## Lint terraform code 9 | lint: 10 | $(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | 3 | contact_links: 4 | 5 | - name: Community Slack Team 6 | url: https://cloudposse.com/slack/ 7 | about: |- 8 | Please ask and answer questions here. 9 | 10 | - name: Office Hours 11 | url: https://cloudposse.com/office-hours/ 12 | about: |- 13 | Join us every Wednesday for FREE Office Hours (lunch & learn). 14 | 15 | - name: DevOps Accelerator Program 16 | url: https://cloudposse.com/accelerate/ 17 | about: |- 18 | Own your infrastructure in record time. We build it. You drive it. 19 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## what 2 | * Describe high-level what changed as a result of these commits (i.e. in plain-english, what do these changes mean?) 3 | * Use bullet points to be concise and to the point. 4 | 5 | ## why 6 | * Provide the justifications for the changes (e.g. business case). 7 | * Describe why these changes were made (e.g. why do these commits fix the problem?) 8 | * Use bullet points to be concise and to the point. 9 | 10 | ## references 11 | * Link to any supporting github issues or helpful documentation to add some context (e.g. stackoverflow). 12 | * Use `closes #123`, if this PR closes a GitHub issue `#123` 13 | 14 | -------------------------------------------------------------------------------- /examples/complete/fixtures.us-east-2.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-2" 2 | 3 | availability_zones = ["us-east-2a", "us-east-2b"] 4 | 5 | namespace = "eg" 6 | 7 | stage = "test" 8 | 9 | name = "suite" 10 | 11 | instance_type = "t2.small" 12 | 13 | health_check_type = "EC2" 14 | 15 | wait_for_capacity_timeout = "10m" 16 | 17 | max_size = 3 18 | 19 | min_size = 2 20 | 21 | autoscaling_policies_enabled = true 22 | 23 | cpu_utilization_high_threshold_percent = 80 24 | 25 | cpu_utilization_low_threshold_percent = 20 26 | 27 | cluster_name = "eg-test-eks-workers-cluster" 28 | 29 | cluster_endpoint = "" 30 | 31 | cluster_certificate_authority_data = "" -------------------------------------------------------------------------------- /userdata.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # userdata for EKS worker nodes to properly configure Kubernetes applications on EC2 instances 4 | # https://docs.aws.amazon.com/eks/latest/userguide/launch-workers.html 5 | # https://aws.amazon.com/blogs/opensource/improvements-eks-worker-node-provisioning/ 6 | # https://github.com/awslabs/amazon-eks-ami/blob/master/files/bootstrap.sh#L97 7 | 8 | ${before_cluster_joining_userdata} 9 | 10 | export KUBELET_EXTRA_ARGS="${kubelet_extra_args}" 11 | 12 | /etc/eks/bootstrap.sh --apiserver-endpoint '${cluster_endpoint}' --b64-cluster-ca '${certificate_authority_data}' ${bootstrap_extra_args} '${cluster_name}' 13 | 14 | ${after_cluster_joining_userdata} 15 | -------------------------------------------------------------------------------- /.github/workflows/auto-release.yml: -------------------------------------------------------------------------------- 1 | name: auto-release 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - master 8 | - production 9 | 10 | jobs: 11 | publish: 12 | runs-on: ubuntu-latest 13 | steps: 14 | # Get PR from merged commit to master 15 | - uses: actions-ecosystem/action-get-merged-pull-request@v1 16 | id: get-merged-pull-request 17 | with: 18 | github_token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} 19 | # Drafts your next Release notes as Pull Requests are merged into "main" 20 | - uses: release-drafter/release-drafter@v5 21 | if: "!contains(steps.get-merged-pull-request.outputs.labels, 'no-release')" 22 | with: 23 | publish: true 24 | prerelease: false 25 | config-name: auto-release.yml 26 | env: 27 | GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} 28 | -------------------------------------------------------------------------------- /test/src/Makefile: -------------------------------------------------------------------------------- 1 | export TF_CLI_ARGS_init ?= -get-plugins=true 2 | export TERRAFORM_VERSION ?= $(shell curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version' | cut -d. -f1-2) 3 | 4 | .DEFAULT_GOAL : all 5 | .PHONY: all 6 | 7 | ## Default target 8 | all: test 9 | 10 | .PHONY : init 11 | ## Initialize tests 12 | init: 13 | @exit 0 14 | 15 | .PHONY : test 16 | ## Run tests 17 | test: init 18 | go mod download 19 | go test -v -timeout 60m -run TestExamplesComplete 20 | 21 | ## Run tests in docker container 22 | docker/test: 23 | docker run --name terratest --rm -it -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e GITHUB_TOKEN \ 24 | -e PATH="/usr/local/terraform/$(TERRAFORM_VERSION)/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ 25 | -v $(CURDIR)/../../:/module/ cloudposse/test-harness:latest -C /module/test/src test 26 | 27 | .PHONY : clean 28 | ## Clean up files 29 | clean: 30 | rm -rf ../../examples/complete/*.tfstate* 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: 'bug' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Found a bug? Maybe our [Slack Community](https://slack.cloudposse.com) can help. 11 | 12 | [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) 13 | 14 | ## Describe the Bug 15 | A clear and concise description of what the bug is. 16 | 17 | ## Expected Behavior 18 | A clear and concise description of what you expected to happen. 19 | 20 | ## Steps to Reproduce 21 | Steps to reproduce the behavior: 22 | 1. Go to '...' 23 | 2. Run '....' 24 | 3. Enter '....' 25 | 4. See error 26 | 27 | ## Screenshots 28 | If applicable, add screenshots or logs to help explain your problem. 29 | 30 | ## Environment (please complete the following information): 31 | 32 | Anything that will help us triage the bug will help. Here are some ideas: 33 | - OS: [e.g. Linux, OSX, WSL, etc] 34 | - Version [e.g. 10.15] 35 | 36 | ## Additional Context 37 | Add any other context about the problem here. -------------------------------------------------------------------------------- /.github/workflows/validate-codeowners.yml: -------------------------------------------------------------------------------- 1 | name: Validate Codeowners 2 | on: 3 | workflow_dispatch: 4 | 5 | pull_request: 6 | 7 | jobs: 8 | validate-codeowners: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: "Checkout source code at current commit" 12 | uses: actions/checkout@v2 13 | - uses: mszostok/codeowners-validator@v0.5.0 14 | if: github.event.pull_request.head.repo.full_name == github.repository 15 | name: "Full check of CODEOWNERS" 16 | with: 17 | # For now, remove "files" check to allow CODEOWNERS to specify non-existent 18 | # files so we can use the same CODEOWNERS file for Terraform and non-Terraform repos 19 | # checks: "files,syntax,owners,duppatterns" 20 | checks: "syntax,owners,duppatterns" 21 | # GitHub access token is required only if the `owners` check is enabled 22 | github_access_token: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}" 23 | - uses: mszostok/codeowners-validator@v0.5.0 24 | if: github.event.pull_request.head.repo.full_name != github.repository 25 | name: "Syntax check of CODEOWNERS" 26 | with: 27 | checks: "syntax,duppatterns" 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: 'feature request' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Have a question? Please checkout our [Slack Community](https://slack.cloudposse.com) or visit our [Slack Archive](https://archive.sweetops.com/). 11 | 12 | [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) 13 | 14 | ## Describe the Feature 15 | 16 | A clear and concise description of what the bug is. 17 | 18 | ## Expected Behavior 19 | 20 | A clear and concise description of what you expected to happen. 21 | 22 | ## Use Case 23 | 24 | Is your feature request related to a problem/challenge you are trying to solve? Please provide some additional context of why this feature or capability will be valuable. 25 | 26 | ## Describe Ideal Solution 27 | 28 | A clear and concise description of what you want to happen. If you don't know, that's okay. 29 | 30 | ## Alternatives Considered 31 | 32 | Explain what alternative solutions or features you've considered. 33 | 34 | ## Additional Context 35 | 36 | Add any other context or screenshots about the feature request here. 37 | -------------------------------------------------------------------------------- /.github/workflows/chatops.yml: -------------------------------------------------------------------------------- 1 | name: chatops 2 | on: 3 | issue_comment: 4 | types: [created] 5 | 6 | jobs: 7 | default: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - name: "Handle common commands" 12 | uses: cloudposse/actions/github/slash-command-dispatch@0.22.0 13 | with: 14 | token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} 15 | reaction-token: ${{ secrets.GITHUB_TOKEN }} 16 | repository: cloudposse/actions 17 | commands: rebuild-readme, terraform-fmt 18 | permission: triage 19 | issue-type: pull-request 20 | 21 | test: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: "Checkout commit" 25 | uses: actions/checkout@v2 26 | - name: "Run tests" 27 | uses: cloudposse/actions/github/slash-command-dispatch@0.22.0 28 | with: 29 | token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} 30 | reaction-token: ${{ secrets.GITHUB_TOKEN }} 31 | repository: cloudposse/actions 32 | commands: test 33 | permission: triage 34 | issue-type: pull-request 35 | reactions: false 36 | 37 | 38 | -------------------------------------------------------------------------------- /.github/auto-release.yml: -------------------------------------------------------------------------------- 1 | name-template: 'v$RESOLVED_VERSION' 2 | tag-template: '$RESOLVED_VERSION' 3 | version-template: '$MAJOR.$MINOR.$PATCH' 4 | version-resolver: 5 | major: 6 | labels: 7 | - 'major' 8 | minor: 9 | labels: 10 | - 'minor' 11 | - 'enhancement' 12 | patch: 13 | labels: 14 | - 'auto-update' 15 | - 'patch' 16 | - 'fix' 17 | - 'bugfix' 18 | - 'bug' 19 | - 'hotfix' 20 | default: 'minor' 21 | 22 | categories: 23 | - title: '🚀 Enhancements' 24 | labels: 25 | - 'enhancement' 26 | - 'patch' 27 | - title: '🐛 Bug Fixes' 28 | labels: 29 | - 'fix' 30 | - 'bugfix' 31 | - 'bug' 32 | - 'hotfix' 33 | - title: '🤖 Automatic Updates' 34 | labels: 35 | - 'auto-update' 36 | 37 | change-template: | 38 |
39 | $TITLE @$AUTHOR (#$NUMBER) 40 | 41 | $BODY 42 |
43 | 44 | template: | 45 | $CHANGES 46 | 47 | replacers: 48 | # Remove irrelevant information from Renovate bot 49 | - search: '/(?<=---\s+)+^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm' 50 | replace: '' 51 | # Remove Renovate bot banner image 52 | - search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm' 53 | replace: '' 54 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Use this file to define individuals or teams that are responsible for code in a repository. 2 | # Read more: 3 | # 4 | # Order is important: the last matching pattern has the highest precedence 5 | 6 | # These owners will be the default owners for everything 7 | * @cloudposse/engineering @cloudposse/contributors 8 | 9 | # Cloud Posse must review any changes to Makefiles 10 | **/Makefile @cloudposse/engineering 11 | **/Makefile.* @cloudposse/engineering 12 | 13 | # Cloud Posse must review any changes to GitHub actions 14 | .github/* @cloudposse/engineering 15 | 16 | # Cloud Posse must review any changes to standard context definition, 17 | # but some changes can be rubber-stamped. 18 | **/*.tf @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers 19 | README.yaml @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers 20 | README.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers 21 | docs/*.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers 22 | 23 | # Cloud Posse Admins must review all changes to CODEOWNERS or the mergify configuration 24 | .github/mergify.yml @cloudposse/admins 25 | .github/CODEOWNERS @cloudposse/admins 26 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | TEST_HARNESS ?= https://github.com/cloudposse/test-harness.git 2 | TEST_HARNESS_BRANCH ?= master 3 | TEST_HARNESS_PATH = $(realpath .test-harness) 4 | BATS_ARGS ?= --tap 5 | BATS_LOG ?= test.log 6 | 7 | # Define a macro to run the tests 8 | define RUN_TESTS 9 | @echo "Running tests in $(1)" 10 | @cd $(1) && bats $(BATS_ARGS) $(addsuffix .bats,$(addprefix $(TEST_HARNESS_PATH)/test/terraform/,$(TESTS))) 11 | endef 12 | 13 | default: all 14 | 15 | -include Makefile.* 16 | 17 | ## Provision the test-harnesss 18 | .test-harness: 19 | [ -d $@ ] || git clone --depth=1 -b $(TEST_HARNESS_BRANCH) $(TEST_HARNESS) $@ 20 | 21 | ## Initialize the tests 22 | init: .test-harness 23 | 24 | ## Install all dependencies (OS specific) 25 | deps:: 26 | @exit 0 27 | 28 | ## Clean up the test harness 29 | clean: 30 | [ "$(TEST_HARNESS_PATH)" == "/" ] || rm -rf $(TEST_HARNESS_PATH) 31 | 32 | ## Run all tests 33 | all: module examples/complete 34 | 35 | ## Run basic sanity checks against the module itself 36 | module: export TESTS ?= installed lint get-modules module-pinning get-plugins provider-pinning validate terraform-docs input-descriptions output-descriptions 37 | module: deps 38 | $(call RUN_TESTS, ../) 39 | 40 | ## Run tests against example 41 | examples/complete: export TESTS ?= installed lint get-modules get-plugins validate 42 | examples/complete: deps 43 | $(call RUN_TESTS, ../$@) 44 | -------------------------------------------------------------------------------- /examples/complete/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | type = string 3 | description = "AWS Region" 4 | } 5 | 6 | variable "availability_zones" { 7 | type = list(string) 8 | description = "List of availability zones" 9 | } 10 | 11 | 12 | variable "cluster_name" { 13 | type = string 14 | description = "The name of the EKS cluster" 15 | } 16 | 17 | variable "cluster_endpoint" { 18 | type = string 19 | description = "EKS cluster endpoint" 20 | } 21 | 22 | variable "cluster_certificate_authority_data" { 23 | type = string 24 | description = "The base64 encoded certificate data required to communicate with the cluster" 25 | } 26 | 27 | variable "instance_type" { 28 | type = string 29 | description = "Instance type to launch" 30 | } 31 | 32 | variable "max_size" { 33 | type = number 34 | description = "The maximum size of the autoscale group" 35 | } 36 | 37 | variable "min_size" { 38 | type = number 39 | description = "The minimum size of the autoscale group" 40 | } 41 | 42 | variable "health_check_type" { 43 | type = string 44 | description = "Controls how health checking is done. Valid values are `EC2` or `ELB`" 45 | } 46 | 47 | variable "wait_for_capacity_timeout" { 48 | type = string 49 | description = "A maximum duration that Terraform should wait for ASG instances to be healthy before timing out. Setting this to '0' causes Terraform to skip all Capacity Waiting behavior" 50 | } 51 | 52 | variable "autoscaling_policies_enabled" { 53 | type = bool 54 | description = "Whether to create `aws_autoscaling_policy` and `aws_cloudwatch_metric_alarm` resources to control Auto Scaling" 55 | } 56 | 57 | variable "cpu_utilization_high_threshold_percent" { 58 | type = number 59 | description = "The value against which the specified statistic is compared" 60 | } 61 | 62 | variable "cpu_utilization_low_threshold_percent" { 63 | type = number 64 | description = "The value against which the specified statistic is compared" 65 | } 66 | -------------------------------------------------------------------------------- /.github/mergify.yml: -------------------------------------------------------------------------------- 1 | # https://docs.mergify.io/conditions.html 2 | # https://docs.mergify.io/actions.html 3 | pull_request_rules: 4 | - name: "approve automated PRs that have passed checks" 5 | conditions: 6 | - "author~=^(cloudpossebot|renovate\\[bot\\])$" 7 | - "base=master" 8 | - "-closed" 9 | - "head~=^(auto-update|renovate)/.*" 10 | - "check-success=test/bats" 11 | - "check-success=test/readme" 12 | - "check-success=test/terratest" 13 | - "check-success=validate-codeowners" 14 | actions: 15 | review: 16 | type: "APPROVE" 17 | bot_account: "cloudposse-mergebot" 18 | message: "We've automatically approved this PR because the checks from the automated Pull Request have passed." 19 | 20 | - name: "merge automated PRs when approved and tests pass" 21 | conditions: 22 | - "author~=^(cloudpossebot|renovate\\[bot\\])$" 23 | - "base=master" 24 | - "-closed" 25 | - "head~=^(auto-update|renovate)/.*" 26 | - "check-success=test/bats" 27 | - "check-success=test/readme" 28 | - "check-success=test/terratest" 29 | - "check-success=validate-codeowners" 30 | - "#approved-reviews-by>=1" 31 | - "#changes-requested-reviews-by=0" 32 | - "#commented-reviews-by=0" 33 | actions: 34 | merge: 35 | method: "squash" 36 | 37 | - name: "delete the head branch after merge" 38 | conditions: 39 | - "merged" 40 | actions: 41 | delete_head_branch: {} 42 | 43 | - name: "ask to resolve conflict" 44 | conditions: 45 | - "conflict" 46 | - "-closed" 47 | actions: 48 | comment: 49 | message: "This pull request is now in conflict. Could you fix it @{{author}}? 🙏" 50 | 51 | - name: "remove outdated reviews" 52 | conditions: 53 | - "base=master" 54 | actions: 55 | dismiss_reviews: 56 | changes_requested: true 57 | approved: true 58 | message: "This Pull Request has been updated, so we're dismissing all reviews." 59 | 60 | - name: "close Pull Requests without files changed" 61 | conditions: 62 | - "#files=0" 63 | actions: 64 | close: 65 | message: "This pull request has been automatically closed by Mergify because there are no longer any changes." 66 | -------------------------------------------------------------------------------- /.github/workflows/auto-context.yml: -------------------------------------------------------------------------------- 1 | name: "auto-context" 2 | on: 3 | schedule: 4 | # Update context.tf nightly 5 | - cron: '0 3 * * *' 6 | 7 | jobs: 8 | update: 9 | if: github.event_name == 'schedule' 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | 14 | - name: Update context.tf 15 | shell: bash 16 | id: update 17 | env: 18 | GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" 19 | run: | 20 | if [[ -f context.tf ]]; then 21 | echo "Discovered existing context.tf! Fetching most recent version to see if there is an update." 22 | curl -o context.tf -fsSL https://raw.githubusercontent.com/cloudposse/terraform-null-label/master/exports/context.tf 23 | if git diff --no-patch --exit-code context.tf; then 24 | echo "No changes detected! Exiting the job..." 25 | else 26 | echo "context.tf file has changed. Update examples and rebuild README.md." 27 | make init 28 | make github/init/context.tf 29 | make readme/build 30 | echo "::set-output name=create_pull_request::true" 31 | fi 32 | else 33 | echo "This module has not yet been updated to support the context.tf pattern! Please update in order to support automatic updates." 34 | fi 35 | 36 | - name: Create Pull Request 37 | if: steps.update.outputs.create_pull_request == 'true' 38 | uses: cloudposse/actions/github/create-pull-request@0.22.0 39 | with: 40 | token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} 41 | committer: 'cloudpossebot <11232728+cloudpossebot@users.noreply.github.com>' 42 | author: 'cloudpossebot <11232728+cloudpossebot@users.noreply.github.com>' 43 | commit-message: Update context.tf from origin source 44 | title: Update context.tf 45 | body: |- 46 | ## what 47 | This is an auto-generated PR that updates the `context.tf` file to the latest version from `cloudposse/terraform-null-label` 48 | 49 | ## why 50 | To support all the features of the `context` interface. 51 | 52 | branch: auto-update/context.tf 53 | base: master 54 | delete-branch: true 55 | labels: | 56 | auto-update 57 | context 58 | -------------------------------------------------------------------------------- /outputs.tf: -------------------------------------------------------------------------------- 1 | output "launch_template_id" { 2 | description = "The ID of the launch template" 3 | value = module.autoscale_group.launch_template_id 4 | } 5 | 6 | output "launch_template_arn" { 7 | description = "ARN of the launch template" 8 | value = module.autoscale_group.launch_template_arn 9 | } 10 | 11 | output "autoscaling_group_id" { 12 | description = "The AutoScaling Group ID" 13 | value = module.autoscale_group.autoscaling_group_id 14 | } 15 | 16 | output "autoscaling_group_name" { 17 | description = "The AutoScaling Group name" 18 | value = module.autoscale_group.autoscaling_group_name 19 | } 20 | 21 | output "autoscaling_group_tags" { 22 | description = "A list of tag settings associated with the AutoScaling Group" 23 | value = module.autoscale_group.autoscaling_group_tags 24 | } 25 | 26 | output "autoscaling_group_arn" { 27 | description = "ARN of the AutoScaling Group" 28 | value = module.autoscale_group.autoscaling_group_arn 29 | } 30 | 31 | output "autoscaling_group_min_size" { 32 | description = "The minimum size of the AutoScaling Group" 33 | value = module.autoscale_group.autoscaling_group_min_size 34 | } 35 | 36 | output "autoscaling_group_max_size" { 37 | description = "The maximum size of the AutoScaling Group" 38 | value = module.autoscale_group.autoscaling_group_max_size 39 | } 40 | 41 | output "autoscaling_group_desired_capacity" { 42 | description = "The number of Amazon EC2 instances that should be running in the group" 43 | value = module.autoscale_group.autoscaling_group_desired_capacity 44 | } 45 | 46 | output "autoscaling_group_default_cooldown" { 47 | description = "Time between a scaling activity and the succeeding scaling activity" 48 | value = module.autoscale_group.autoscaling_group_default_cooldown 49 | } 50 | 51 | output "autoscaling_group_health_check_grace_period" { 52 | description = "Time after instance comes into service before checking health" 53 | value = module.autoscale_group.autoscaling_group_health_check_grace_period 54 | } 55 | 56 | output "autoscaling_group_health_check_type" { 57 | description = "`EC2` or `ELB`. Controls how health checking is done" 58 | value = module.autoscale_group.autoscaling_group_health_check_type 59 | } 60 | 61 | output "security_group_id" { 62 | description = "ID of the worker nodes Security Group" 63 | value = module.security_group.id 64 | } 65 | 66 | output "security_group_arn" { 67 | description = "ARN of the worker nodes Security Group" 68 | value = module.security_group.arn 69 | } 70 | 71 | output "security_group_name" { 72 | description = "Name of the worker nodes Security Group" 73 | value = module.security_group.name 74 | } 75 | 76 | output "workers_role_arn" { 77 | description = "ARN of the worker nodes IAM role" 78 | value = local.workers_role_arn 79 | } 80 | 81 | output "workers_role_name" { 82 | description = "Name of the worker nodes IAM role" 83 | value = local.workers_role_name 84 | } 85 | -------------------------------------------------------------------------------- /examples/complete/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | locals { 6 | # The usage of the specific kubernetes.io/cluster/* resource tags below are required 7 | # for EKS and Kubernetes to discover and manage networking resources 8 | # https://www.terraform.io/docs/providers/aws/guides/eks-getting-started.html#base-vpc-networking 9 | tags = { "kubernetes.io/cluster/${var.cluster_name}" = "shared" } 10 | } 11 | 12 | module "vpc" { 13 | source = "cloudposse/vpc/aws" 14 | version = "0.18.2" 15 | 16 | cidr_block = "172.16.0.0/16" 17 | tags = local.tags 18 | 19 | context = module.this.context 20 | } 21 | 22 | module "subnets" { 23 | source = "cloudposse/dynamic-subnets/aws" 24 | version = "0.36.0" 25 | 26 | availability_zones = var.availability_zones 27 | vpc_id = module.vpc.vpc_id 28 | igw_id = module.vpc.igw_id 29 | cidr_block = module.vpc.vpc_cidr_block 30 | nat_gateway_enabled = false 31 | nat_instance_enabled = false 32 | tags = local.tags 33 | 34 | context = module.this.context 35 | } 36 | 37 | module "eks_workers" { 38 | source = "../../" 39 | 40 | instance_type = var.instance_type 41 | vpc_id = module.vpc.vpc_id 42 | subnet_ids = module.subnets.public_subnet_ids 43 | health_check_type = var.health_check_type 44 | min_size = var.min_size 45 | max_size = var.max_size 46 | wait_for_capacity_timeout = var.wait_for_capacity_timeout 47 | cluster_name = var.cluster_name 48 | cluster_endpoint = var.cluster_endpoint 49 | cluster_certificate_authority_data = var.cluster_certificate_authority_data 50 | bootstrap_extra_args = "--use-max-pods false" 51 | kubelet_extra_args = "--node-labels=purpose=ci-worker" 52 | 53 | security_group_rules = [ 54 | { 55 | type = "egress" 56 | from_port = 0 57 | to_port = 65535 58 | protocol = "-1" 59 | cidr_blocks = ["0.0.0.0/0"] 60 | source_security_group_id = null 61 | description = "Allow all outbound traffic" 62 | }, 63 | { 64 | type = "ingress" 65 | from_port = 0 66 | to_port = 65535 67 | protocol = "-1" 68 | cidr_blocks = [] 69 | source_security_group_id = module.vpc.vpc_default_security_group_id 70 | description = "Allow all inbound traffic from trusted Security Groups" 71 | }, 72 | ] 73 | 74 | # Auto-scaling policies and CloudWatch metric alarms 75 | autoscaling_policies_enabled = var.autoscaling_policies_enabled 76 | cpu_utilization_high_threshold_percent = var.cpu_utilization_high_threshold_percent 77 | cpu_utilization_low_threshold_percent = var.cpu_utilization_low_threshold_percent 78 | 79 | context = module.this.context 80 | } 81 | -------------------------------------------------------------------------------- /examples/complete/outputs.tf: -------------------------------------------------------------------------------- 1 | output "public_subnet_cidrs" { 2 | value = module.subnets.public_subnet_cidrs 3 | description = "Public subnet CIDRs" 4 | } 5 | 6 | output "private_subnet_cidrs" { 7 | value = module.subnets.private_subnet_cidrs 8 | description = "Private subnet CIDRs" 9 | } 10 | 11 | output "vpc_cidr" { 12 | value = module.vpc.vpc_cidr_block 13 | description = "VPC ID" 14 | } 15 | 16 | output "launch_template_id" { 17 | description = "ID of the launch template" 18 | value = module.eks_workers.launch_template_id 19 | } 20 | 21 | output "launch_template_arn" { 22 | description = "ARN of the launch template" 23 | value = module.eks_workers.launch_template_arn 24 | } 25 | 26 | output "autoscaling_group_id" { 27 | description = "The AutoScaling Group ID" 28 | value = module.eks_workers.autoscaling_group_id 29 | } 30 | 31 | output "autoscaling_group_name" { 32 | description = "The AutoScaling Group name" 33 | value = module.eks_workers.autoscaling_group_name 34 | } 35 | 36 | output "autoscaling_group_tags" { 37 | description = "A list of tag settings associated with the AutoScaling Group" 38 | value = module.eks_workers.autoscaling_group_tags 39 | } 40 | 41 | output "autoscaling_group_arn" { 42 | description = "ARN of the AutoScaling Group" 43 | value = module.eks_workers.autoscaling_group_arn 44 | } 45 | 46 | output "autoscaling_group_min_size" { 47 | description = "The minimum size of the AutoScaling Group" 48 | value = module.eks_workers.autoscaling_group_min_size 49 | } 50 | 51 | output "autoscaling_group_max_size" { 52 | description = "The maximum size of the AutoScaling Group" 53 | value = module.eks_workers.autoscaling_group_max_size 54 | } 55 | 56 | output "autoscaling_group_desired_capacity" { 57 | description = "The number of Amazon EC2 instances that should be running in the group" 58 | value = module.eks_workers.autoscaling_group_desired_capacity 59 | } 60 | 61 | output "autoscaling_group_default_cooldown" { 62 | description = "Time between a scaling activity and the succeeding scaling activity" 63 | value = module.eks_workers.autoscaling_group_default_cooldown 64 | } 65 | 66 | output "autoscaling_group_health_check_grace_period" { 67 | description = "Time after instance comes into service before checking health" 68 | value = module.eks_workers.autoscaling_group_health_check_grace_period 69 | } 70 | 71 | output "autoscaling_group_health_check_type" { 72 | description = "`EC2` or `ELB`. Controls how health checking is done" 73 | value = module.eks_workers.autoscaling_group_health_check_type 74 | } 75 | 76 | output "security_group_id" { 77 | description = "ID of the worker nodes Security Group" 78 | value = module.eks_workers.security_group_id 79 | } 80 | 81 | output "security_group_arn" { 82 | description = "ARN of the worker nodes Security Group" 83 | value = module.eks_workers.security_group_arn 84 | } 85 | 86 | output "security_group_name" { 87 | description = "Name of the worker nodes Security Group" 88 | value = module.eks_workers.security_group_name 89 | } 90 | 91 | output "workers_role_arn" { 92 | description = "ARN of the worker nodes IAM role" 93 | value = module.eks_workers.workers_role_arn 94 | } 95 | 96 | output "workers_role_name" { 97 | description = "Name of the worker nodes IAM role" 98 | value = module.eks_workers.workers_role_name 99 | } 100 | -------------------------------------------------------------------------------- /.github/workflows/auto-format.yml: -------------------------------------------------------------------------------- 1 | name: Auto Format 2 | on: 3 | pull_request_target: 4 | types: [opened, synchronize] 5 | 6 | jobs: 7 | auto-format: 8 | runs-on: ubuntu-latest 9 | container: cloudposse/build-harness:latest 10 | steps: 11 | # Checkout the pull request branch 12 | # "An action in a workflow run can’t trigger a new workflow run. For example, if an action pushes code using 13 | # the repository’s GITHUB_TOKEN, a new workflow will not run even when the repository contains 14 | # a workflow configured to run when push events occur." 15 | # However, using a personal access token will cause events to be triggered. 16 | # We need that to ensure a status gets posted after the auto-format commit. 17 | # We also want to trigger tests if the auto-format made no changes. 18 | - uses: actions/checkout@v2 19 | if: github.event.pull_request.state == 'open' 20 | name: Privileged Checkout 21 | with: 22 | token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} 23 | repository: ${{ github.event.pull_request.head.repo.full_name }} 24 | # Check out the PR commit, not the merge commit 25 | # Use `ref` instead of `sha` to enable pushing back to `ref` 26 | ref: ${{ github.event.pull_request.head.ref }} 27 | 28 | # Do all the formatting stuff 29 | - name: Auto Format 30 | if: github.event.pull_request.state == 'open' 31 | shell: bash 32 | env: 33 | GITHUB_TOKEN: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}" 34 | run: make BUILD_HARNESS_PATH=/build-harness PACKAGES_PREFER_HOST=true -f /build-harness/templates/Makefile.build-harness pr/auto-format/host 35 | 36 | # Commit changes (if any) to the PR branch 37 | - name: Commit changes to the PR branch 38 | if: github.event.pull_request.state == 'open' 39 | shell: bash 40 | id: commit 41 | env: 42 | SENDER: ${{ github.event.sender.login }} 43 | run: | 44 | set -x 45 | output=$(git diff --name-only) 46 | 47 | if [ -n "$output" ]; then 48 | echo "Changes detected. Pushing to the PR branch" 49 | git config --global user.name 'cloudpossebot' 50 | git config --global user.email '11232728+cloudpossebot@users.noreply.github.com' 51 | git add -A 52 | git commit -m "Auto Format" 53 | # Prevent looping by not pushing changes in response to changes from cloudpossebot 54 | [[ $SENDER == "cloudpossebot" ]] || git push 55 | # Set status to fail, because the push should trigger another status check, 56 | # and we use success to indicate the checks are finished. 57 | printf "::set-output name=%s::%s\n" "changed" "true" 58 | exit 1 59 | else 60 | printf "::set-output name=%s::%s\n" "changed" "false" 61 | echo "No changes detected" 62 | fi 63 | 64 | - name: Auto Test 65 | uses: cloudposse/actions/github/repository-dispatch@0.22.0 66 | # match users by ID because logins (user names) are inconsistent, 67 | # for example in the REST API Renovate Bot is `renovate[bot]` but 68 | # in GraphQL it is just `renovate`, plus there is a non-bot 69 | # user `renovate` with ID 1832810. 70 | # Mergify bot: 37929162 71 | # Renovate bot: 29139614 72 | # Cloudpossebot: 11232728 73 | # Need to use space separators to prevent "21" from matching "112144" 74 | if: > 75 | contains(' 37929162 29139614 11232728 ', format(' {0} ', github.event.pull_request.user.id)) 76 | && steps.commit.outputs.changed == 'false' && github.event.pull_request.state == 'open' 77 | with: 78 | token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} 79 | repository: cloudposse/actions 80 | event-type: test-command 81 | client-payload: |- 82 | { "slash_command":{"args": {"unnamed": {"all": "all", "arg1": "all"}}}, 83 | "pull_request": ${{ toJSON(github.event.pull_request) }}, 84 | "github":{"payload":{"repository": ${{ toJSON(github.event.repository) }}, 85 | "comment": {"id": ""} 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /test/src/examples_complete_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "math/rand" 5 | "regexp" 6 | "strconv" 7 | "testing" 8 | "time" 9 | 10 | "github.com/gruntwork-io/terratest/modules/terraform" 11 | "github.com/stretchr/testify/assert" 12 | ) 13 | 14 | type TerraformMapString map[string]string 15 | 16 | // Test the Terraform module in examples/complete using Terratest. 17 | func TestExamplesComplete(t *testing.T) { 18 | t.Parallel() 19 | 20 | rand.Seed(time.Now().UnixNano()) 21 | 22 | randId := strconv.Itoa(rand.Intn(100000)) 23 | attributes := []string{randId} 24 | 25 | terraformOptions := &terraform.Options{ 26 | // The path to where our Terraform code is located 27 | TerraformDir: "../../examples/complete", 28 | Upgrade: true, 29 | // Variables to pass to our Terraform code using -var-file options 30 | VarFiles: []string{"fixtures.us-east-2.tfvars"}, 31 | Vars: map[string]interface{}{ 32 | "attributes": attributes, 33 | }, 34 | } 35 | 36 | expectedPrefix := "eg-test-suite-" + randId 37 | 38 | // At the end of the test, run `terraform destroy` to clean up any resources that were created 39 | defer terraform.Destroy(t, terraformOptions) 40 | 41 | // This will run `terraform init` and `terraform apply` and fail the test if there are any errors 42 | terraform.InitAndApply(t, terraformOptions) 43 | 44 | // Run `terraform output` to get the value of an output variable 45 | vpcCidr := terraform.Output(t, terraformOptions, "vpc_cidr") 46 | // Verify we're getting back the outputs we expect 47 | assert.Equal(t, "172.16.0.0/16", vpcCidr) 48 | 49 | // Run `terraform output` to get the value of an output variable 50 | privateSubnetCidrs := terraform.OutputList(t, terraformOptions, "private_subnet_cidrs") 51 | // Verify we're getting back the outputs we expect 52 | assert.Equal(t, []string{"172.16.0.0/19", "172.16.32.0/19"}, privateSubnetCidrs) 53 | 54 | // Run `terraform output` to get the value of an output variable 55 | publicSubnetCidrs := terraform.OutputList(t, terraformOptions, "public_subnet_cidrs") 56 | // Verify we're getting back the outputs we expect 57 | assert.Equal(t, []string{"172.16.96.0/19", "172.16.128.0/19"}, publicSubnetCidrs) 58 | 59 | // Run `terraform output` to get the value of an output variable 60 | // autoscaling_group_name = eg-test-suite-20210416185727403200000006 61 | autoscalingGroupName := terraform.Output(t, terraformOptions, "autoscaling_group_name") 62 | // Verify we're getting back the outputs we expect 63 | assert.Regexp(t, regexp.MustCompile(`^`+expectedPrefix+`-\d+$`), autoscalingGroupName, "Autoscaling Group name should be our expected prefix plus a random suffix") 64 | 65 | // Run `terraform output` to get the value of an output variable 66 | var tags []TerraformMapString 67 | 68 | terraform.OutputStruct(t, terraformOptions, "autoscaling_group_tags", &tags) 69 | expectedTag := TerraformMapString{ 70 | "key": "Name", 71 | "value": expectedPrefix, 72 | "propagate_at_launch": "true", 73 | } 74 | 75 | assert.Contains(t, tags, expectedTag, `Tag "Name" should match eks-workers module ID`) 76 | 77 | // "kubernetes.io/cluster/${var.cluster_name}" = "owned" 78 | expectedTag = TerraformMapString{ 79 | "key": "kubernetes.io/cluster/eg-test-eks-workers-cluster", 80 | "value": "owned", 81 | "propagate_at_launch": "true", 82 | } 83 | 84 | assert.Contains(t, tags, expectedTag, `Tag "kubernetes.io/cluster/eg-test-eks-workers-cluster" = "owned" should be present and propagate`) 85 | 86 | // Run `terraform output` to get the value of an output variable 87 | launchTemplateArn := terraform.Output(t, terraformOptions, "launch_template_arn") 88 | launchTemplateId := terraform.Output(t, terraformOptions, "launch_template_id") 89 | // Verify we're getting back the outputs we expect 90 | // arn:aws:ec2:us-east-2:126450723953:launch-template/ 91 | assert.Equal(t, "arn:aws:ec2:us-east-2:126450723953:launch-template/"+launchTemplateId, launchTemplateArn) 92 | 93 | // Run `terraform output` to get the value of an output variable 94 | securityGroupName := terraform.Output(t, terraformOptions, "security_group_name") 95 | // Verify we're getting back the outputs we expect 96 | assert.Equal(t, expectedPrefix+"-workers", securityGroupName) 97 | 98 | // Run `terraform output` to get the value of an output variable 99 | securityGroupID := terraform.Output(t, terraformOptions, "security_group_id") 100 | // Verify we're getting back the outputs we expect 101 | assert.Contains(t, securityGroupID, "sg-", "SG ID should contains substring 'sg-'") 102 | 103 | // Run `terraform output` to get the value of an output variable 104 | securityGroupARN := terraform.Output(t, terraformOptions, "security_group_arn") 105 | // Verify we're getting back the outputs we expect 106 | assert.Contains(t, securityGroupARN, "arn:aws:ec2", "SG ID should contains substring 'arn:aws:ec2'") 107 | 108 | // Run `terraform output` to get the value of an output variable 109 | workerRoleName := terraform.Output(t, terraformOptions, "workers_role_name") 110 | // Verify we're getting back the outputs we expect 111 | assert.Equal(t, expectedPrefix+"-workers", workerRoleName) 112 | } 113 | -------------------------------------------------------------------------------- /README.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # This is the canonical configuration for the `README.md` 3 | # Run `make readme` to rebuild the `README.md` 4 | # 5 | 6 | # Name of this project 7 | name: terraform-aws-eks-workers 8 | # Logo for this project 9 | #logo: docs/logo.png 10 | 11 | # License of this project 12 | license: "APACHE2" 13 | # Canonical GitHub repo 14 | github_repo: cloudposse/terraform-aws-eks-workers 15 | # Badges to display 16 | badges: 17 | - name: "Latest Release" 18 | image: "https://img.shields.io/github/release/cloudposse/terraform-aws-eks-workers.svg" 19 | url: "https://github.com/cloudposse/terraform-aws-eks-workers/releases/latest" 20 | - name: "Slack Community" 21 | image: "https://slack.cloudposse.com/badge.svg" 22 | url: "https://slack.cloudposse.com" 23 | related: 24 | - name: "terraform-aws-ec2-autoscale-group" 25 | description: "Terraform module to provision Auto Scaling Group and Launch Template on AWS" 26 | url: "https://github.com/cloudposse/terraform-aws-ec2-autoscale-group" 27 | - name: "terraform-aws-ecs-container-definition" 28 | description: "Terraform module to generate well-formed JSON documents (container definitions) that are passed to the aws_ecs_task_definition Terraform resource" 29 | url: "https://github.com/cloudposse/terraform-aws-ecs-container-definition" 30 | - name: "terraform-aws-ecs-alb-service-task" 31 | description: "Terraform module which implements an ECS service which exposes a web service via ALB" 32 | url: "https://github.com/cloudposse/terraform-aws-ecs-alb-service-task" 33 | - name: "terraform-aws-ecs-web-app" 34 | description: "Terraform module that implements a web app on ECS and supports autoscaling, CI/CD, monitoring, ALB integration, and much more" 35 | url: "https://github.com/cloudposse/terraform-aws-ecs-web-app" 36 | - name: "terraform-aws-ecs-codepipeline" 37 | description: "Terraform module for CI/CD with AWS Code Pipeline and Code Build for ECS" 38 | url: "https://github.com/cloudposse/terraform-aws-ecs-codepipeline" 39 | - name: "terraform-aws-ecs-cloudwatch-autoscaling" 40 | description: "Terraform module to autoscale ECS Service based on CloudWatch metrics" 41 | url: "https://github.com/cloudposse/terraform-aws-ecs-cloudwatch-autoscaling" 42 | - name: "terraform-aws-ecs-cloudwatch-sns-alarms" 43 | description: "Terraform module to create CloudWatch Alarms on ECS Service level metrics" 44 | url: "https://github.com/cloudposse/terraform-aws-ecs-cloudwatch-sns-alarms" 45 | - name: "terraform-aws-ec2-instance" 46 | description: "Terraform module for providing a general purpose EC2 instance" 47 | url: "https://github.com/cloudposse/terraform-aws-ec2-instance" 48 | - name: "terraform-aws-ec2-instance-group" 49 | description: "Terraform module for provisioning multiple general purpose EC2 hosts for stateful applications" 50 | url: "https://github.com/cloudposse/terraform-aws-ec2-instance-group" 51 | # Short description of this project 52 | description: |- 53 | Terraform module to provision AWS resources to run EC2 worker nodes for [Elastic Container Service for Kubernetes](https://aws.amazon.com/eks/). 54 | 55 | Instantiate it multiple times to create many EKS worker node pools with specific settings such as GPUs, EC2 instance types, or autoscale parameters. 56 | introduction: |- 57 | The module provisions the following resources: 58 | 59 | - IAM Role and Instance Profile to allow Kubernetes nodes to access other AWS services 60 | - Security Group with rules for EKS workers to allow networking traffic 61 | - AutoScaling Group with Launch Template to configure and launch worker instances 62 | - AutoScaling Policies and CloudWatch Metric Alarms to monitor CPU utilization on the EC2 instances and scale the number of instance in the AutoScaling Group up or down. 63 | If you don't want to use the provided functionality, or want to provide your own policies, disable it by setting the variable `autoscaling_policies_enabled` to `"false"`. 64 | # How to use this project 65 | usage: |2- 66 | 67 | For a complete example, see [examples/complete](examples/complete) 68 | 69 | ```hcl 70 | provider "aws" { 71 | region = var.region 72 | } 73 | 74 | locals { 75 | # The usage of the specific kubernetes.io/cluster/* resource tags below are required 76 | # for EKS and Kubernetes to discover and manage networking resources 77 | # https://www.terraform.io/docs/providers/aws/guides/eks-getting-started.html#base-vpc-networking 78 | tags = merge(var.tags, map("kubernetes.io/cluster/${var.cluster_name}", "shared")) 79 | } 80 | 81 | module "vpc" { 82 | source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.8.0" 83 | namespace = var.namespace 84 | stage = var.stage 85 | name = var.name 86 | cidr_block = "172.16.0.0/16" 87 | tags = local.tags 88 | } 89 | 90 | module "subnets" { 91 | source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.16.0" 92 | availability_zones = var.availability_zones 93 | namespace = var.namespace 94 | stage = var.stage 95 | name = var.name 96 | vpc_id = module.vpc.vpc_id 97 | igw_id = module.vpc.igw_id 98 | cidr_block = module.vpc.vpc_cidr_block 99 | nat_gateway_enabled = false 100 | nat_instance_enabled = false 101 | tags = local.tags 102 | } 103 | 104 | module "eks_workers" { 105 | source = "cloudposse/eks-workers/aws" 106 | # Cloud Posse recommends pinning every module to a specific version 107 | # version = "x.x.x" 108 | namespace = var.namespace 109 | stage = var.stage 110 | name = var.name 111 | instance_type = var.instance_type 112 | vpc_id = module.vpc.vpc_id 113 | subnet_ids = module.subnets.public_subnet_ids 114 | health_check_type = var.health_check_type 115 | min_size = var.min_size 116 | max_size = var.max_size 117 | wait_for_capacity_timeout = var.wait_for_capacity_timeout 118 | cluster_name = var.cluster_name 119 | cluster_endpoint = var.cluster_endpoint 120 | cluster_certificate_authority_data = var.cluster_certificate_authority_data 121 | 122 | security_group_rules = [ 123 | { 124 | type = "egress" 125 | from_port = 0 126 | to_port = 65535 127 | protocol = "-1" 128 | cidr_blocks = ["0.0.0.0/0"] 129 | source_security_group_id = null 130 | description = "Allow all outbound traffic" 131 | }, 132 | { 133 | type = "ingress" 134 | from_port = 0 135 | to_port = 65535 136 | protocol = "-1" 137 | cidr_blocks = [] 138 | source_security_group_id = "sg-XXXXXXXXX" 139 | description = "Allow all inbound traffic from Security Group ID of the EKS cluster" 140 | } 141 | ] 142 | 143 | # Auto-scaling policies and CloudWatch metric alarms 144 | autoscaling_policies_enabled = var.autoscaling_policies_enabled 145 | cpu_utilization_high_threshold_percent = var.cpu_utilization_high_threshold_percent 146 | cpu_utilization_low_threshold_percent = var.cpu_utilization_low_threshold_percent 147 | } 148 | ``` 149 | include: 150 | - "docs/targets.md" 151 | - "docs/terraform.md" 152 | # Contributors to this project 153 | contributors: 154 | - name: "Erik Osterman" 155 | github: "osterman" 156 | - name: "Andriy Knysh" 157 | github: "aknysh" 158 | - name: "Igor Rodionov" 159 | github: "goruha" 160 | - name: Vladimir Syromyatnikov 161 | github: SweetOps 162 | -------------------------------------------------------------------------------- /main.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | enabled = module.this.enabled 3 | tags = { 4 | "kubernetes.io/cluster/${var.cluster_name}" = "owned" 5 | } 6 | 7 | workers_role_arn = var.use_existing_aws_iam_instance_profile ? join("", data.aws_iam_instance_profile.default.*.role_arn) : join("", aws_iam_role.default.*.arn) 8 | workers_role_name = var.use_existing_aws_iam_instance_profile ? join("", data.aws_iam_instance_profile.default.*.role_name) : join("", aws_iam_role.default.*.name) 9 | security_group_enabled = module.this.enabled && var.security_group_enabled 10 | } 11 | 12 | module "label" { 13 | source = "cloudposse/label/null" 14 | version = "0.25.0" 15 | 16 | attributes = ["workers"] 17 | tags = local.tags 18 | 19 | context = module.this.context 20 | } 21 | 22 | data "aws_iam_policy_document" "assume_role" { 23 | count = local.enabled && var.use_existing_aws_iam_instance_profile == false ? 1 : 0 24 | 25 | statement { 26 | effect = "Allow" 27 | actions = ["sts:AssumeRole"] 28 | 29 | principals { 30 | type = "Service" 31 | identifiers = ["ec2.amazonaws.com"] 32 | } 33 | } 34 | } 35 | 36 | resource "aws_iam_role" "default" { 37 | count = local.enabled && var.use_existing_aws_iam_instance_profile == false ? 1 : 0 38 | name = module.label.id 39 | assume_role_policy = join("", data.aws_iam_policy_document.assume_role.*.json) 40 | tags = module.label.tags 41 | permissions_boundary = var.permissions_boundary 42 | } 43 | 44 | resource "aws_iam_role_policy_attachment" "amazon_eks_worker_node_policy" { 45 | count = local.enabled && var.use_existing_aws_iam_instance_profile == false ? 1 : 0 46 | policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy" 47 | role = join("", aws_iam_role.default.*.name) 48 | } 49 | 50 | resource "aws_iam_role_policy_attachment" "amazon_eks_cni_policy" { 51 | count = local.enabled && var.use_existing_aws_iam_instance_profile == false ? 1 : 0 52 | policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy" 53 | role = join("", aws_iam_role.default.*.name) 54 | } 55 | 56 | resource "aws_iam_role_policy_attachment" "amazon_ec2_container_registry_read_only" { 57 | count = local.enabled && var.use_existing_aws_iam_instance_profile == false ? 1 : 0 58 | policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly" 59 | role = join("", aws_iam_role.default.*.name) 60 | } 61 | 62 | resource "aws_iam_role_policy_attachment" "existing_policies_attach_to_eks_workers_role" { 63 | count = local.enabled && var.use_existing_aws_iam_instance_profile == false ? var.workers_role_policy_arns_count : 0 64 | policy_arn = var.workers_role_policy_arns[count.index] 65 | role = join("", aws_iam_role.default.*.name) 66 | } 67 | 68 | resource "aws_iam_instance_profile" "default" { 69 | count = local.enabled && var.use_existing_aws_iam_instance_profile == false ? 1 : 0 70 | name = module.label.id 71 | role = join("", aws_iam_role.default.*.name) 72 | } 73 | 74 | module "security_group" { 75 | source = "cloudposse/security-group/aws" 76 | version = "0.3.3" 77 | 78 | use_name_prefix = var.security_group_use_name_prefix 79 | rules = var.security_group_rules 80 | description = var.security_group_description 81 | vpc_id = var.vpc_id 82 | 83 | enabled = local.security_group_enabled 84 | context = module.label.context 85 | } 86 | 87 | data "aws_ami" "eks_worker" { 88 | count = local.enabled && var.use_custom_image_id == false ? 1 : 0 89 | 90 | most_recent = true 91 | name_regex = var.eks_worker_ami_name_regex 92 | 93 | filter { 94 | name = "name" 95 | values = [var.eks_worker_ami_name_filter] 96 | } 97 | 98 | owners = ["602401143452"] # Amazon 99 | } 100 | 101 | data "template_file" "userdata" { 102 | count = local.enabled ? 1 : 0 103 | template = file("${path.module}/userdata.tpl") 104 | 105 | vars = { 106 | cluster_endpoint = var.cluster_endpoint 107 | certificate_authority_data = var.cluster_certificate_authority_data 108 | cluster_name = var.cluster_name 109 | bootstrap_extra_args = var.bootstrap_extra_args 110 | kubelet_extra_args = var.kubelet_extra_args 111 | before_cluster_joining_userdata = var.before_cluster_joining_userdata 112 | after_cluster_joining_userdata = var.after_cluster_joining_userdata 113 | } 114 | } 115 | 116 | data "aws_iam_instance_profile" "default" { 117 | count = local.enabled && var.use_existing_aws_iam_instance_profile ? 1 : 0 118 | name = var.aws_iam_instance_profile_name 119 | } 120 | 121 | module "autoscale_group" { 122 | source = "cloudposse/ec2-autoscale-group/aws" 123 | version = "0.27.0" 124 | 125 | enabled = local.enabled 126 | tags = merge(local.tags, var.autoscaling_group_tags) 127 | 128 | image_id = var.use_custom_image_id ? var.image_id : join("", data.aws_ami.eks_worker.*.id) 129 | iam_instance_profile_name = var.use_existing_aws_iam_instance_profile == false ? join("", aws_iam_instance_profile.default.*.name) : var.aws_iam_instance_profile_name 130 | 131 | security_group_ids = compact(concat(module.security_group.*.id, var.security_groups)) 132 | 133 | user_data_base64 = base64encode(join("", data.template_file.userdata.*.rendered)) 134 | 135 | instance_type = var.instance_type 136 | subnet_ids = var.subnet_ids 137 | min_size = var.min_size 138 | max_size = var.max_size 139 | associate_public_ip_address = var.associate_public_ip_address 140 | block_device_mappings = var.block_device_mappings 141 | credit_specification = var.credit_specification 142 | disable_api_termination = var.disable_api_termination 143 | ebs_optimized = var.ebs_optimized 144 | elastic_gpu_specifications = var.elastic_gpu_specifications 145 | instance_initiated_shutdown_behavior = var.instance_initiated_shutdown_behavior 146 | instance_market_options = var.instance_market_options 147 | mixed_instances_policy = var.mixed_instances_policy 148 | key_name = var.key_name 149 | placement = var.placement 150 | enable_monitoring = var.enable_monitoring 151 | load_balancers = var.load_balancers 152 | health_check_grace_period = var.health_check_grace_period 153 | health_check_type = var.health_check_type 154 | min_elb_capacity = var.min_elb_capacity 155 | wait_for_elb_capacity = var.wait_for_elb_capacity 156 | target_group_arns = var.target_group_arns 157 | default_cooldown = var.default_cooldown 158 | force_delete = var.force_delete 159 | termination_policies = var.termination_policies 160 | suspended_processes = var.suspended_processes 161 | placement_group = var.placement_group 162 | enabled_metrics = var.enabled_metrics 163 | metrics_granularity = var.metrics_granularity 164 | wait_for_capacity_timeout = var.wait_for_capacity_timeout 165 | protect_from_scale_in = var.protect_from_scale_in 166 | service_linked_role_arn = var.service_linked_role_arn 167 | autoscaling_policies_enabled = var.autoscaling_policies_enabled 168 | scale_up_cooldown_seconds = var.scale_up_cooldown_seconds 169 | scale_up_scaling_adjustment = var.scale_up_scaling_adjustment 170 | scale_up_adjustment_type = var.scale_up_adjustment_type 171 | scale_up_policy_type = var.scale_up_policy_type 172 | scale_down_cooldown_seconds = var.scale_down_cooldown_seconds 173 | scale_down_scaling_adjustment = var.scale_down_scaling_adjustment 174 | scale_down_adjustment_type = var.scale_down_adjustment_type 175 | scale_down_policy_type = var.scale_down_policy_type 176 | cpu_utilization_high_evaluation_periods = var.cpu_utilization_high_evaluation_periods 177 | cpu_utilization_high_period_seconds = var.cpu_utilization_high_period_seconds 178 | cpu_utilization_high_threshold_percent = var.cpu_utilization_high_threshold_percent 179 | cpu_utilization_high_statistic = var.cpu_utilization_high_statistic 180 | cpu_utilization_low_evaluation_periods = var.cpu_utilization_low_evaluation_periods 181 | cpu_utilization_low_period_seconds = var.cpu_utilization_low_period_seconds 182 | cpu_utilization_low_statistic = var.cpu_utilization_low_statistic 183 | cpu_utilization_low_threshold_percent = var.cpu_utilization_low_threshold_percent 184 | metadata_http_endpoint_enabled = var.metadata_http_endpoint_enabled 185 | metadata_http_put_response_hop_limit = var.metadata_http_put_response_hop_limit 186 | metadata_http_tokens_required = var.metadata_http_tokens_required 187 | 188 | context = module.this.context 189 | } 190 | -------------------------------------------------------------------------------- /context.tf: -------------------------------------------------------------------------------- 1 | # 2 | # ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label 3 | # All other instances of this file should be a copy of that one 4 | # 5 | # 6 | # Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf 7 | # and then place it in your Terraform module to automatically get 8 | # Cloud Posse's standard configuration inputs suitable for passing 9 | # to Cloud Posse modules. 10 | # 11 | # curl -sL https://raw.githubusercontent.com/cloudposse/terraform-null-label/master/exports/context.tf -o context.tf 12 | # 13 | # Modules should access the whole context as `module.this.context` 14 | # to get the input variables with nulls for defaults, 15 | # for example `context = module.this.context`, 16 | # and access individual variables as `module.this.`, 17 | # with final values filled in. 18 | # 19 | # For example, when using defaults, `module.this.context.delimiter` 20 | # will be null, and `module.this.delimiter` will be `-` (hyphen). 21 | # 22 | 23 | module "this" { 24 | source = "cloudposse/label/null" 25 | version = "0.25.0" # requires Terraform >= 0.13.0 26 | 27 | enabled = var.enabled 28 | namespace = var.namespace 29 | tenant = var.tenant 30 | environment = var.environment 31 | stage = var.stage 32 | name = var.name 33 | delimiter = var.delimiter 34 | attributes = var.attributes 35 | tags = var.tags 36 | additional_tag_map = var.additional_tag_map 37 | label_order = var.label_order 38 | regex_replace_chars = var.regex_replace_chars 39 | id_length_limit = var.id_length_limit 40 | label_key_case = var.label_key_case 41 | label_value_case = var.label_value_case 42 | descriptor_formats = var.descriptor_formats 43 | labels_as_tags = var.labels_as_tags 44 | 45 | context = var.context 46 | } 47 | 48 | # Copy contents of cloudposse/terraform-null-label/variables.tf here 49 | 50 | variable "context" { 51 | type = any 52 | default = { 53 | enabled = true 54 | namespace = null 55 | tenant = null 56 | environment = null 57 | stage = null 58 | name = null 59 | delimiter = null 60 | attributes = [] 61 | tags = {} 62 | additional_tag_map = {} 63 | regex_replace_chars = null 64 | label_order = [] 65 | id_length_limit = null 66 | label_key_case = null 67 | label_value_case = null 68 | descriptor_formats = {} 69 | # Note: we have to use [] instead of null for unset lists due to 70 | # https://github.com/hashicorp/terraform/issues/28137 71 | # which was not fixed until Terraform 1.0.0, 72 | # but we want the default to be all the labels in `label_order` 73 | # and we want users to be able to prevent all tag generation 74 | # by setting `labels_as_tags` to `[]`, so we need 75 | # a different sentinel to indicate "default" 76 | labels_as_tags = ["unset"] 77 | } 78 | description = <<-EOT 79 | Single object for setting entire context at once. 80 | See description of individual variables for details. 81 | Leave string and numeric variables as `null` to use default value. 82 | Individual variable settings (non-null) override settings in context object, 83 | except for attributes, tags, and additional_tag_map, which are merged. 84 | EOT 85 | 86 | validation { 87 | condition = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"]) 88 | error_message = "Allowed values: `lower`, `title`, `upper`." 89 | } 90 | 91 | validation { 92 | condition = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"]) 93 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`." 94 | } 95 | } 96 | 97 | variable "enabled" { 98 | type = bool 99 | default = null 100 | description = "Set to false to prevent the module from creating any resources" 101 | } 102 | 103 | variable "namespace" { 104 | type = string 105 | default = null 106 | description = "ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique" 107 | } 108 | 109 | variable "tenant" { 110 | type = string 111 | default = null 112 | description = "ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for" 113 | } 114 | 115 | variable "environment" { 116 | type = string 117 | default = null 118 | description = "ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'" 119 | } 120 | 121 | variable "stage" { 122 | type = string 123 | default = null 124 | description = "ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'" 125 | } 126 | 127 | variable "name" { 128 | type = string 129 | default = null 130 | description = <<-EOT 131 | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'. 132 | This is the only ID element not also included as a `tag`. 133 | The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. 134 | EOT 135 | } 136 | 137 | variable "delimiter" { 138 | type = string 139 | default = null 140 | description = <<-EOT 141 | Delimiter to be used between ID elements. 142 | Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. 143 | EOT 144 | } 145 | 146 | variable "attributes" { 147 | type = list(string) 148 | default = [] 149 | description = <<-EOT 150 | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`, 151 | in the order they appear in the list. New attributes are appended to the 152 | end of the list. The elements of the list are joined by the `delimiter` 153 | and treated as a single ID element. 154 | EOT 155 | } 156 | 157 | variable "labels_as_tags" { 158 | type = set(string) 159 | default = ["default"] 160 | description = <<-EOT 161 | Set of labels (ID elements) to include as tags in the `tags` output. 162 | Default is to include all labels. 163 | Tags with empty values will not be included in the `tags` output. 164 | Set to `[]` to suppress all generated tags. 165 | **Notes:** 166 | The value of the `name` tag, if included, will be the `id`, not the `name`. 167 | Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be 168 | changed in later chained modules. Attempts to change it will be silently ignored. 169 | EOT 170 | } 171 | 172 | variable "tags" { 173 | type = map(string) 174 | default = {} 175 | description = <<-EOT 176 | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`). 177 | Neither the tag keys nor the tag values will be modified by this module. 178 | EOT 179 | } 180 | 181 | variable "additional_tag_map" { 182 | type = map(string) 183 | default = {} 184 | description = <<-EOT 185 | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`. 186 | This is for some rare cases where resources want additional configuration of tags 187 | and therefore take a list of maps with tag key, value, and additional configuration. 188 | EOT 189 | } 190 | 191 | variable "label_order" { 192 | type = list(string) 193 | default = null 194 | description = <<-EOT 195 | The order in which the labels (ID elements) appear in the `id`. 196 | Defaults to ["namespace", "environment", "stage", "name", "attributes"]. 197 | You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. 198 | EOT 199 | } 200 | 201 | variable "regex_replace_chars" { 202 | type = string 203 | default = null 204 | description = <<-EOT 205 | Terraform regular expression (regex) string. 206 | Characters matching the regex will be removed from the ID elements. 207 | If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. 208 | EOT 209 | } 210 | 211 | variable "id_length_limit" { 212 | type = number 213 | default = null 214 | description = <<-EOT 215 | Limit `id` to this many characters (minimum 6). 216 | Set to `0` for unlimited length. 217 | Set to `null` for keep the existing setting, which defaults to `0`. 218 | Does not affect `id_full`. 219 | EOT 220 | validation { 221 | condition = var.id_length_limit == null ? true : var.id_length_limit >= 6 || var.id_length_limit == 0 222 | error_message = "The id_length_limit must be >= 6 if supplied (not null), or 0 for unlimited length." 223 | } 224 | } 225 | 226 | variable "label_key_case" { 227 | type = string 228 | default = null 229 | description = <<-EOT 230 | Controls the letter case of the `tags` keys (label names) for tags generated by this module. 231 | Does not affect keys of tags passed in via the `tags` input. 232 | Possible values: `lower`, `title`, `upper`. 233 | Default value: `title`. 234 | EOT 235 | 236 | validation { 237 | condition = var.label_key_case == null ? true : contains(["lower", "title", "upper"], var.label_key_case) 238 | error_message = "Allowed values: `lower`, `title`, `upper`." 239 | } 240 | } 241 | 242 | variable "label_value_case" { 243 | type = string 244 | default = null 245 | description = <<-EOT 246 | Controls the letter case of ID elements (labels) as included in `id`, 247 | set as tag values, and output by this module individually. 248 | Does not affect values of tags passed in via the `tags` input. 249 | Possible values: `lower`, `title`, `upper` and `none` (no transformation). 250 | Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs. 251 | Default value: `lower`. 252 | EOT 253 | 254 | validation { 255 | condition = var.label_value_case == null ? true : contains(["lower", "title", "upper", "none"], var.label_value_case) 256 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`." 257 | } 258 | } 259 | 260 | variable "descriptor_formats" { 261 | type = any 262 | default = {} 263 | description = <<-EOT 264 | Describe additional descriptors to be output in the `descriptors` output map. 265 | Map of maps. Keys are names of descriptors. Values are maps of the form 266 | `{ 267 | format = string 268 | labels = list(string) 269 | }` 270 | (Type is `any` so the map values can later be enhanced to provide additional options.) 271 | `format` is a Terraform format string to be passed to the `format()` function. 272 | `labels` is a list of labels, in order, to pass to `format()` function. 273 | Label values will be normalized before being passed to `format()` so they will be 274 | identical to how they appear in `id`. 275 | Default is `{}` (`descriptors` output will be empty). 276 | EOT 277 | } 278 | 279 | #### End of copy of cloudposse/terraform-null-label/variables.tf 280 | -------------------------------------------------------------------------------- /examples/complete/context.tf: -------------------------------------------------------------------------------- 1 | # 2 | # ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label 3 | # All other instances of this file should be a copy of that one 4 | # 5 | # 6 | # Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf 7 | # and then place it in your Terraform module to automatically get 8 | # Cloud Posse's standard configuration inputs suitable for passing 9 | # to Cloud Posse modules. 10 | # 11 | # curl -sL https://raw.githubusercontent.com/cloudposse/terraform-null-label/master/exports/context.tf -o context.tf 12 | # 13 | # Modules should access the whole context as `module.this.context` 14 | # to get the input variables with nulls for defaults, 15 | # for example `context = module.this.context`, 16 | # and access individual variables as `module.this.`, 17 | # with final values filled in. 18 | # 19 | # For example, when using defaults, `module.this.context.delimiter` 20 | # will be null, and `module.this.delimiter` will be `-` (hyphen). 21 | # 22 | 23 | module "this" { 24 | source = "cloudposse/label/null" 25 | version = "0.25.0" # requires Terraform >= 0.13.0 26 | 27 | enabled = var.enabled 28 | namespace = var.namespace 29 | tenant = var.tenant 30 | environment = var.environment 31 | stage = var.stage 32 | name = var.name 33 | delimiter = var.delimiter 34 | attributes = var.attributes 35 | tags = var.tags 36 | additional_tag_map = var.additional_tag_map 37 | label_order = var.label_order 38 | regex_replace_chars = var.regex_replace_chars 39 | id_length_limit = var.id_length_limit 40 | label_key_case = var.label_key_case 41 | label_value_case = var.label_value_case 42 | descriptor_formats = var.descriptor_formats 43 | labels_as_tags = var.labels_as_tags 44 | 45 | context = var.context 46 | } 47 | 48 | # Copy contents of cloudposse/terraform-null-label/variables.tf here 49 | 50 | variable "context" { 51 | type = any 52 | default = { 53 | enabled = true 54 | namespace = null 55 | tenant = null 56 | environment = null 57 | stage = null 58 | name = null 59 | delimiter = null 60 | attributes = [] 61 | tags = {} 62 | additional_tag_map = {} 63 | regex_replace_chars = null 64 | label_order = [] 65 | id_length_limit = null 66 | label_key_case = null 67 | label_value_case = null 68 | descriptor_formats = {} 69 | # Note: we have to use [] instead of null for unset lists due to 70 | # https://github.com/hashicorp/terraform/issues/28137 71 | # which was not fixed until Terraform 1.0.0, 72 | # but we want the default to be all the labels in `label_order` 73 | # and we want users to be able to prevent all tag generation 74 | # by setting `labels_as_tags` to `[]`, so we need 75 | # a different sentinel to indicate "default" 76 | labels_as_tags = ["unset"] 77 | } 78 | description = <<-EOT 79 | Single object for setting entire context at once. 80 | See description of individual variables for details. 81 | Leave string and numeric variables as `null` to use default value. 82 | Individual variable settings (non-null) override settings in context object, 83 | except for attributes, tags, and additional_tag_map, which are merged. 84 | EOT 85 | 86 | validation { 87 | condition = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"]) 88 | error_message = "Allowed values: `lower`, `title`, `upper`." 89 | } 90 | 91 | validation { 92 | condition = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"]) 93 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`." 94 | } 95 | } 96 | 97 | variable "enabled" { 98 | type = bool 99 | default = null 100 | description = "Set to false to prevent the module from creating any resources" 101 | } 102 | 103 | variable "namespace" { 104 | type = string 105 | default = null 106 | description = "ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique" 107 | } 108 | 109 | variable "tenant" { 110 | type = string 111 | default = null 112 | description = "ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for" 113 | } 114 | 115 | variable "environment" { 116 | type = string 117 | default = null 118 | description = "ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'" 119 | } 120 | 121 | variable "stage" { 122 | type = string 123 | default = null 124 | description = "ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'" 125 | } 126 | 127 | variable "name" { 128 | type = string 129 | default = null 130 | description = <<-EOT 131 | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'. 132 | This is the only ID element not also included as a `tag`. 133 | The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. 134 | EOT 135 | } 136 | 137 | variable "delimiter" { 138 | type = string 139 | default = null 140 | description = <<-EOT 141 | Delimiter to be used between ID elements. 142 | Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. 143 | EOT 144 | } 145 | 146 | variable "attributes" { 147 | type = list(string) 148 | default = [] 149 | description = <<-EOT 150 | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`, 151 | in the order they appear in the list. New attributes are appended to the 152 | end of the list. The elements of the list are joined by the `delimiter` 153 | and treated as a single ID element. 154 | EOT 155 | } 156 | 157 | variable "labels_as_tags" { 158 | type = set(string) 159 | default = ["default"] 160 | description = <<-EOT 161 | Set of labels (ID elements) to include as tags in the `tags` output. 162 | Default is to include all labels. 163 | Tags with empty values will not be included in the `tags` output. 164 | Set to `[]` to suppress all generated tags. 165 | **Notes:** 166 | The value of the `name` tag, if included, will be the `id`, not the `name`. 167 | Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be 168 | changed in later chained modules. Attempts to change it will be silently ignored. 169 | EOT 170 | } 171 | 172 | variable "tags" { 173 | type = map(string) 174 | default = {} 175 | description = <<-EOT 176 | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`). 177 | Neither the tag keys nor the tag values will be modified by this module. 178 | EOT 179 | } 180 | 181 | variable "additional_tag_map" { 182 | type = map(string) 183 | default = {} 184 | description = <<-EOT 185 | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`. 186 | This is for some rare cases where resources want additional configuration of tags 187 | and therefore take a list of maps with tag key, value, and additional configuration. 188 | EOT 189 | } 190 | 191 | variable "label_order" { 192 | type = list(string) 193 | default = null 194 | description = <<-EOT 195 | The order in which the labels (ID elements) appear in the `id`. 196 | Defaults to ["namespace", "environment", "stage", "name", "attributes"]. 197 | You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. 198 | EOT 199 | } 200 | 201 | variable "regex_replace_chars" { 202 | type = string 203 | default = null 204 | description = <<-EOT 205 | Terraform regular expression (regex) string. 206 | Characters matching the regex will be removed from the ID elements. 207 | If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. 208 | EOT 209 | } 210 | 211 | variable "id_length_limit" { 212 | type = number 213 | default = null 214 | description = <<-EOT 215 | Limit `id` to this many characters (minimum 6). 216 | Set to `0` for unlimited length. 217 | Set to `null` for keep the existing setting, which defaults to `0`. 218 | Does not affect `id_full`. 219 | EOT 220 | validation { 221 | condition = var.id_length_limit == null ? true : var.id_length_limit >= 6 || var.id_length_limit == 0 222 | error_message = "The id_length_limit must be >= 6 if supplied (not null), or 0 for unlimited length." 223 | } 224 | } 225 | 226 | variable "label_key_case" { 227 | type = string 228 | default = null 229 | description = <<-EOT 230 | Controls the letter case of the `tags` keys (label names) for tags generated by this module. 231 | Does not affect keys of tags passed in via the `tags` input. 232 | Possible values: `lower`, `title`, `upper`. 233 | Default value: `title`. 234 | EOT 235 | 236 | validation { 237 | condition = var.label_key_case == null ? true : contains(["lower", "title", "upper"], var.label_key_case) 238 | error_message = "Allowed values: `lower`, `title`, `upper`." 239 | } 240 | } 241 | 242 | variable "label_value_case" { 243 | type = string 244 | default = null 245 | description = <<-EOT 246 | Controls the letter case of ID elements (labels) as included in `id`, 247 | set as tag values, and output by this module individually. 248 | Does not affect values of tags passed in via the `tags` input. 249 | Possible values: `lower`, `title`, `upper` and `none` (no transformation). 250 | Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs. 251 | Default value: `lower`. 252 | EOT 253 | 254 | validation { 255 | condition = var.label_value_case == null ? true : contains(["lower", "title", "upper", "none"], var.label_value_case) 256 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`." 257 | } 258 | } 259 | 260 | variable "descriptor_formats" { 261 | type = any 262 | default = {} 263 | description = <<-EOT 264 | Describe additional descriptors to be output in the `descriptors` output map. 265 | Map of maps. Keys are names of descriptors. Values are maps of the form 266 | `{ 267 | format = string 268 | labels = list(string) 269 | }` 270 | (Type is `any` so the map values can later be enhanced to provide additional options.) 271 | `format` is a Terraform format string to be passed to the `format()` function. 272 | `labels` is a list of labels, in order, to pass to `format()` function. 273 | Label values will be normalized before being passed to `format()` so they will be 274 | identical to how they appear in `id`. 275 | Default is `{}` (`descriptors` output will be empty). 276 | EOT 277 | } 278 | 279 | #### End of copy of cloudposse/terraform-null-label/variables.tf 280 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2018-2019 Cloud Posse, LLC 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | variable "cluster_name" { 2 | type = string 3 | description = "The name of the EKS cluster" 4 | } 5 | 6 | variable "cluster_endpoint" { 7 | type = string 8 | description = "EKS cluster endpoint" 9 | } 10 | 11 | variable "cluster_certificate_authority_data" { 12 | type = string 13 | description = "The base64 encoded certificate data required to communicate with the cluster" 14 | } 15 | 16 | variable "vpc_id" { 17 | type = string 18 | description = "VPC ID for the EKS cluster" 19 | } 20 | 21 | variable "security_group_enabled" { 22 | type = bool 23 | description = "Whether to create default Security Group for EKS worker nodes." 24 | default = true 25 | } 26 | 27 | variable "security_group_description" { 28 | type = string 29 | default = "Security Group for EKS worker nodes" 30 | description = "The Security Group description." 31 | } 32 | 33 | variable "security_group_use_name_prefix" { 34 | type = bool 35 | default = false 36 | description = "Whether to create a default Security Group with unique name beginning with the normalized prefix." 37 | } 38 | 39 | variable "security_group_rules" { 40 | type = list(any) 41 | default = [ 42 | { 43 | type = "egress" 44 | from_port = 0 45 | to_port = 65535 46 | protocol = "-1" 47 | cidr_blocks = ["0.0.0.0/0"] 48 | description = "Allow all outbound traffic" 49 | } 50 | ] 51 | description = <<-EOT 52 | A list of maps of Security Group rules. 53 | The values of map is fully complated with `aws_security_group_rule` resource. 54 | To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule . 55 | EOT 56 | } 57 | 58 | variable "security_groups" { 59 | type = list(string) 60 | default = [] 61 | description = "A list of Security Group IDs to associate with EKS worker nodes." 62 | } 63 | 64 | variable "metadata_http_endpoint_enabled" { 65 | type = bool 66 | default = true 67 | description = "Set false to disable the Instance Metadata Service." 68 | } 69 | 70 | variable "metadata_http_put_response_hop_limit" { 71 | type = number 72 | default = 2 73 | description = <<-EOT 74 | The desired HTTP PUT response hop limit (between 1 and 64) for Instance Metadata Service requests. 75 | The default is `2` to support containerized workloads. 76 | EOT 77 | } 78 | 79 | variable "metadata_http_tokens_required" { 80 | type = bool 81 | default = true 82 | description = "Set true to require IMDS session tokens, disabling Instance Metadata Service Version 1." 83 | } 84 | 85 | variable "instance_initiated_shutdown_behavior" { 86 | type = string 87 | description = "Shutdown behavior for the instances. Can be `stop` or `terminate`" 88 | default = "terminate" 89 | } 90 | 91 | variable "image_id" { 92 | type = string 93 | description = "EC2 image ID to launch. If not provided, the module will lookup the most recent EKS AMI. See https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html for more details on EKS-optimized images" 94 | default = "" 95 | } 96 | 97 | variable "use_custom_image_id" { 98 | type = bool 99 | description = "If set to `true`, will use variable `image_id` for the EKS workers inside autoscaling group" 100 | default = false 101 | } 102 | 103 | variable "eks_worker_ami_name_filter" { 104 | type = string 105 | description = "AMI name filter to lookup the most recent EKS AMI if `image_id` is not provided" 106 | default = "amazon-eks-node-*" 107 | } 108 | 109 | variable "eks_worker_ami_name_regex" { 110 | type = string 111 | description = "A regex string to apply to the AMI list returned by AWS" 112 | default = "^amazon-eks-node-[1-9,.]+-v[0-9]{8}$" 113 | } 114 | 115 | variable "instance_type" { 116 | type = string 117 | description = "Instance type to launch" 118 | } 119 | 120 | variable "key_name" { 121 | type = string 122 | description = "SSH key name that should be used for the instance" 123 | default = "" 124 | } 125 | 126 | variable "associate_public_ip_address" { 127 | type = bool 128 | description = "Associate a public IP address with an instance in a VPC" 129 | default = false 130 | } 131 | 132 | variable "enable_monitoring" { 133 | type = bool 134 | description = "Enable/disable detailed monitoring" 135 | default = true 136 | } 137 | 138 | variable "ebs_optimized" { 139 | type = bool 140 | description = "If true, the launched EC2 instance will be EBS-optimized" 141 | default = false 142 | } 143 | 144 | variable "disable_api_termination" { 145 | type = bool 146 | description = "If `true`, enables EC2 Instance Termination Protection" 147 | default = false 148 | } 149 | 150 | variable "max_size" { 151 | type = number 152 | description = "The maximum size of the autoscale group" 153 | } 154 | 155 | variable "min_size" { 156 | type = number 157 | description = "The minimum size of the autoscale group" 158 | } 159 | 160 | variable "subnet_ids" { 161 | description = "A list of subnet IDs to launch resources in" 162 | type = list(string) 163 | } 164 | 165 | variable "default_cooldown" { 166 | type = number 167 | description = "The amount of time, in seconds, after a scaling activity completes before another scaling activity can start" 168 | default = 300 169 | } 170 | 171 | variable "health_check_grace_period" { 172 | type = number 173 | description = "Time (in seconds) after instance comes into service before checking health" 174 | default = 300 175 | } 176 | 177 | variable "health_check_type" { 178 | type = string 179 | description = "Controls how health checking is done. Valid values are `EC2` or `ELB`" 180 | default = "EC2" 181 | } 182 | 183 | variable "force_delete" { 184 | type = bool 185 | description = "Allows deleting the autoscaling group without waiting for all instances in the pool to terminate. You can force an autoscaling 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" 186 | default = false 187 | } 188 | 189 | variable "load_balancers" { 190 | type = list(string) 191 | description = "A list of elastic load balancer names to add to the autoscaling group. Only valid for classic load balancers. For ALBs, use `target_group_arns` instead" 192 | default = [] 193 | } 194 | 195 | variable "target_group_arns" { 196 | type = list(string) 197 | description = "A list of aws_alb_target_group ARNs, for use with Application Load Balancing" 198 | default = [] 199 | } 200 | 201 | variable "termination_policies" { 202 | description = "A list of policies to decide how the instances in the auto scale group should be terminated. The allowed values are `OldestInstance`, `NewestInstance`, `OldestLaunchConfiguration`, `ClosestToNextInstanceHour`, `Default`" 203 | type = list(string) 204 | default = ["Default"] 205 | } 206 | 207 | variable "suspended_processes" { 208 | type = list(string) 209 | description = "A list of processes to suspend for the AutoScaling 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 autoscaling group from functioning properly." 210 | default = [] 211 | } 212 | 213 | variable "placement_group" { 214 | type = string 215 | description = "The name of the placement group into which you'll launch your instances, if any" 216 | default = "" 217 | } 218 | 219 | variable "metrics_granularity" { 220 | type = string 221 | description = "The granularity to associate with the metrics to collect. The only valid value is 1Minute" 222 | default = "1Minute" 223 | } 224 | 225 | variable "enabled_metrics" { 226 | description = "A list of metrics to collect. The allowed values are `GroupMinSize`, `GroupMaxSize`, `GroupDesiredCapacity`, `GroupInServiceInstances`, `GroupPendingInstances`, `GroupStandbyInstances`, `GroupTerminatingInstances`, `GroupTotalInstances`" 227 | type = list(string) 228 | 229 | default = [ 230 | "GroupMinSize", 231 | "GroupMaxSize", 232 | "GroupDesiredCapacity", 233 | "GroupInServiceInstances", 234 | "GroupPendingInstances", 235 | "GroupStandbyInstances", 236 | "GroupTerminatingInstances", 237 | "GroupTotalInstances", 238 | ] 239 | } 240 | 241 | variable "wait_for_capacity_timeout" { 242 | type = string 243 | description = "A maximum duration that Terraform should wait for ASG instances to be healthy before timing out. Setting this to '0' causes Terraform to skip all Capacity Waiting behavior" 244 | default = "10m" 245 | } 246 | 247 | variable "min_elb_capacity" { 248 | type = number 249 | 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" 250 | default = 0 251 | } 252 | 253 | variable "wait_for_elb_capacity" { 254 | type = number 255 | 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" 256 | default = 0 257 | } 258 | 259 | variable "protect_from_scale_in" { 260 | type = bool 261 | description = "Allows setting instance protection. The autoscaling group will not select instances with this setting for terminination during scale in events" 262 | default = false 263 | } 264 | 265 | variable "service_linked_role_arn" { 266 | type = string 267 | description = "The ARN of the service-linked role that the ASG will use to call other AWS services" 268 | default = "" 269 | } 270 | 271 | variable "autoscaling_group_tags" { 272 | type = map(string) 273 | default = {} 274 | description = "Additional tags only for the autoscaling group, e.g. \"k8s.io/cluster-autoscaler/node-template/taint/dedicated\" = \"ci-cd:NoSchedule\"." 275 | } 276 | 277 | variable "autoscaling_policies_enabled" { 278 | type = bool 279 | default = true 280 | description = "Whether to create `aws_autoscaling_policy` and `aws_cloudwatch_metric_alarm` resources to control Auto Scaling" 281 | } 282 | 283 | variable "scale_up_cooldown_seconds" { 284 | type = number 285 | default = 300 286 | description = "The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start" 287 | } 288 | 289 | variable "scale_up_scaling_adjustment" { 290 | type = number 291 | default = 1 292 | description = "The number of instances by which to scale. `scale_up_adjustment_type` determines the interpretation of this number (e.g. as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity" 293 | } 294 | 295 | variable "scale_up_adjustment_type" { 296 | type = string 297 | default = "ChangeInCapacity" 298 | description = "Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity` and `PercentChangeInCapacity`" 299 | } 300 | 301 | variable "scale_up_policy_type" { 302 | type = string 303 | default = "SimpleScaling" 304 | description = "The scalling policy type, either `SimpleScaling`, `StepScaling` or `TargetTrackingScaling`" 305 | } 306 | 307 | variable "scale_down_cooldown_seconds" { 308 | type = number 309 | default = 300 310 | description = "The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start" 311 | } 312 | 313 | variable "scale_down_scaling_adjustment" { 314 | type = number 315 | default = -1 316 | description = "The number of instances by which to scale. `scale_down_scaling_adjustment` determines the interpretation of this number (e.g. as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity" 317 | } 318 | 319 | variable "scale_down_adjustment_type" { 320 | type = string 321 | default = "ChangeInCapacity" 322 | description = "Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity` and `PercentChangeInCapacity`" 323 | } 324 | 325 | variable "scale_down_policy_type" { 326 | type = string 327 | default = "SimpleScaling" 328 | description = "The scalling policy type, either `SimpleScaling`, `StepScaling` or `TargetTrackingScaling`" 329 | } 330 | 331 | variable "cpu_utilization_high_evaluation_periods" { 332 | type = number 333 | default = 2 334 | description = "The number of periods over which data is compared to the specified threshold" 335 | } 336 | 337 | variable "cpu_utilization_high_period_seconds" { 338 | type = number 339 | default = 300 340 | description = "The period in seconds over which the specified statistic is applied" 341 | } 342 | 343 | variable "cpu_utilization_high_threshold_percent" { 344 | type = number 345 | default = 90 346 | description = "The value against which the specified statistic is compared" 347 | } 348 | 349 | variable "cpu_utilization_high_statistic" { 350 | type = string 351 | default = "Average" 352 | description = "The statistic to apply to the alarm's associated metric. Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum`" 353 | } 354 | 355 | variable "cpu_utilization_low_evaluation_periods" { 356 | type = number 357 | default = 2 358 | description = "The number of periods over which data is compared to the specified threshold" 359 | } 360 | 361 | variable "cpu_utilization_low_period_seconds" { 362 | type = number 363 | default = 300 364 | description = "The period in seconds over which the specified statistic is applied" 365 | } 366 | 367 | variable "cpu_utilization_low_threshold_percent" { 368 | type = number 369 | default = 10 370 | description = "The value against which the specified statistic is compared" 371 | } 372 | 373 | variable "cpu_utilization_low_statistic" { 374 | type = string 375 | default = "Average" 376 | description = "The statistic to apply to the alarm's associated metric. Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum`" 377 | } 378 | 379 | variable "bootstrap_extra_args" { 380 | type = string 381 | default = "" 382 | description = "Extra arguments to the `bootstrap.sh` script to enable `--enable-docker-bridge` or `--use-max-pods`" 383 | } 384 | 385 | variable "kubelet_extra_args" { 386 | type = string 387 | default = "" 388 | description = "Extra arguments to pass to kubelet, like \"--register-with-taints=dedicated=ci-cd:NoSchedule --node-labels=purpose=ci-worker\"" 389 | } 390 | 391 | 392 | variable "before_cluster_joining_userdata" { 393 | type = string 394 | default = "" 395 | description = "Additional commands to execute on each worker node before joining the EKS cluster (before executing the `bootstrap.sh` script). For mot info, see https://kubedex.com/90-days-of-aws-eks-in-production" 396 | } 397 | 398 | variable "after_cluster_joining_userdata" { 399 | type = string 400 | default = "" 401 | description = "Additional commands to execute on each worker node after joining the EKS cluster (after executing the `bootstrap.sh` script). For mot info, see https://kubedex.com/90-days-of-aws-eks-in-production" 402 | } 403 | 404 | variable "aws_iam_instance_profile_name" { 405 | type = string 406 | default = "" 407 | description = "The name of the existing instance profile that will be used in autoscaling group for EKS workers. If empty will create a new instance profile." 408 | } 409 | 410 | variable "use_existing_aws_iam_instance_profile" { 411 | type = bool 412 | description = "If set to `true`, will use variable `aws_iam_instance_profile_name` to run EKS workers using an existing AWS instance profile that was created outside of this module, workaround for error like `count cannot be computed`" 413 | default = false 414 | } 415 | 416 | variable "permissions_boundary" { 417 | type = string 418 | description = "Provide an existing permissions boundary to attach to the default role" 419 | default = null 420 | } 421 | 422 | variable "workers_role_policy_arns" { 423 | type = list(string) 424 | default = [] 425 | description = "List of policy ARNs that will be attached to the workers default role on creation" 426 | } 427 | 428 | variable "workers_role_policy_arns_count" { 429 | type = number 430 | default = 0 431 | description = "Count of policy ARNs that will be attached to the workers default role on creation. Needed to prevent Terraform error `count can't be computed`" 432 | } 433 | 434 | variable "block_device_mappings" { 435 | description = "Specify volumes to attach to the instance besides the volumes specified by the AMI" 436 | 437 | type = list(object({ 438 | device_name = string 439 | no_device = bool 440 | virtual_name = string 441 | ebs = object({ 442 | delete_on_termination = bool 443 | encrypted = bool 444 | iops = number 445 | kms_key_id = string 446 | snapshot_id = string 447 | volume_size = number 448 | volume_type = string 449 | }) 450 | })) 451 | 452 | default = [] 453 | } 454 | 455 | variable "instance_market_options" { 456 | description = "The market (purchasing) option for the instances" 457 | 458 | type = object({ 459 | market_type = string 460 | spot_options = object({ 461 | block_duration_minutes = number 462 | instance_interruption_behavior = string 463 | max_price = number 464 | spot_instance_type = string 465 | valid_until = string 466 | }) 467 | }) 468 | 469 | default = null 470 | } 471 | 472 | variable "mixed_instances_policy" { 473 | description = "policy to used mixed group of on demand/spot of differing types. Launch template is automatically generated. https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html#mixed_instances_policy-1" 474 | 475 | type = object({ 476 | instances_distribution = object({ 477 | on_demand_allocation_strategy = string 478 | on_demand_base_capacity = number 479 | on_demand_percentage_above_base_capacity = number 480 | spot_allocation_strategy = string 481 | spot_instance_pools = number 482 | spot_max_price = string 483 | }) 484 | override = list(object({ 485 | instance_type = string 486 | weighted_capacity = number 487 | })) 488 | }) 489 | default = null 490 | } 491 | 492 | variable "placement" { 493 | description = "The placement specifications of the instances" 494 | 495 | type = object({ 496 | affinity = string 497 | availability_zone = string 498 | group_name = string 499 | host_id = string 500 | tenancy = string 501 | }) 502 | 503 | default = null 504 | } 505 | 506 | variable "credit_specification" { 507 | description = "Customize the credit specification of the instances" 508 | 509 | type = object({ 510 | cpu_credits = string 511 | }) 512 | 513 | default = null 514 | } 515 | 516 | variable "elastic_gpu_specifications" { 517 | description = "Specifications of Elastic GPU to attach to the instances" 518 | 519 | type = object({ 520 | type = string 521 | }) 522 | 523 | default = null 524 | } 525 | -------------------------------------------------------------------------------- /docs/terraform.md: -------------------------------------------------------------------------------- 1 | 2 | ## Requirements 3 | 4 | | Name | Version | 5 | |------|---------| 6 | | [terraform](#requirement\_terraform) | >= 0.13 | 7 | | [aws](#requirement\_aws) | >= 2.0 | 8 | | [template](#requirement\_template) | >= 2.0 | 9 | 10 | ## Providers 11 | 12 | | Name | Version | 13 | |------|---------| 14 | | [aws](#provider\_aws) | >= 2.0 | 15 | | [template](#provider\_template) | >= 2.0 | 16 | 17 | ## Modules 18 | 19 | | Name | Source | Version | 20 | |------|--------|---------| 21 | | [autoscale\_group](#module\_autoscale\_group) | cloudposse/ec2-autoscale-group/aws | 0.27.0 | 22 | | [label](#module\_label) | cloudposse/label/null | 0.25.0 | 23 | | [security\_group](#module\_security\_group) | cloudposse/security-group/aws | 0.3.3 | 24 | | [this](#module\_this) | cloudposse/label/null | 0.25.0 | 25 | 26 | ## Resources 27 | 28 | | Name | Type | 29 | |------|------| 30 | | [aws_iam_instance_profile.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource | 31 | | [aws_iam_role.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | 32 | | [aws_iam_role_policy_attachment.amazon_ec2_container_registry_read_only](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 33 | | [aws_iam_role_policy_attachment.amazon_eks_cni_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 34 | | [aws_iam_role_policy_attachment.amazon_eks_worker_node_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 35 | | [aws_iam_role_policy_attachment.existing_policies_attach_to_eks_workers_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 36 | | [aws_ami.eks_worker](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | 37 | | [aws_iam_instance_profile.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_instance_profile) | data source | 38 | | [aws_iam_policy_document.assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 39 | | [template_file.userdata](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source | 40 | 41 | ## Inputs 42 | 43 | | Name | Description | Type | Default | Required | 44 | |------|-------------|------|---------|:--------:| 45 | | [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no | 46 | | [after\_cluster\_joining\_userdata](#input\_after\_cluster\_joining\_userdata) | Additional commands to execute on each worker node after joining the EKS cluster (after executing the `bootstrap.sh` script). For mot info, see https://kubedex.com/90-days-of-aws-eks-in-production | `string` | `""` | no | 47 | | [associate\_public\_ip\_address](#input\_associate\_public\_ip\_address) | Associate a public IP address with an instance in a VPC | `bool` | `false` | no | 48 | | [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the `delimiter`
and treated as a single ID element. | `list(string)` | `[]` | no | 49 | | [autoscaling\_group\_tags](#input\_autoscaling\_group\_tags) | Additional tags only for the autoscaling group, e.g. "k8s.io/cluster-autoscaler/node-template/taint/dedicated" = "ci-cd:NoSchedule". | `map(string)` | `{}` | no | 50 | | [autoscaling\_policies\_enabled](#input\_autoscaling\_policies\_enabled) | Whether to create `aws_autoscaling_policy` and `aws_cloudwatch_metric_alarm` resources to control Auto Scaling | `bool` | `true` | no | 51 | | [aws\_iam\_instance\_profile\_name](#input\_aws\_iam\_instance\_profile\_name) | The name of the existing instance profile that will be used in autoscaling group for EKS workers. If empty will create a new instance profile. | `string` | `""` | no | 52 | | [before\_cluster\_joining\_userdata](#input\_before\_cluster\_joining\_userdata) | Additional commands to execute on each worker node before joining the EKS cluster (before executing the `bootstrap.sh` script). For mot info, see https://kubedex.com/90-days-of-aws-eks-in-production | `string` | `""` | no | 53 | | [block\_device\_mappings](#input\_block\_device\_mappings) | Specify volumes to attach to the instance besides the volumes specified by the AMI |
list(object({
device_name = string
no_device = bool
virtual_name = string
ebs = object({
delete_on_termination = bool
encrypted = bool
iops = number
kms_key_id = string
snapshot_id = string
volume_size = number
volume_type = string
})
}))
| `[]` | no | 54 | | [bootstrap\_extra\_args](#input\_bootstrap\_extra\_args) | Extra arguments to the `bootstrap.sh` script to enable `--enable-docker-bridge` or `--use-max-pods` | `string` | `""` | no | 55 | | [cluster\_certificate\_authority\_data](#input\_cluster\_certificate\_authority\_data) | The base64 encoded certificate data required to communicate with the cluster | `string` | n/a | yes | 56 | | [cluster\_endpoint](#input\_cluster\_endpoint) | EKS cluster endpoint | `string` | n/a | yes | 57 | | [cluster\_name](#input\_cluster\_name) | The name of the EKS cluster | `string` | n/a | yes | 58 | | [context](#input\_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,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
| no | 59 | | [cpu\_utilization\_high\_evaluation\_periods](#input\_cpu\_utilization\_high\_evaluation\_periods) | The number of periods over which data is compared to the specified threshold | `number` | `2` | no | 60 | | [cpu\_utilization\_high\_period\_seconds](#input\_cpu\_utilization\_high\_period\_seconds) | The period in seconds over which the specified statistic is applied | `number` | `300` | no | 61 | | [cpu\_utilization\_high\_statistic](#input\_cpu\_utilization\_high\_statistic) | The statistic to apply to the alarm's associated metric. Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum` | `string` | `"Average"` | no | 62 | | [cpu\_utilization\_high\_threshold\_percent](#input\_cpu\_utilization\_high\_threshold\_percent) | The value against which the specified statistic is compared | `number` | `90` | no | 63 | | [cpu\_utilization\_low\_evaluation\_periods](#input\_cpu\_utilization\_low\_evaluation\_periods) | The number of periods over which data is compared to the specified threshold | `number` | `2` | no | 64 | | [cpu\_utilization\_low\_period\_seconds](#input\_cpu\_utilization\_low\_period\_seconds) | The period in seconds over which the specified statistic is applied | `number` | `300` | no | 65 | | [cpu\_utilization\_low\_statistic](#input\_cpu\_utilization\_low\_statistic) | The statistic to apply to the alarm's associated metric. Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum` | `string` | `"Average"` | no | 66 | | [cpu\_utilization\_low\_threshold\_percent](#input\_cpu\_utilization\_low\_threshold\_percent) | The value against which the specified statistic is compared | `number` | `10` | no | 67 | | [credit\_specification](#input\_credit\_specification) | Customize the credit specification of the instances |
object({
cpu_credits = string
})
| `null` | no | 68 | | [default\_cooldown](#input\_default\_cooldown) | The amount of time, in seconds, after a scaling activity completes before another scaling activity can start | `number` | `300` | no | 69 | | [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | 70 | | [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
`labels` is a list of labels, in order, to pass to `format()` function.
Label values will be normalized before being passed to `format()` so they will be
identical to how they appear in `id`.
Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no | 71 | | [disable\_api\_termination](#input\_disable\_api\_termination) | If `true`, enables EC2 Instance Termination Protection | `bool` | `false` | no | 72 | | [ebs\_optimized](#input\_ebs\_optimized) | If true, the launched EC2 instance will be EBS-optimized | `bool` | `false` | no | 73 | | [eks\_worker\_ami\_name\_filter](#input\_eks\_worker\_ami\_name\_filter) | AMI name filter to lookup the most recent EKS AMI if `image_id` is not provided | `string` | `"amazon-eks-node-*"` | no | 74 | | [eks\_worker\_ami\_name\_regex](#input\_eks\_worker\_ami\_name\_regex) | A regex string to apply to the AMI list returned by AWS | `string` | `"^amazon-eks-node-[1-9,.]+-v[0-9]{8}$"` | no | 75 | | [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | Specifications of Elastic GPU to attach to the instances |
object({
type = string
})
| `null` | no | 76 | | [enable\_monitoring](#input\_enable\_monitoring) | Enable/disable detailed monitoring | `bool` | `true` | no | 77 | | [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | 78 | | [enabled\_metrics](#input\_enabled\_metrics) | A list of metrics to collect. The allowed values are `GroupMinSize`, `GroupMaxSize`, `GroupDesiredCapacity`, `GroupInServiceInstances`, `GroupPendingInstances`, `GroupStandbyInstances`, `GroupTerminatingInstances`, `GroupTotalInstances` | `list(string)` |
[
"GroupMinSize",
"GroupMaxSize",
"GroupDesiredCapacity",
"GroupInServiceInstances",
"GroupPendingInstances",
"GroupStandbyInstances",
"GroupTerminatingInstances",
"GroupTotalInstances"
]
| no | 79 | | [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | 80 | | [force\_delete](#input\_force\_delete) | Allows deleting the autoscaling group without waiting for all instances in the pool to terminate. You can force an autoscaling 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` | `false` | no | 81 | | [health\_check\_grace\_period](#input\_health\_check\_grace\_period) | Time (in seconds) after instance comes into service before checking health | `number` | `300` | no | 82 | | [health\_check\_type](#input\_health\_check\_type) | Controls how health checking is done. Valid values are `EC2` or `ELB` | `string` | `"EC2"` | no | 83 | | [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for keep the existing setting, which defaults to `0`.
Does not affect `id_full`. | `number` | `null` | no | 84 | | [image\_id](#input\_image\_id) | EC2 image ID to launch. If not provided, the module will lookup the most recent EKS AMI. See https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html for more details on EKS-optimized images | `string` | `""` | no | 85 | | [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Shutdown behavior for the instances. Can be `stop` or `terminate` | `string` | `"terminate"` | no | 86 | | [instance\_market\_options](#input\_instance\_market\_options) | The market (purchasing) option for the instances |
object({
market_type = string
spot_options = object({
block_duration_minutes = number
instance_interruption_behavior = string
max_price = number
spot_instance_type = string
valid_until = string
})
})
| `null` | no | 87 | | [instance\_type](#input\_instance\_type) | Instance type to launch | `string` | n/a | yes | 88 | | [key\_name](#input\_key\_name) | SSH key name that should be used for the instance | `string` | `""` | no | 89 | | [kubelet\_extra\_args](#input\_kubelet\_extra\_args) | Extra arguments to pass to kubelet, like "--register-with-taints=dedicated=ci-cd:NoSchedule --node-labels=purpose=ci-worker" | `string` | `""` | no | 90 | | [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no | 91 | | [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no | 92 | | [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.
Default value: `lower`. | `string` | `null` | no | 93 | | [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.
Default is to include all labels.
Tags with empty values will not be included in the `tags` output.
Set to `[]` to suppress all generated tags.
**Notes:**
The value of the `name` tag, if included, will be the `id`, not the `name`.
Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be
changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` |
[
"default"
]
| no | 94 | | [load\_balancers](#input\_load\_balancers) | A list of elastic load balancer names to add to the autoscaling group. Only valid for classic load balancers. For ALBs, use `target_group_arns` instead | `list(string)` | `[]` | no | 95 | | [max\_size](#input\_max\_size) | The maximum size of the autoscale group | `number` | n/a | yes | 96 | | [metadata\_http\_endpoint\_enabled](#input\_metadata\_http\_endpoint\_enabled) | Set false to disable the Instance Metadata Service. | `bool` | `true` | no | 97 | | [metadata\_http\_put\_response\_hop\_limit](#input\_metadata\_http\_put\_response\_hop\_limit) | The desired HTTP PUT response hop limit (between 1 and 64) for Instance Metadata Service requests.
The default is `2` to support containerized workloads. | `number` | `2` | no | 98 | | [metadata\_http\_tokens\_required](#input\_metadata\_http\_tokens\_required) | Set true to require IMDS session tokens, disabling Instance Metadata Service Version 1. | `bool` | `true` | no | 99 | | [metrics\_granularity](#input\_metrics\_granularity) | The granularity to associate with the metrics to collect. The only valid value is 1Minute | `string` | `"1Minute"` | no | 100 | | [min\_elb\_capacity](#input\_min\_elb\_capacity) | 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 | `number` | `0` | no | 101 | | [min\_size](#input\_min\_size) | The minimum size of the autoscale group | `number` | n/a | yes | 102 | | [mixed\_instances\_policy](#input\_mixed\_instances\_policy) | policy to used mixed group of on demand/spot of differing types. Launch template is automatically generated. https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html#mixed_instances_policy-1 |
object({
instances_distribution = object({
on_demand_allocation_strategy = string
on_demand_base_capacity = number
on_demand_percentage_above_base_capacity = number
spot_allocation_strategy = string
spot_instance_pools = number
spot_max_price = string
})
override = list(object({
instance_type = string
weighted_capacity = number
}))
})
| `null` | no | 103 | | [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a `tag`.
The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no | 104 | | [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no | 105 | | [permissions\_boundary](#input\_permissions\_boundary) | Provide an existing permissions boundary to attach to the default role | `string` | `null` | no | 106 | | [placement](#input\_placement) | The placement specifications of the instances |
object({
affinity = string
availability_zone = string
group_name = string
host_id = string
tenancy = string
})
| `null` | no | 107 | | [placement\_group](#input\_placement\_group) | The name of the placement group into which you'll launch your instances, if any | `string` | `""` | no | 108 | | [protect\_from\_scale\_in](#input\_protect\_from\_scale\_in) | Allows setting instance protection. The autoscaling group will not select instances with this setting for terminination during scale in events | `bool` | `false` | no | 109 | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | 110 | | [scale\_down\_adjustment\_type](#input\_scale\_down\_adjustment\_type) | Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity` and `PercentChangeInCapacity` | `string` | `"ChangeInCapacity"` | no | 111 | | [scale\_down\_cooldown\_seconds](#input\_scale\_down\_cooldown\_seconds) | The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start | `number` | `300` | no | 112 | | [scale\_down\_policy\_type](#input\_scale\_down\_policy\_type) | The scalling policy type, either `SimpleScaling`, `StepScaling` or `TargetTrackingScaling` | `string` | `"SimpleScaling"` | no | 113 | | [scale\_down\_scaling\_adjustment](#input\_scale\_down\_scaling\_adjustment) | The number of instances by which to scale. `scale_down_scaling_adjustment` determines the interpretation of this number (e.g. as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity | `number` | `-1` | no | 114 | | [scale\_up\_adjustment\_type](#input\_scale\_up\_adjustment\_type) | Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity` and `PercentChangeInCapacity` | `string` | `"ChangeInCapacity"` | no | 115 | | [scale\_up\_cooldown\_seconds](#input\_scale\_up\_cooldown\_seconds) | The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start | `number` | `300` | no | 116 | | [scale\_up\_policy\_type](#input\_scale\_up\_policy\_type) | The scalling policy type, either `SimpleScaling`, `StepScaling` or `TargetTrackingScaling` | `string` | `"SimpleScaling"` | no | 117 | | [scale\_up\_scaling\_adjustment](#input\_scale\_up\_scaling\_adjustment) | The number of instances by which to scale. `scale_up_adjustment_type` determines the interpretation of this number (e.g. as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity | `number` | `1` | no | 118 | | [security\_group\_description](#input\_security\_group\_description) | The Security Group description. | `string` | `"Security Group for EKS worker nodes"` | no | 119 | | [security\_group\_enabled](#input\_security\_group\_enabled) | Whether to create default Security Group for EKS worker nodes. | `bool` | `true` | no | 120 | | [security\_group\_rules](#input\_security\_group\_rules) | A list of maps of Security Group rules.
The values of map is fully complated with `aws_security_group_rule` resource.
To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule . | `list(any)` |
[
{
"cidr_blocks": [
"0.0.0.0/0"
],
"description": "Allow all outbound traffic",
"from_port": 0,
"protocol": "-1",
"to_port": 65535,
"type": "egress"
}
]
| no | 121 | | [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Whether to create a default Security Group with unique name beginning with the normalized prefix. | `bool` | `false` | no | 122 | | [security\_groups](#input\_security\_groups) | A list of Security Group IDs to associate with EKS worker nodes. | `list(string)` | `[]` | no | 123 | | [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` | `""` | no | 124 | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | 125 | | [subnet\_ids](#input\_subnet\_ids) | A list of subnet IDs to launch resources in | `list(string)` | n/a | yes | 126 | | [suspended\_processes](#input\_suspended\_processes) | A list of processes to suspend for the AutoScaling 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 autoscaling group from functioning properly. | `list(string)` | `[]` | no | 127 | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | 128 | | [target\_group\_arns](#input\_target\_group\_arns) | A list of aws\_alb\_target\_group ARNs, for use with Application Load Balancing | `list(string)` | `[]` | no | 129 | | [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no | 130 | | [termination\_policies](#input\_termination\_policies) | A list of policies to decide how the instances in the auto scale group should be terminated. The allowed values are `OldestInstance`, `NewestInstance`, `OldestLaunchConfiguration`, `ClosestToNextInstanceHour`, `Default` | `list(string)` |
[
"Default"
]
| no | 131 | | [use\_custom\_image\_id](#input\_use\_custom\_image\_id) | If set to `true`, will use variable `image_id` for the EKS workers inside autoscaling group | `bool` | `false` | no | 132 | | [use\_existing\_aws\_iam\_instance\_profile](#input\_use\_existing\_aws\_iam\_instance\_profile) | If set to `true`, will use variable `aws_iam_instance_profile_name` to run EKS workers using an existing AWS instance profile that was created outside of this module, workaround for error like `count cannot be computed` | `bool` | `false` | no | 133 | | [vpc\_id](#input\_vpc\_id) | VPC ID for the EKS cluster | `string` | n/a | yes | 134 | | [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. Setting this to '0' causes Terraform to skip all Capacity Waiting behavior | `string` | `"10m"` | no | 135 | | [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` | `0` | no | 136 | | [workers\_role\_policy\_arns](#input\_workers\_role\_policy\_arns) | List of policy ARNs that will be attached to the workers default role on creation | `list(string)` | `[]` | no | 137 | | [workers\_role\_policy\_arns\_count](#input\_workers\_role\_policy\_arns\_count) | Count of policy ARNs that will be attached to the workers default role on creation. Needed to prevent Terraform error `count can't be computed` | `number` | `0` | no | 138 | 139 | ## Outputs 140 | 141 | | Name | Description | 142 | |------|-------------| 143 | | [autoscaling\_group\_arn](#output\_autoscaling\_group\_arn) | ARN of the AutoScaling Group | 144 | | [autoscaling\_group\_default\_cooldown](#output\_autoscaling\_group\_default\_cooldown) | Time between a scaling activity and the succeeding scaling activity | 145 | | [autoscaling\_group\_desired\_capacity](#output\_autoscaling\_group\_desired\_capacity) | The number of Amazon EC2 instances that should be running in the group | 146 | | [autoscaling\_group\_health\_check\_grace\_period](#output\_autoscaling\_group\_health\_check\_grace\_period) | Time after instance comes into service before checking health | 147 | | [autoscaling\_group\_health\_check\_type](#output\_autoscaling\_group\_health\_check\_type) | `EC2` or `ELB`. Controls how health checking is done | 148 | | [autoscaling\_group\_id](#output\_autoscaling\_group\_id) | The AutoScaling Group ID | 149 | | [autoscaling\_group\_max\_size](#output\_autoscaling\_group\_max\_size) | The maximum size of the AutoScaling Group | 150 | | [autoscaling\_group\_min\_size](#output\_autoscaling\_group\_min\_size) | The minimum size of the AutoScaling Group | 151 | | [autoscaling\_group\_name](#output\_autoscaling\_group\_name) | The AutoScaling Group name | 152 | | [autoscaling\_group\_tags](#output\_autoscaling\_group\_tags) | A list of tag settings associated with the AutoScaling Group | 153 | | [launch\_template\_arn](#output\_launch\_template\_arn) | ARN of the launch template | 154 | | [launch\_template\_id](#output\_launch\_template\_id) | The ID of the launch template | 155 | | [security\_group\_arn](#output\_security\_group\_arn) | ARN of the worker nodes Security Group | 156 | | [security\_group\_id](#output\_security\_group\_id) | ID of the worker nodes Security Group | 157 | | [security\_group\_name](#output\_security\_group\_name) | Name of the worker nodes Security Group | 158 | | [workers\_role\_arn](#output\_workers\_role\_arn) | ARN of the worker nodes IAM role | 159 | | [workers\_role\_name](#output\_workers\_role\_name) | Name of the worker nodes IAM role | 160 | 161 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # terraform-aws-eks-workers [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-eks-workers.svg)](https://github.com/cloudposse/terraform-aws-eks-workers/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) 4 | 5 | 6 | [![README Header][readme_header_img]][readme_header_link] 7 | 8 | [![Cloud Posse][logo]](https://cpco.io/homepage) 9 | 10 | 30 | 31 | Terraform module to provision AWS resources to run EC2 worker nodes for [Elastic Container Service for Kubernetes](https://aws.amazon.com/eks/). 32 | 33 | Instantiate it multiple times to create many EKS worker node pools with specific settings such as GPUs, EC2 instance types, or autoscale parameters. 34 | 35 | --- 36 | 37 | This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps. 38 | [][share_email] 39 | [][share_googleplus] 40 | [][share_facebook] 41 | [][share_reddit] 42 | [][share_linkedin] 43 | [][share_twitter] 44 | 45 | 46 | [![Terraform Open Source Modules](https://docs.cloudposse.com/images/terraform-open-source-modules.svg)][terraform_modules] 47 | 48 | 49 | 50 | It's 100% Open Source and licensed under the [APACHE2](LICENSE). 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | We literally have [*hundreds of terraform modules*][terraform_modules] that are Open Source and well-maintained. Check them out! 59 | 60 | 61 | 62 | 63 | 64 | ## Introduction 65 | 66 | The module provisions the following resources: 67 | 68 | - IAM Role and Instance Profile to allow Kubernetes nodes to access other AWS services 69 | - Security Group with rules for EKS workers to allow networking traffic 70 | - AutoScaling Group with Launch Template to configure and launch worker instances 71 | - AutoScaling Policies and CloudWatch Metric Alarms to monitor CPU utilization on the EC2 instances and scale the number of instance in the AutoScaling Group up or down. 72 | If you don't want to use the provided functionality, or want to provide your own policies, disable it by setting the variable `autoscaling_policies_enabled` to `"false"`. 73 | 74 | 75 | ## Security & Compliance [](https://bridgecrew.io/) 76 | 77 | Security scanning is graciously provided by Bridgecrew. Bridgecrew is the leading fully hosted, cloud-native solution providing continuous Terraform security and compliance. 78 | 79 | | Benchmark | Description | 80 | |--------|---------------| 81 | | [![Infrastructure Security](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-eks-workers/general)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-eks-workers&benchmark=INFRASTRUCTURE+SECURITY) | Infrastructure Security Compliance | 82 | | [![CIS KUBERNETES](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-eks-workers/cis_kubernetes)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-eks-workers&benchmark=CIS+KUBERNETES+V1.5) | Center for Internet Security, KUBERNETES Compliance | 83 | | [![CIS AWS](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-eks-workers/cis_aws)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-eks-workers&benchmark=CIS+AWS+V1.2) | Center for Internet Security, AWS Compliance | 84 | | [![CIS AZURE](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-eks-workers/cis_azure)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-eks-workers&benchmark=CIS+AZURE+V1.1) | Center for Internet Security, AZURE Compliance | 85 | | [![PCI-DSS](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-eks-workers/pci)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-eks-workers&benchmark=PCI-DSS+V3.2) | Payment Card Industry Data Security Standards Compliance | 86 | | [![NIST-800-53](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-eks-workers/nist)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-eks-workers&benchmark=NIST-800-53) | National Institute of Standards and Technology Compliance | 87 | | [![ISO27001](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-eks-workers/iso)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-eks-workers&benchmark=ISO27001) | Information Security Management System, ISO/IEC 27001 Compliance | 88 | | [![SOC2](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-eks-workers/soc2)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-eks-workers&benchmark=SOC2)| Service Organization Control 2 Compliance | 89 | | [![CIS GCP](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-eks-workers/cis_gcp)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-eks-workers&benchmark=CIS+GCP+V1.1) | Center for Internet Security, GCP Compliance | 90 | | [![HIPAA](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-eks-workers/hipaa)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-eks-workers&benchmark=HIPAA) | Health Insurance Portability and Accountability Compliance | 91 | 92 | 93 | 94 | ## Usage 95 | 96 | 97 | **IMPORTANT:** We do not pin modules to versions in our examples because of the 98 | difficulty of keeping the versions in the documentation in sync with the latest released versions. 99 | We highly recommend that in your code you pin the version to the exact version you are 100 | using so that your infrastructure remains stable, and update versions in a 101 | systematic way so that they do not catch you by surprise. 102 | 103 | Also, because of a bug in the Terraform registry ([hashicorp/terraform#21417](https://github.com/hashicorp/terraform/issues/21417)), 104 | the registry shows many of our inputs as required when in fact they are optional. 105 | The table below correctly indicates which inputs are required. 106 | 107 | 108 | 109 | For a complete example, see [examples/complete](examples/complete) 110 | 111 | ```hcl 112 | provider "aws" { 113 | region = var.region 114 | } 115 | 116 | locals { 117 | # The usage of the specific kubernetes.io/cluster/* resource tags below are required 118 | # for EKS and Kubernetes to discover and manage networking resources 119 | # https://www.terraform.io/docs/providers/aws/guides/eks-getting-started.html#base-vpc-networking 120 | tags = merge(var.tags, map("kubernetes.io/cluster/${var.cluster_name}", "shared")) 121 | } 122 | 123 | module "vpc" { 124 | source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.8.0" 125 | namespace = var.namespace 126 | stage = var.stage 127 | name = var.name 128 | cidr_block = "172.16.0.0/16" 129 | tags = local.tags 130 | } 131 | 132 | module "subnets" { 133 | source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.16.0" 134 | availability_zones = var.availability_zones 135 | namespace = var.namespace 136 | stage = var.stage 137 | name = var.name 138 | vpc_id = module.vpc.vpc_id 139 | igw_id = module.vpc.igw_id 140 | cidr_block = module.vpc.vpc_cidr_block 141 | nat_gateway_enabled = false 142 | nat_instance_enabled = false 143 | tags = local.tags 144 | } 145 | 146 | module "eks_workers" { 147 | source = "cloudposse/eks-workers/aws" 148 | # Cloud Posse recommends pinning every module to a specific version 149 | # version = "x.x.x" 150 | namespace = var.namespace 151 | stage = var.stage 152 | name = var.name 153 | instance_type = var.instance_type 154 | vpc_id = module.vpc.vpc_id 155 | subnet_ids = module.subnets.public_subnet_ids 156 | health_check_type = var.health_check_type 157 | min_size = var.min_size 158 | max_size = var.max_size 159 | wait_for_capacity_timeout = var.wait_for_capacity_timeout 160 | cluster_name = var.cluster_name 161 | cluster_endpoint = var.cluster_endpoint 162 | cluster_certificate_authority_data = var.cluster_certificate_authority_data 163 | 164 | security_group_rules = [ 165 | { 166 | type = "egress" 167 | from_port = 0 168 | to_port = 65535 169 | protocol = "-1" 170 | cidr_blocks = ["0.0.0.0/0"] 171 | source_security_group_id = null 172 | description = "Allow all outbound traffic" 173 | }, 174 | { 175 | type = "ingress" 176 | from_port = 0 177 | to_port = 65535 178 | protocol = "-1" 179 | cidr_blocks = [] 180 | source_security_group_id = "sg-XXXXXXXXX" 181 | description = "Allow all inbound traffic from Security Group ID of the EKS cluster" 182 | } 183 | ] 184 | 185 | # Auto-scaling policies and CloudWatch metric alarms 186 | autoscaling_policies_enabled = var.autoscaling_policies_enabled 187 | cpu_utilization_high_threshold_percent = var.cpu_utilization_high_threshold_percent 188 | cpu_utilization_low_threshold_percent = var.cpu_utilization_low_threshold_percent 189 | } 190 | ``` 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | ## Makefile Targets 199 | ```text 200 | Available targets: 201 | 202 | help Help screen 203 | help/all Display help for all targets 204 | help/short This help short screen 205 | lint Lint terraform code 206 | 207 | ``` 208 | 209 | 210 | ## Requirements 211 | 212 | | Name | Version | 213 | |------|---------| 214 | | [terraform](#requirement\_terraform) | >= 0.13 | 215 | | [aws](#requirement\_aws) | >= 2.0 | 216 | | [template](#requirement\_template) | >= 2.0 | 217 | 218 | ## Providers 219 | 220 | | Name | Version | 221 | |------|---------| 222 | | [aws](#provider\_aws) | >= 2.0 | 223 | | [template](#provider\_template) | >= 2.0 | 224 | 225 | ## Modules 226 | 227 | | Name | Source | Version | 228 | |------|--------|---------| 229 | | [autoscale\_group](#module\_autoscale\_group) | cloudposse/ec2-autoscale-group/aws | 0.27.0 | 230 | | [label](#module\_label) | cloudposse/label/null | 0.25.0 | 231 | | [security\_group](#module\_security\_group) | cloudposse/security-group/aws | 0.3.3 | 232 | | [this](#module\_this) | cloudposse/label/null | 0.25.0 | 233 | 234 | ## Resources 235 | 236 | | Name | Type | 237 | |------|------| 238 | | [aws_iam_instance_profile.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource | 239 | | [aws_iam_role.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | 240 | | [aws_iam_role_policy_attachment.amazon_ec2_container_registry_read_only](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 241 | | [aws_iam_role_policy_attachment.amazon_eks_cni_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 242 | | [aws_iam_role_policy_attachment.amazon_eks_worker_node_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 243 | | [aws_iam_role_policy_attachment.existing_policies_attach_to_eks_workers_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 244 | | [aws_ami.eks_worker](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | 245 | | [aws_iam_instance_profile.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_instance_profile) | data source | 246 | | [aws_iam_policy_document.assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 247 | | [template_file.userdata](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source | 248 | 249 | ## Inputs 250 | 251 | | Name | Description | Type | Default | Required | 252 | |------|-------------|------|---------|:--------:| 253 | | [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no | 254 | | [after\_cluster\_joining\_userdata](#input\_after\_cluster\_joining\_userdata) | Additional commands to execute on each worker node after joining the EKS cluster (after executing the `bootstrap.sh` script). For mot info, see https://kubedex.com/90-days-of-aws-eks-in-production | `string` | `""` | no | 255 | | [associate\_public\_ip\_address](#input\_associate\_public\_ip\_address) | Associate a public IP address with an instance in a VPC | `bool` | `false` | no | 256 | | [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the `delimiter`
and treated as a single ID element. | `list(string)` | `[]` | no | 257 | | [autoscaling\_group\_tags](#input\_autoscaling\_group\_tags) | Additional tags only for the autoscaling group, e.g. "k8s.io/cluster-autoscaler/node-template/taint/dedicated" = "ci-cd:NoSchedule". | `map(string)` | `{}` | no | 258 | | [autoscaling\_policies\_enabled](#input\_autoscaling\_policies\_enabled) | Whether to create `aws_autoscaling_policy` and `aws_cloudwatch_metric_alarm` resources to control Auto Scaling | `bool` | `true` | no | 259 | | [aws\_iam\_instance\_profile\_name](#input\_aws\_iam\_instance\_profile\_name) | The name of the existing instance profile that will be used in autoscaling group for EKS workers. If empty will create a new instance profile. | `string` | `""` | no | 260 | | [before\_cluster\_joining\_userdata](#input\_before\_cluster\_joining\_userdata) | Additional commands to execute on each worker node before joining the EKS cluster (before executing the `bootstrap.sh` script). For mot info, see https://kubedex.com/90-days-of-aws-eks-in-production | `string` | `""` | no | 261 | | [block\_device\_mappings](#input\_block\_device\_mappings) | Specify volumes to attach to the instance besides the volumes specified by the AMI |
list(object({
device_name = string
no_device = bool
virtual_name = string
ebs = object({
delete_on_termination = bool
encrypted = bool
iops = number
kms_key_id = string
snapshot_id = string
volume_size = number
volume_type = string
})
}))
| `[]` | no | 262 | | [bootstrap\_extra\_args](#input\_bootstrap\_extra\_args) | Extra arguments to the `bootstrap.sh` script to enable `--enable-docker-bridge` or `--use-max-pods` | `string` | `""` | no | 263 | | [cluster\_certificate\_authority\_data](#input\_cluster\_certificate\_authority\_data) | The base64 encoded certificate data required to communicate with the cluster | `string` | n/a | yes | 264 | | [cluster\_endpoint](#input\_cluster\_endpoint) | EKS cluster endpoint | `string` | n/a | yes | 265 | | [cluster\_name](#input\_cluster\_name) | The name of the EKS cluster | `string` | n/a | yes | 266 | | [context](#input\_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,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
| no | 267 | | [cpu\_utilization\_high\_evaluation\_periods](#input\_cpu\_utilization\_high\_evaluation\_periods) | The number of periods over which data is compared to the specified threshold | `number` | `2` | no | 268 | | [cpu\_utilization\_high\_period\_seconds](#input\_cpu\_utilization\_high\_period\_seconds) | The period in seconds over which the specified statistic is applied | `number` | `300` | no | 269 | | [cpu\_utilization\_high\_statistic](#input\_cpu\_utilization\_high\_statistic) | The statistic to apply to the alarm's associated metric. Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum` | `string` | `"Average"` | no | 270 | | [cpu\_utilization\_high\_threshold\_percent](#input\_cpu\_utilization\_high\_threshold\_percent) | The value against which the specified statistic is compared | `number` | `90` | no | 271 | | [cpu\_utilization\_low\_evaluation\_periods](#input\_cpu\_utilization\_low\_evaluation\_periods) | The number of periods over which data is compared to the specified threshold | `number` | `2` | no | 272 | | [cpu\_utilization\_low\_period\_seconds](#input\_cpu\_utilization\_low\_period\_seconds) | The period in seconds over which the specified statistic is applied | `number` | `300` | no | 273 | | [cpu\_utilization\_low\_statistic](#input\_cpu\_utilization\_low\_statistic) | The statistic to apply to the alarm's associated metric. Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum` | `string` | `"Average"` | no | 274 | | [cpu\_utilization\_low\_threshold\_percent](#input\_cpu\_utilization\_low\_threshold\_percent) | The value against which the specified statistic is compared | `number` | `10` | no | 275 | | [credit\_specification](#input\_credit\_specification) | Customize the credit specification of the instances |
object({
cpu_credits = string
})
| `null` | no | 276 | | [default\_cooldown](#input\_default\_cooldown) | The amount of time, in seconds, after a scaling activity completes before another scaling activity can start | `number` | `300` | no | 277 | | [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no | 278 | | [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
`labels` is a list of labels, in order, to pass to `format()` function.
Label values will be normalized before being passed to `format()` so they will be
identical to how they appear in `id`.
Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no | 279 | | [disable\_api\_termination](#input\_disable\_api\_termination) | If `true`, enables EC2 Instance Termination Protection | `bool` | `false` | no | 280 | | [ebs\_optimized](#input\_ebs\_optimized) | If true, the launched EC2 instance will be EBS-optimized | `bool` | `false` | no | 281 | | [eks\_worker\_ami\_name\_filter](#input\_eks\_worker\_ami\_name\_filter) | AMI name filter to lookup the most recent EKS AMI if `image_id` is not provided | `string` | `"amazon-eks-node-*"` | no | 282 | | [eks\_worker\_ami\_name\_regex](#input\_eks\_worker\_ami\_name\_regex) | A regex string to apply to the AMI list returned by AWS | `string` | `"^amazon-eks-node-[1-9,.]+-v[0-9]{8}$"` | no | 283 | | [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | Specifications of Elastic GPU to attach to the instances |
object({
type = string
})
| `null` | no | 284 | | [enable\_monitoring](#input\_enable\_monitoring) | Enable/disable detailed monitoring | `bool` | `true` | no | 285 | | [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | 286 | | [enabled\_metrics](#input\_enabled\_metrics) | A list of metrics to collect. The allowed values are `GroupMinSize`, `GroupMaxSize`, `GroupDesiredCapacity`, `GroupInServiceInstances`, `GroupPendingInstances`, `GroupStandbyInstances`, `GroupTerminatingInstances`, `GroupTotalInstances` | `list(string)` |
[
"GroupMinSize",
"GroupMaxSize",
"GroupDesiredCapacity",
"GroupInServiceInstances",
"GroupPendingInstances",
"GroupStandbyInstances",
"GroupTerminatingInstances",
"GroupTotalInstances"
]
| no | 287 | | [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | 288 | | [force\_delete](#input\_force\_delete) | Allows deleting the autoscaling group without waiting for all instances in the pool to terminate. You can force an autoscaling 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` | `false` | no | 289 | | [health\_check\_grace\_period](#input\_health\_check\_grace\_period) | Time (in seconds) after instance comes into service before checking health | `number` | `300` | no | 290 | | [health\_check\_type](#input\_health\_check\_type) | Controls how health checking is done. Valid values are `EC2` or `ELB` | `string` | `"EC2"` | no | 291 | | [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for keep the existing setting, which defaults to `0`.
Does not affect `id_full`. | `number` | `null` | no | 292 | | [image\_id](#input\_image\_id) | EC2 image ID to launch. If not provided, the module will lookup the most recent EKS AMI. See https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html for more details on EKS-optimized images | `string` | `""` | no | 293 | | [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Shutdown behavior for the instances. Can be `stop` or `terminate` | `string` | `"terminate"` | no | 294 | | [instance\_market\_options](#input\_instance\_market\_options) | The market (purchasing) option for the instances |
object({
market_type = string
spot_options = object({
block_duration_minutes = number
instance_interruption_behavior = string
max_price = number
spot_instance_type = string
valid_until = string
})
})
| `null` | no | 295 | | [instance\_type](#input\_instance\_type) | Instance type to launch | `string` | n/a | yes | 296 | | [key\_name](#input\_key\_name) | SSH key name that should be used for the instance | `string` | `""` | no | 297 | | [kubelet\_extra\_args](#input\_kubelet\_extra\_args) | Extra arguments to pass to kubelet, like "--register-with-taints=dedicated=ci-cd:NoSchedule --node-labels=purpose=ci-worker" | `string` | `""` | no | 298 | | [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no | 299 | | [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no | 300 | | [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.
Default value: `lower`. | `string` | `null` | no | 301 | | [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.
Default is to include all labels.
Tags with empty values will not be included in the `tags` output.
Set to `[]` to suppress all generated tags.
**Notes:**
The value of the `name` tag, if included, will be the `id`, not the `name`.
Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be
changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` |
[
"default"
]
| no | 302 | | [load\_balancers](#input\_load\_balancers) | A list of elastic load balancer names to add to the autoscaling group. Only valid for classic load balancers. For ALBs, use `target_group_arns` instead | `list(string)` | `[]` | no | 303 | | [max\_size](#input\_max\_size) | The maximum size of the autoscale group | `number` | n/a | yes | 304 | | [metadata\_http\_endpoint\_enabled](#input\_metadata\_http\_endpoint\_enabled) | Set false to disable the Instance Metadata Service. | `bool` | `true` | no | 305 | | [metadata\_http\_put\_response\_hop\_limit](#input\_metadata\_http\_put\_response\_hop\_limit) | The desired HTTP PUT response hop limit (between 1 and 64) for Instance Metadata Service requests.
The default is `2` to support containerized workloads. | `number` | `2` | no | 306 | | [metadata\_http\_tokens\_required](#input\_metadata\_http\_tokens\_required) | Set true to require IMDS session tokens, disabling Instance Metadata Service Version 1. | `bool` | `true` | no | 307 | | [metrics\_granularity](#input\_metrics\_granularity) | The granularity to associate with the metrics to collect. The only valid value is 1Minute | `string` | `"1Minute"` | no | 308 | | [min\_elb\_capacity](#input\_min\_elb\_capacity) | 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 | `number` | `0` | no | 309 | | [min\_size](#input\_min\_size) | The minimum size of the autoscale group | `number` | n/a | yes | 310 | | [mixed\_instances\_policy](#input\_mixed\_instances\_policy) | policy to used mixed group of on demand/spot of differing types. Launch template is automatically generated. https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html#mixed_instances_policy-1 |
object({
instances_distribution = object({
on_demand_allocation_strategy = string
on_demand_base_capacity = number
on_demand_percentage_above_base_capacity = number
spot_allocation_strategy = string
spot_instance_pools = number
spot_max_price = string
})
override = list(object({
instance_type = string
weighted_capacity = number
}))
})
| `null` | no | 311 | | [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a `tag`.
The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no | 312 | | [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no | 313 | | [permissions\_boundary](#input\_permissions\_boundary) | Provide an existing permissions boundary to attach to the default role | `string` | `null` | no | 314 | | [placement](#input\_placement) | The placement specifications of the instances |
object({
affinity = string
availability_zone = string
group_name = string
host_id = string
tenancy = string
})
| `null` | no | 315 | | [placement\_group](#input\_placement\_group) | The name of the placement group into which you'll launch your instances, if any | `string` | `""` | no | 316 | | [protect\_from\_scale\_in](#input\_protect\_from\_scale\_in) | Allows setting instance protection. The autoscaling group will not select instances with this setting for terminination during scale in events | `bool` | `false` | no | 317 | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | 318 | | [scale\_down\_adjustment\_type](#input\_scale\_down\_adjustment\_type) | Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity` and `PercentChangeInCapacity` | `string` | `"ChangeInCapacity"` | no | 319 | | [scale\_down\_cooldown\_seconds](#input\_scale\_down\_cooldown\_seconds) | The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start | `number` | `300` | no | 320 | | [scale\_down\_policy\_type](#input\_scale\_down\_policy\_type) | The scalling policy type, either `SimpleScaling`, `StepScaling` or `TargetTrackingScaling` | `string` | `"SimpleScaling"` | no | 321 | | [scale\_down\_scaling\_adjustment](#input\_scale\_down\_scaling\_adjustment) | The number of instances by which to scale. `scale_down_scaling_adjustment` determines the interpretation of this number (e.g. as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity | `number` | `-1` | no | 322 | | [scale\_up\_adjustment\_type](#input\_scale\_up\_adjustment\_type) | Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity` and `PercentChangeInCapacity` | `string` | `"ChangeInCapacity"` | no | 323 | | [scale\_up\_cooldown\_seconds](#input\_scale\_up\_cooldown\_seconds) | The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start | `number` | `300` | no | 324 | | [scale\_up\_policy\_type](#input\_scale\_up\_policy\_type) | The scalling policy type, either `SimpleScaling`, `StepScaling` or `TargetTrackingScaling` | `string` | `"SimpleScaling"` | no | 325 | | [scale\_up\_scaling\_adjustment](#input\_scale\_up\_scaling\_adjustment) | The number of instances by which to scale. `scale_up_adjustment_type` determines the interpretation of this number (e.g. as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity | `number` | `1` | no | 326 | | [security\_group\_description](#input\_security\_group\_description) | The Security Group description. | `string` | `"Security Group for EKS worker nodes"` | no | 327 | | [security\_group\_enabled](#input\_security\_group\_enabled) | Whether to create default Security Group for EKS worker nodes. | `bool` | `true` | no | 328 | | [security\_group\_rules](#input\_security\_group\_rules) | A list of maps of Security Group rules.
The values of map is fully complated with `aws_security_group_rule` resource.
To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule . | `list(any)` |
[
{
"cidr_blocks": [
"0.0.0.0/0"
],
"description": "Allow all outbound traffic",
"from_port": 0,
"protocol": "-1",
"to_port": 65535,
"type": "egress"
}
]
| no | 329 | | [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Whether to create a default Security Group with unique name beginning with the normalized prefix. | `bool` | `false` | no | 330 | | [security\_groups](#input\_security\_groups) | A list of Security Group IDs to associate with EKS worker nodes. | `list(string)` | `[]` | no | 331 | | [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` | `""` | no | 332 | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | 333 | | [subnet\_ids](#input\_subnet\_ids) | A list of subnet IDs to launch resources in | `list(string)` | n/a | yes | 334 | | [suspended\_processes](#input\_suspended\_processes) | A list of processes to suspend for the AutoScaling 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 autoscaling group from functioning properly. | `list(string)` | `[]` | no | 335 | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | 336 | | [target\_group\_arns](#input\_target\_group\_arns) | A list of aws\_alb\_target\_group ARNs, for use with Application Load Balancing | `list(string)` | `[]` | no | 337 | | [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no | 338 | | [termination\_policies](#input\_termination\_policies) | A list of policies to decide how the instances in the auto scale group should be terminated. The allowed values are `OldestInstance`, `NewestInstance`, `OldestLaunchConfiguration`, `ClosestToNextInstanceHour`, `Default` | `list(string)` |
[
"Default"
]
| no | 339 | | [use\_custom\_image\_id](#input\_use\_custom\_image\_id) | If set to `true`, will use variable `image_id` for the EKS workers inside autoscaling group | `bool` | `false` | no | 340 | | [use\_existing\_aws\_iam\_instance\_profile](#input\_use\_existing\_aws\_iam\_instance\_profile) | If set to `true`, will use variable `aws_iam_instance_profile_name` to run EKS workers using an existing AWS instance profile that was created outside of this module, workaround for error like `count cannot be computed` | `bool` | `false` | no | 341 | | [vpc\_id](#input\_vpc\_id) | VPC ID for the EKS cluster | `string` | n/a | yes | 342 | | [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. Setting this to '0' causes Terraform to skip all Capacity Waiting behavior | `string` | `"10m"` | no | 343 | | [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` | `0` | no | 344 | | [workers\_role\_policy\_arns](#input\_workers\_role\_policy\_arns) | List of policy ARNs that will be attached to the workers default role on creation | `list(string)` | `[]` | no | 345 | | [workers\_role\_policy\_arns\_count](#input\_workers\_role\_policy\_arns\_count) | Count of policy ARNs that will be attached to the workers default role on creation. Needed to prevent Terraform error `count can't be computed` | `number` | `0` | no | 346 | 347 | ## Outputs 348 | 349 | | Name | Description | 350 | |------|-------------| 351 | | [autoscaling\_group\_arn](#output\_autoscaling\_group\_arn) | ARN of the AutoScaling Group | 352 | | [autoscaling\_group\_default\_cooldown](#output\_autoscaling\_group\_default\_cooldown) | Time between a scaling activity and the succeeding scaling activity | 353 | | [autoscaling\_group\_desired\_capacity](#output\_autoscaling\_group\_desired\_capacity) | The number of Amazon EC2 instances that should be running in the group | 354 | | [autoscaling\_group\_health\_check\_grace\_period](#output\_autoscaling\_group\_health\_check\_grace\_period) | Time after instance comes into service before checking health | 355 | | [autoscaling\_group\_health\_check\_type](#output\_autoscaling\_group\_health\_check\_type) | `EC2` or `ELB`. Controls how health checking is done | 356 | | [autoscaling\_group\_id](#output\_autoscaling\_group\_id) | The AutoScaling Group ID | 357 | | [autoscaling\_group\_max\_size](#output\_autoscaling\_group\_max\_size) | The maximum size of the AutoScaling Group | 358 | | [autoscaling\_group\_min\_size](#output\_autoscaling\_group\_min\_size) | The minimum size of the AutoScaling Group | 359 | | [autoscaling\_group\_name](#output\_autoscaling\_group\_name) | The AutoScaling Group name | 360 | | [autoscaling\_group\_tags](#output\_autoscaling\_group\_tags) | A list of tag settings associated with the AutoScaling Group | 361 | | [launch\_template\_arn](#output\_launch\_template\_arn) | ARN of the launch template | 362 | | [launch\_template\_id](#output\_launch\_template\_id) | The ID of the launch template | 363 | | [security\_group\_arn](#output\_security\_group\_arn) | ARN of the worker nodes Security Group | 364 | | [security\_group\_id](#output\_security\_group\_id) | ID of the worker nodes Security Group | 365 | | [security\_group\_name](#output\_security\_group\_name) | Name of the worker nodes Security Group | 366 | | [workers\_role\_arn](#output\_workers\_role\_arn) | ARN of the worker nodes IAM role | 367 | | [workers\_role\_name](#output\_workers\_role\_name) | Name of the worker nodes IAM role | 368 | 369 | 370 | 371 | 372 | ## Share the Love 373 | 374 | Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/terraform-aws-eks-workers)! (it helps us **a lot**) 375 | 376 | Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =) 377 | 378 | 379 | 380 | ## Related Projects 381 | 382 | Check out these related projects. 383 | 384 | - [terraform-aws-ec2-autoscale-group](https://github.com/cloudposse/terraform-aws-ec2-autoscale-group) - Terraform module to provision Auto Scaling Group and Launch Template on AWS 385 | - [terraform-aws-ecs-container-definition](https://github.com/cloudposse/terraform-aws-ecs-container-definition) - Terraform module to generate well-formed JSON documents (container definitions) that are passed to the aws_ecs_task_definition Terraform resource 386 | - [terraform-aws-ecs-alb-service-task](https://github.com/cloudposse/terraform-aws-ecs-alb-service-task) - Terraform module which implements an ECS service which exposes a web service via ALB 387 | - [terraform-aws-ecs-web-app](https://github.com/cloudposse/terraform-aws-ecs-web-app) - Terraform module that implements a web app on ECS and supports autoscaling, CI/CD, monitoring, ALB integration, and much more 388 | - [terraform-aws-ecs-codepipeline](https://github.com/cloudposse/terraform-aws-ecs-codepipeline) - Terraform module for CI/CD with AWS Code Pipeline and Code Build for ECS 389 | - [terraform-aws-ecs-cloudwatch-autoscaling](https://github.com/cloudposse/terraform-aws-ecs-cloudwatch-autoscaling) - Terraform module to autoscale ECS Service based on CloudWatch metrics 390 | - [terraform-aws-ecs-cloudwatch-sns-alarms](https://github.com/cloudposse/terraform-aws-ecs-cloudwatch-sns-alarms) - Terraform module to create CloudWatch Alarms on ECS Service level metrics 391 | - [terraform-aws-ec2-instance](https://github.com/cloudposse/terraform-aws-ec2-instance) - Terraform module for providing a general purpose EC2 instance 392 | - [terraform-aws-ec2-instance-group](https://github.com/cloudposse/terraform-aws-ec2-instance-group) - Terraform module for provisioning multiple general purpose EC2 hosts for stateful applications 393 | 394 | ## Help 395 | 396 | **Got a question?** We got answers. 397 | 398 | File a GitHub [issue](https://github.com/cloudposse/terraform-aws-eks-workers/issues), send us an [email][email] or join our [Slack Community][slack]. 399 | 400 | [![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link] 401 | 402 | ## DevOps Accelerator for Startups 403 | 404 | 405 | We are a [**DevOps Accelerator**][commercial_support]. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us. 406 | 407 | [![Learn More](https://img.shields.io/badge/learn%20more-success.svg?style=for-the-badge)][commercial_support] 408 | 409 | Work directly with our team of DevOps experts via email, slack, and video conferencing. 410 | 411 | We deliver 10x the value for a fraction of the cost of a full-time engineer. Our track record is not even funny. If you want things done right and you need it done FAST, then we're your best bet. 412 | 413 | - **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code. 414 | - **Release Engineering.** You'll have end-to-end CI/CD with unlimited staging environments. 415 | - **Site Reliability Engineering.** You'll have total visibility into your apps and microservices. 416 | - **Security Baseline.** You'll have built-in governance with accountability and audit logs for all changes. 417 | - **GitOps.** You'll be able to operate your infrastructure via Pull Requests. 418 | - **Training.** You'll receive hands-on training so your team can operate what we build. 419 | - **Questions.** You'll have a direct line of communication between our teams via a Shared Slack channel. 420 | - **Troubleshooting.** You'll get help to triage when things aren't working. 421 | - **Code Reviews.** You'll receive constructive feedback on Pull Requests. 422 | - **Bug Fixes.** We'll rapidly work with you to fix any bugs in our projects. 423 | 424 | ## Slack Community 425 | 426 | Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure. 427 | 428 | ## Discourse Forums 429 | 430 | Participate in our [Discourse Forums][discourse]. Here you'll find answers to commonly asked questions. Most questions will be related to the enormous number of projects we support on our GitHub. Come here to collaborate on answers, find solutions, and get ideas about the products and services we value. It only takes a minute to get started! Just sign in with SSO using your GitHub account. 431 | 432 | ## Newsletter 433 | 434 | Sign up for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover. 435 | 436 | ## Office Hours 437 | 438 | [Join us every Wednesday via Zoom][office_hours] for our weekly "Lunch & Learn" sessions. It's **FREE** for everyone! 439 | 440 | [![zoom](https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png")][office_hours] 441 | 442 | ## Contributing 443 | 444 | ### Bug Reports & Feature Requests 445 | 446 | Please use the [issue tracker](https://github.com/cloudposse/terraform-aws-eks-workers/issues) to report any bugs or file feature requests. 447 | 448 | ### Developing 449 | 450 | If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with our other projects, we would love to hear from you! Shoot us an [email][email]. 451 | 452 | In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. 453 | 454 | 1. **Fork** the repo on GitHub 455 | 2. **Clone** the project to your own machine 456 | 3. **Commit** changes to your own branch 457 | 4. **Push** your work back up to your fork 458 | 5. Submit a **Pull Request** so that we can review your changes 459 | 460 | **NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request! 461 | 462 | 463 | ## Copyright 464 | 465 | Copyright © 2017-2022 [Cloud Posse, LLC](https://cpco.io/copyright) 466 | 467 | 468 | 469 | ## License 470 | 471 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 472 | 473 | See [LICENSE](LICENSE) for full details. 474 | 475 | ```text 476 | Licensed to the Apache Software Foundation (ASF) under one 477 | or more contributor license agreements. See the NOTICE file 478 | distributed with this work for additional information 479 | regarding copyright ownership. The ASF licenses this file 480 | to you under the Apache License, Version 2.0 (the 481 | "License"); you may not use this file except in compliance 482 | with the License. You may obtain a copy of the License at 483 | 484 | https://www.apache.org/licenses/LICENSE-2.0 485 | 486 | Unless required by applicable law or agreed to in writing, 487 | software distributed under the License is distributed on an 488 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 489 | KIND, either express or implied. See the License for the 490 | specific language governing permissions and limitations 491 | under the License. 492 | ``` 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | ## Trademarks 503 | 504 | All other trademarks referenced herein are the property of their respective owners. 505 | 506 | ## About 507 | 508 | This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know by [leaving a testimonial][testimonial]! 509 | 510 | [![Cloud Posse][logo]][website] 511 | 512 | We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We ❤️ [Open Source Software][we_love_open_source]. 513 | 514 | We offer [paid support][commercial_support] on all of our projects. 515 | 516 | Check out [our other projects][github], [follow us on twitter][twitter], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation. 517 | 518 | 519 | 520 | ### Contributors 521 | 522 | 523 | | [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]
[Andriy Knysh][aknysh_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | [![Vladimir Syromyatnikov][SweetOps_avatar]][SweetOps_homepage]
[Vladimir Syromyatnikov][SweetOps_homepage] | 524 | |---|---|---|---| 525 | 526 | 527 | [osterman_homepage]: https://github.com/osterman 528 | [osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png 529 | [aknysh_homepage]: https://github.com/aknysh 530 | [aknysh_avatar]: https://img.cloudposse.com/150x150/https://github.com/aknysh.png 531 | [goruha_homepage]: https://github.com/goruha 532 | [goruha_avatar]: https://img.cloudposse.com/150x150/https://github.com/goruha.png 533 | [SweetOps_homepage]: https://github.com/SweetOps 534 | [SweetOps_avatar]: https://img.cloudposse.com/150x150/https://github.com/SweetOps.png 535 | 536 | [![README Footer][readme_footer_img]][readme_footer_link] 537 | [![Beacon][beacon]][website] 538 | 539 | [logo]: https://cloudposse.com/logo-300x69.svg 540 | [docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=docs 541 | [website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=website 542 | [github]: https://cpco.io/github?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=github 543 | [jobs]: https://cpco.io/jobs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=jobs 544 | [hire]: https://cpco.io/hire?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=hire 545 | [slack]: https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=slack 546 | [linkedin]: https://cpco.io/linkedin?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=linkedin 547 | [twitter]: https://cpco.io/twitter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=twitter 548 | [testimonial]: https://cpco.io/leave-testimonial?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=testimonial 549 | [office_hours]: https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=office_hours 550 | [newsletter]: https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=newsletter 551 | [discourse]: https://ask.sweetops.com/?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=discourse 552 | [email]: https://cpco.io/email?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=email 553 | [commercial_support]: https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=commercial_support 554 | [we_love_open_source]: https://cpco.io/we-love-open-source?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=we_love_open_source 555 | [terraform_modules]: https://cpco.io/terraform-modules?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=terraform_modules 556 | [readme_header_img]: https://cloudposse.com/readme/header/img 557 | [readme_header_link]: https://cloudposse.com/readme/header/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=readme_header_link 558 | [readme_footer_img]: https://cloudposse.com/readme/footer/img 559 | [readme_footer_link]: https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=readme_footer_link 560 | [readme_commercial_support_img]: https://cloudposse.com/readme/commercial-support/img 561 | [readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-eks-workers&utm_content=readme_commercial_support_link 562 | [share_twitter]: https://twitter.com/intent/tweet/?text=terraform-aws-eks-workers&url=https://github.com/cloudposse/terraform-aws-eks-workers 563 | [share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=terraform-aws-eks-workers&url=https://github.com/cloudposse/terraform-aws-eks-workers 564 | [share_reddit]: https://reddit.com/submit/?url=https://github.com/cloudposse/terraform-aws-eks-workers 565 | [share_facebook]: https://facebook.com/sharer/sharer.php?u=https://github.com/cloudposse/terraform-aws-eks-workers 566 | [share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/terraform-aws-eks-workers 567 | [share_email]: mailto:?subject=terraform-aws-eks-workers&body=https://github.com/cloudposse/terraform-aws-eks-workers 568 | [beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/terraform-aws-eks-workers?pixel&cs=github&cm=readme&an=terraform-aws-eks-workers 569 | --------------------------------------------------------------------------------