├── .editorconfig ├── .github └── workflows │ ├── lock.yml │ ├── pr-title.yml │ ├── pre-commit.yml │ ├── release.yml │ └── stale-actions.yaml ├── .gitignore ├── .pre-commit-config.yaml ├── .releaserc.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── examples ├── README.md └── complete │ ├── README.md │ ├── main.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── main.tf ├── modules ├── elb │ ├── README.md │ ├── main.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf └── elb_attachment │ ├── README.md │ ├── main.tf │ ├── outputs.tf │ ├── variables.tf │ └── versions.tf ├── outputs.tf ├── variables.tf └── versions.tf /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | # Uses editorconfig to maintain consistent coding styles 3 | 4 | # top-most EditorConfig file 5 | root = true 6 | 7 | # Unix-style newlines with a newline ending every file 8 | [*] 9 | charset = utf-8 10 | end_of_line = lf 11 | indent_size = 2 12 | indent_style = space 13 | insert_final_newline = true 14 | max_line_length = 80 15 | trim_trailing_whitespace = true 16 | 17 | [*.{tf,tfvars}] 18 | indent_size = 2 19 | indent_style = space 20 | 21 | [*.md] 22 | max_line_length = 0 23 | trim_trailing_whitespace = false 24 | 25 | [Makefile] 26 | tab_width = 2 27 | indent_style = tab 28 | 29 | [COMMIT_EDITMSG] 30 | max_line_length = 0 31 | -------------------------------------------------------------------------------- /.github/workflows/lock.yml: -------------------------------------------------------------------------------- 1 | name: 'Lock Threads' 2 | 3 | on: 4 | schedule: 5 | - cron: '50 1 * * *' 6 | 7 | jobs: 8 | lock: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: dessant/lock-threads@v5 12 | with: 13 | github-token: ${{ secrets.GITHUB_TOKEN }} 14 | issue-comment: > 15 | I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues. 16 | If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. 17 | issue-inactive-days: '30' 18 | pr-comment: > 19 | I'm going to lock this pull request because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues. 20 | If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. 21 | pr-inactive-days: '30' 22 | -------------------------------------------------------------------------------- /.github/workflows/pr-title.yml: -------------------------------------------------------------------------------- 1 | name: 'Validate PR title' 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - opened 7 | - edited 8 | - synchronize 9 | 10 | jobs: 11 | main: 12 | name: Validate PR title 13 | runs-on: ubuntu-latest 14 | steps: 15 | # Please look up the latest version from 16 | # https://github.com/amannn/action-semantic-pull-request/releases 17 | - uses: amannn/action-semantic-pull-request@v5.5.3 18 | env: 19 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 20 | with: 21 | # Configure which types are allowed. 22 | # Default: https://github.com/commitizen/conventional-commit-types 23 | types: | 24 | fix 25 | feat 26 | docs 27 | ci 28 | chore 29 | # Configure that a scope must always be provided. 30 | requireScope: false 31 | # Configure additional validation for the subject based on a regex. 32 | # This example ensures the subject starts with an uppercase character. 33 | subjectPattern: ^[A-Z].+$ 34 | # If `subjectPattern` is configured, you can use this property to override 35 | # the default error message that is shown when the pattern doesn't match. 36 | # The variables `subject` and `title` can be used within the message. 37 | subjectPatternError: | 38 | The subject "{subject}" found in the pull request title "{title}" 39 | didn't match the configured pattern. Please ensure that the subject 40 | starts with an uppercase character. 41 | # For work-in-progress PRs you can typically use draft pull requests 42 | # from Github. However, private repositories on the free plan don't have 43 | # this option and therefore this action allows you to opt-in to using the 44 | # special "[WIP]" prefix to indicate this state. This will avoid the 45 | # validation of the PR title and the pull request checks remain pending. 46 | # Note that a second check will be reported if this is enabled. 47 | wip: true 48 | # When using "Squash and merge" on a PR with only one commit, GitHub 49 | # will suggest using that commit message instead of the PR title for the 50 | # merge commit, and it's easy to commit this by mistake. Enable this option 51 | # to also validate the commit message for one commit PRs. 52 | validateSingleCommit: false 53 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit.yml: -------------------------------------------------------------------------------- 1 | name: Pre-Commit 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | - master 8 | 9 | env: 10 | TERRAFORM_DOCS_VERSION: v0.19.0 11 | TFLINT_VERSION: v0.53.0 12 | 13 | jobs: 14 | collectInputs: 15 | name: Collect workflow inputs 16 | runs-on: ubuntu-latest 17 | outputs: 18 | directories: ${{ steps.dirs.outputs.directories }} 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v4 22 | 23 | - name: Get root directories 24 | id: dirs 25 | uses: clowdhaus/terraform-composite-actions/directories@v1.9.0 26 | 27 | preCommitMinVersions: 28 | name: Min TF pre-commit 29 | needs: collectInputs 30 | runs-on: ubuntu-latest 31 | strategy: 32 | matrix: 33 | directory: ${{ fromJson(needs.collectInputs.outputs.directories) }} 34 | steps: 35 | # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449 36 | - name: Delete huge unnecessary tools folder 37 | run: | 38 | rm -rf /opt/hostedtoolcache/CodeQL 39 | rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk 40 | rm -rf /opt/hostedtoolcache/Ruby 41 | rm -rf /opt/hostedtoolcache/go 42 | 43 | - name: Checkout 44 | uses: actions/checkout@v4 45 | 46 | - name: Terraform min/max versions 47 | id: minMax 48 | uses: clowdhaus/terraform-min-max@v1.3.1 49 | with: 50 | directory: ${{ matrix.directory }} 51 | 52 | - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} 53 | # Run only validate pre-commit check on min version supported 54 | if: ${{ matrix.directory != '.' }} 55 | uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1 56 | with: 57 | terraform-version: ${{ steps.minMax.outputs.minVersion }} 58 | tflint-version: ${{ env.TFLINT_VERSION }} 59 | args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*' 60 | 61 | - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} 62 | # Run only validate pre-commit check on min version supported 63 | if: ${{ matrix.directory == '.' }} 64 | uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1 65 | with: 66 | terraform-version: ${{ steps.minMax.outputs.minVersion }} 67 | tflint-version: ${{ env.TFLINT_VERSION }} 68 | args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)' 69 | 70 | preCommitMaxVersion: 71 | name: Max TF pre-commit 72 | runs-on: ubuntu-latest 73 | needs: collectInputs 74 | steps: 75 | # https://github.com/orgs/community/discussions/25678#discussioncomment-5242449 76 | - name: Delete huge unnecessary tools folder 77 | run: | 78 | rm -rf /opt/hostedtoolcache/CodeQL 79 | rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk 80 | rm -rf /opt/hostedtoolcache/Ruby 81 | rm -rf /opt/hostedtoolcache/go 82 | 83 | - name: Checkout 84 | uses: actions/checkout@v4 85 | with: 86 | ref: ${{ github.event.pull_request.head.ref }} 87 | repository: ${{github.event.pull_request.head.repo.full_name}} 88 | 89 | - name: Terraform min/max versions 90 | id: minMax 91 | uses: clowdhaus/terraform-min-max@v1.3.1 92 | 93 | - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }} 94 | uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1 95 | with: 96 | terraform-version: ${{ steps.minMax.outputs.maxVersion }} 97 | tflint-version: ${{ env.TFLINT_VERSION }} 98 | terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }} 99 | install-hcledit: true 100 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - main 8 | - master 9 | paths: 10 | - '**/*.tpl' 11 | - '**/*.py' 12 | - '**/*.tf' 13 | - '.github/workflows/release.yml' 14 | 15 | jobs: 16 | release: 17 | name: Release 18 | runs-on: ubuntu-latest 19 | # Skip running release workflow on forks 20 | if: github.repository_owner == 'terraform-aws-modules' 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@v4 24 | with: 25 | persist-credentials: false 26 | fetch-depth: 0 27 | 28 | - name: Release 29 | uses: cycjimmy/semantic-release-action@v4 30 | with: 31 | semantic_version: 23.0.2 32 | extra_plugins: | 33 | @semantic-release/changelog@6.0.3 34 | @semantic-release/git@10.0.1 35 | conventional-changelog-conventionalcommits@7.0.2 36 | env: 37 | GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} 38 | -------------------------------------------------------------------------------- /.github/workflows/stale-actions.yaml: -------------------------------------------------------------------------------- 1 | name: 'Mark or close stale issues and PRs' 2 | on: 3 | schedule: 4 | - cron: '0 0 * * *' 5 | 6 | jobs: 7 | stale: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/stale@v9 11 | with: 12 | repo-token: ${{ secrets.GITHUB_TOKEN }} 13 | # Staling issues and PR's 14 | days-before-stale: 30 15 | stale-issue-label: stale 16 | stale-pr-label: stale 17 | stale-issue-message: | 18 | This issue has been automatically marked as stale because it has been open 30 days 19 | with no activity. Remove stale label or comment or this issue will be closed in 10 days 20 | stale-pr-message: | 21 | This PR has been automatically marked as stale because it has been open 30 days 22 | with no activity. Remove stale label or comment or this PR will be closed in 10 days 23 | # Not stale if have this labels or part of milestone 24 | exempt-issue-labels: bug,wip,on-hold 25 | exempt-pr-labels: bug,wip,on-hold 26 | exempt-all-milestones: true 27 | # Close issue operations 28 | # Label will be automatically removed if the issues are no longer closed nor locked. 29 | days-before-close: 10 30 | delete-branch: true 31 | close-issue-message: This issue was automatically closed because of stale in 10 days 32 | close-pr-message: This PR was automatically closed because of stale in 10 days 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Local .terraform directories 2 | **/.terraform/* 3 | 4 | # Terraform lockfile 5 | .terraform.lock.hcl 6 | 7 | # .tfstate files 8 | *.tfstate 9 | *.tfstate.* 10 | 11 | # Crash log files 12 | crash.log 13 | 14 | # Exclude all .tfvars files, which are likely to contain sentitive data, such as 15 | # password, private keys, and other secrets. These should not be part of version 16 | # control as they are data points which are potentially sensitive and subject 17 | # to change depending on the environment. 18 | *.tfvars 19 | 20 | # Ignore override files as they are usually used to override resources locally and so 21 | # are not checked in 22 | override.tf 23 | override.tf.json 24 | *_override.tf 25 | *_override.tf.json 26 | 27 | # Ignore CLI configuration files 28 | .terraformrc 29 | terraform.rc 30 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/antonbabenko/pre-commit-terraform 3 | rev: v1.96.1 4 | hooks: 5 | - id: terraform_fmt 6 | - id: terraform_docs 7 | args: 8 | - '--args=--lockfile=false' 9 | - id: terraform_tflint 10 | args: 11 | - '--args=--only=terraform_deprecated_interpolation' 12 | - '--args=--only=terraform_deprecated_index' 13 | - '--args=--only=terraform_unused_declarations' 14 | - '--args=--only=terraform_comment_syntax' 15 | - '--args=--only=terraform_documented_outputs' 16 | - '--args=--only=terraform_documented_variables' 17 | - '--args=--only=terraform_typed_variables' 18 | - '--args=--only=terraform_module_pinned_source' 19 | - '--args=--only=terraform_naming_convention' 20 | - '--args=--only=terraform_required_version' 21 | - '--args=--only=terraform_required_providers' 22 | - '--args=--only=terraform_standard_module_structure' 23 | - '--args=--only=terraform_workspace_remote' 24 | - id: terraform_validate 25 | - repo: https://github.com/pre-commit/pre-commit-hooks 26 | rev: v5.0.0 27 | hooks: 28 | - id: check-merge-conflict 29 | - id: end-of-file-fixer 30 | - id: trailing-whitespace 31 | -------------------------------------------------------------------------------- /.releaserc.json: -------------------------------------------------------------------------------- 1 | { 2 | "branches": [ 3 | "main", 4 | "master" 5 | ], 6 | "ci": false, 7 | "plugins": [ 8 | [ 9 | "@semantic-release/commit-analyzer", 10 | { 11 | "preset": "conventionalcommits" 12 | } 13 | ], 14 | [ 15 | "@semantic-release/release-notes-generator", 16 | { 17 | "preset": "conventionalcommits" 18 | } 19 | ], 20 | [ 21 | "@semantic-release/github", 22 | { 23 | "successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:", 24 | "labels": false, 25 | "releasedLabels": false 26 | } 27 | ], 28 | [ 29 | "@semantic-release/changelog", 30 | { 31 | "changelogFile": "CHANGELOG.md", 32 | "changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file." 33 | } 34 | ], 35 | [ 36 | "@semantic-release/git", 37 | { 38 | "assets": [ 39 | "CHANGELOG.md" 40 | ], 41 | "message": "chore(release): version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" 42 | } 43 | ] 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | ## [4.0.2](https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v4.0.1...v4.0.2) (2024-03-07) 6 | 7 | 8 | ### Bug Fixes 9 | 10 | * Update CI workflow versions to remove deprecated runtime warnings ([#49](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/49)) ([e81f1ca](https://github.com/terraform-aws-modules/terraform-aws-elb/commit/e81f1ca4fb31ab09705a140918e6a24548339845)) 11 | 12 | ### [4.0.1](https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v4.0.0...v4.0.1) (2023-01-24) 13 | 14 | 15 | ### Bug Fixes 16 | 17 | * Use a version for to avoid GitHub API rate limiting on CI workflows ([#46](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/46)) ([0501388](https://github.com/terraform-aws-modules/terraform-aws-elb/commit/0501388d753ad2cb8a2e698fef9ff84521e8dfc9)) 18 | 19 | ## [4.0.0](https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v3.0.1...v4.0.0) (2022-11-12) 20 | 21 | 22 | ### ⚠ BREAKING CHANGES 23 | 24 | * Update supported Terraform min version to v1.0+ and AWS provider to v4.0+ (#45) 25 | 26 | ### Features 27 | 28 | * Update supported Terraform min version to v1.0+ and AWS provider to v4.0+ ([#45](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/45)) ([4702d67](https://github.com/terraform-aws-modules/terraform-aws-elb/commit/4702d67bb2a1748254e8cc2e0d73645a05b60845)) 29 | 30 | ### [3.0.1](https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v3.0.0...v3.0.1) (2022-01-10) 31 | 32 | 33 | ### Bug Fixes 34 | 35 | * update CI/CD process to enable auto-release workflow ([#43](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/43)) ([e0a616d](https://github.com/terraform-aws-modules/terraform-aws-elb/commit/e0a616d517fcd4d0e7b88380cc47d96c5e4b08c6)) 36 | 37 | 38 | ## [v3.0.0] - 2021-04-26 39 | 40 | - feat: Shorten outputs (removing this_) ([#39](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/39)) 41 | - chore: update documentation and pin `terraform_docs` version to avoid future changes ([#38](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/38)) 42 | 43 | 44 | 45 | ## [v2.5.0] - 2021-03-15 46 | 47 | - fix: update pre-commit configuration to add validate and tflint ([#35](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/35)) 48 | - chore: add ci-cd workflow for pre-commit checks ([#34](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/34)) 49 | 50 | 51 | 52 | ## [v2.4.0] - 2020-06-19 53 | 54 | - feat: Added variable to enable/disable module ([#23](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/23)) 55 | - Minor update of README.md - certificate id argument name ([#32](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/32)) 56 | - Merge pull request [#31](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/31) from terraform-aws-modules/terraform-provider-githubfile-1584635213365195000 57 | - [ci skip] Create ".chglog/CHANGELOG.tpl.md". 58 | - Merge pull request [#30](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/30) from terraform-aws-modules/terraform-provider-githubfile-1584536634639555000 59 | - Merge pull request [#29](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/29) from terraform-aws-modules/terraform-provider-githubfile-1584536634639568000 60 | - [ci skip] Create ".pre-commit-config.yaml". 61 | - [ci skip] Create ".gitignore". 62 | - Merge pull request [#28](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/28) from terraform-aws-modules/terraform-provider-githubfile-1584536595705590000 63 | - Merge pull request [#26](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/26) from terraform-aws-modules/terraform-provider-githubfile-1584536595707469000 64 | - Merge pull request [#25](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/25) from terraform-aws-modules/terraform-provider-githubfile-1584536595705588000 65 | - [ci skip] Create "Makefile". 66 | - [ci skip] Create "LICENSE". 67 | - [ci skip] Create ".editorconfig". 68 | 69 | 70 | 71 | ## [v2.3.0] - 2019-11-04 72 | 73 | - Fixed var type for internal 74 | 75 | 76 | 77 | ## [v2.2.0] - 2019-08-21 78 | 79 | - Allow creation of ELB with and without access_logs (fixed [#21](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/21)) 80 | 81 | 82 | 83 | ## [v2.1.0] - 2019-07-17 84 | 85 | - Updated pre-commit and docs 86 | - Making access_logs field optional ([#20](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/20)) 87 | 88 | 89 | 90 | ## [v2.0.0] - 2019-06-09 91 | 92 | - Updated module for Terraform 0.12 ([#17](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/17)) 93 | 94 | 95 | 96 | ## [v1.4.1] - 2018-05-22 97 | 98 | - Fixed instances output ([#13](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/13)) 99 | 100 | 101 | 102 | ## [v1.4.0] - 2018-05-16 103 | 104 | - Added pre-commit hook to autogenerate terraform-docs ([#11](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/11)) 105 | 106 | 107 | 108 | ## [v1.3.1] - 2018-05-16 109 | 110 | - Fixed [#10](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/10). Wrong type in output 111 | - Fixed [#10](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/10). Wrong type in output 112 | 113 | 114 | 115 | ## [v1.3.0] - 2018-05-16 116 | 117 | - Fixed outputs of ELB module when resource does not exist 118 | 119 | 120 | 121 | ## [v1.2.0] - 2018-03-06 122 | 123 | - Renamed count to number_of_instances to be as much forward compatible as possible ([#9](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/9)) 124 | 125 | 126 | 127 | ## [v1.1.0] - 2018-03-01 128 | 129 | - Merge pull request [#8](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/8) from dropped/arn_output 130 | - Add the ARN output 131 | - Merge pull request [#6](https://github.com/terraform-aws-modules/terraform-aws-elb/issues/6) from horsey/master 132 | - - Fixed formatting 133 | - - Fixed formatting 134 | - - Added Known Issues/Limitations section 135 | 136 | 137 | 138 | ## [v1.0.1] - 2017-12-11 139 | 140 | - Upgraded ec2-instance module example 141 | 142 | 143 | 144 | ## v1.0.0 - 2017-09-14 145 | 146 | - Added complete code and examples 147 | - Added complete code and examples 148 | - Initial commit 149 | 150 | 151 | [Unreleased]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v3.0.0...HEAD 152 | [v3.0.0]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v2.5.0...v3.0.0 153 | [v2.5.0]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v2.4.0...v2.5.0 154 | [v2.4.0]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v2.3.0...v2.4.0 155 | [v2.3.0]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v2.2.0...v2.3.0 156 | [v2.2.0]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v2.1.0...v2.2.0 157 | [v2.1.0]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v2.0.0...v2.1.0 158 | [v2.0.0]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v1.4.1...v2.0.0 159 | [v1.4.1]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v1.4.0...v1.4.1 160 | [v1.4.0]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v1.3.1...v1.4.0 161 | [v1.3.1]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v1.3.0...v1.3.1 162 | [v1.3.0]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v1.2.0...v1.3.0 163 | [v1.2.0]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v1.1.0...v1.2.0 164 | [v1.1.0]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v1.0.1...v1.1.0 165 | [v1.0.1]: https://github.com/terraform-aws-modules/terraform-aws-elb/compare/v1.0.0...v1.0.1 166 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AWS Elastic Load Balancer (ELB) Terraform module 2 | 3 | Terraform module which creates Classic Load Balancer (also called ELB) resources on AWS. 4 | 5 | ## Usage 6 | 7 | ```hcl 8 | module "elb_http" { 9 | source = "terraform-aws-modules/elb/aws" 10 | 11 | name = "elb-example" 12 | 13 | subnets = ["subnet-12345678", "subnet-87654321"] 14 | security_groups = ["sg-12345678"] 15 | internal = false 16 | 17 | listener = [ 18 | { 19 | instance_port = 80 20 | instance_protocol = "HTTP" 21 | lb_port = 80 22 | lb_protocol = "HTTP" 23 | }, 24 | { 25 | instance_port = 8080 26 | instance_protocol = "http" 27 | lb_port = 8080 28 | lb_protocol = "http" 29 | ssl_certificate_id = "arn:aws:acm:eu-west-1:235367859451:certificate/6c270328-2cd5-4b2d-8dfd-ae8d0004ad31" 30 | }, 31 | ] 32 | 33 | health_check = { 34 | target = "HTTP:80/" 35 | interval = 30 36 | healthy_threshold = 2 37 | unhealthy_threshold = 2 38 | timeout = 5 39 | } 40 | 41 | access_logs = { 42 | bucket = "my-access-logs-bucket" 43 | } 44 | 45 | // ELB attachments 46 | number_of_instances = 2 47 | instances = ["i-06ff41a77dfb5349d", "i-4906ff41a77dfb53d"] 48 | 49 | tags = { 50 | Owner = "user" 51 | Environment = "dev" 52 | } 53 | } 54 | ``` 55 | 56 | ## Examples 57 | 58 | - [Complete ELB example](https://github.com/terraform-aws-modules/terraform-aws-elb/tree/master/examples/complete) 59 | 60 | ## Note about SSL 61 | 62 | - Valid SSL certificate has to be specified as `ssl_certificate_id` argument for secure listener. Use [terraform-aws-acm module](https://github.com/terraform-aws-modules/terraform-aws-acm) to create one. 63 | 64 | 65 | ## Requirements 66 | 67 | | Name | Version | 68 | |------|---------| 69 | | [terraform](#requirement\_terraform) | >= 1.0 | 70 | 71 | ## Providers 72 | 73 | No providers. 74 | 75 | ## Modules 76 | 77 | | Name | Source | Version | 78 | |------|--------|---------| 79 | | [elb](#module\_elb) | ./modules/elb | n/a | 80 | | [elb\_attachment](#module\_elb\_attachment) | ./modules/elb_attachment | n/a | 81 | 82 | ## Resources 83 | 84 | No resources. 85 | 86 | ## Inputs 87 | 88 | | Name | Description | Type | Default | Required | 89 | |------|-------------|------|---------|:--------:| 90 | | [access\_logs](#input\_access\_logs) | An access logs block | `map(string)` | `{}` | no | 91 | | [connection\_draining](#input\_connection\_draining) | Boolean to enable connection draining | `bool` | `false` | no | 92 | | [connection\_draining\_timeout](#input\_connection\_draining\_timeout) | The time in seconds to allow for connections to drain | `number` | `300` | no | 93 | | [create\_elb](#input\_create\_elb) | Create the elb or not | `bool` | `true` | no | 94 | | [cross\_zone\_load\_balancing](#input\_cross\_zone\_load\_balancing) | Enable cross-zone load balancing | `bool` | `true` | no | 95 | | [health\_check](#input\_health\_check) | A health check block | `map(string)` | n/a | yes | 96 | | [idle\_timeout](#input\_idle\_timeout) | The time in seconds that the connection is allowed to be idle | `number` | `60` | no | 97 | | [instances](#input\_instances) | List of instances ID to place in the ELB pool | `list(string)` | `[]` | no | 98 | | [internal](#input\_internal) | If true, ELB will be an internal ELB | `bool` | `false` | no | 99 | | [listener](#input\_listener) | A list of listener blocks | `list(map(string))` | n/a | yes | 100 | | [name](#input\_name) | The name of the ELB | `string` | `null` | no | 101 | | [name\_prefix](#input\_name\_prefix) | The prefix name of the ELB | `string` | `null` | no | 102 | | [number\_of\_instances](#input\_number\_of\_instances) | Number of instances to attach to ELB | `number` | `0` | no | 103 | | [security\_groups](#input\_security\_groups) | A list of security group IDs to assign to the ELB | `list(string)` | n/a | yes | 104 | | [subnets](#input\_subnets) | A list of subnet IDs to attach to the ELB | `list(string)` | n/a | yes | 105 | | [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)` | `{}` | no | 106 | 107 | ## Outputs 108 | 109 | | Name | Description | 110 | |------|-------------| 111 | | [elb\_arn](#output\_elb\_arn) | The ARN of the ELB | 112 | | [elb\_dns\_name](#output\_elb\_dns\_name) | The DNS name of the ELB | 113 | | [elb\_id](#output\_elb\_id) | The name of the ELB | 114 | | [elb\_instances](#output\_elb\_instances) | The list of instances in the ELB | 115 | | [elb\_name](#output\_elb\_name) | The name of the ELB | 116 | | [elb\_source\_security\_group\_id](#output\_elb\_source\_security\_group\_id) | The ID of the security group that you can use as part of your inbound rules for your load balancer's back-end application instances | 117 | | [elb\_zone\_id](#output\_elb\_zone\_id) | The canonical hosted zone ID of the ELB (to be used in a Route 53 Alias record) | 118 | 119 | 120 | ## Authors 121 | 122 | Module is maintained by [Anton Babenko](https://github.com/antonbabenko) with help from [these awesome contributors](https://github.com/terraform-aws-modules/terraform-aws-elb/graphs/contributors). 123 | 124 | ## License 125 | 126 | Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-elb/tree/master/LICENSE) for full details. 127 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | Please note - the examples provided serve two primary means: 4 | 5 | 1. Show users working examples of the various ways in which the module can be configured and features supported 6 | 2. A means of testing/validating module changes 7 | 8 | Please do not mistake the examples provided as "best practices". It is up to users to consult the AWS service documentation for best practices, usage recommendations, etc. 9 | -------------------------------------------------------------------------------- /examples/complete/README.md: -------------------------------------------------------------------------------- 1 | # Complete ELB example 2 | 3 | Configuration in this directory creates ELB, EC2 instances and attach them together. 4 | 5 | This example also creates ACM SSL certificate which can be attached to a secure listener in ELB. 6 | 7 | Data sources are used to discover existing VPC resources (VPC, subnet and security group). 8 | 9 | ## Usage 10 | 11 | To run this example you need to execute: 12 | 13 | ```bash 14 | $ terraform init 15 | $ terraform plan 16 | $ terraform apply 17 | ``` 18 | 19 | Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources. 20 | 21 | 22 | ## Requirements 23 | 24 | | Name | Version | 25 | |------|---------| 26 | | [terraform](#requirement\_terraform) | >= 1.0 | 27 | | [aws](#requirement\_aws) | >= 4.0 | 28 | 29 | ## Providers 30 | 31 | | Name | Version | 32 | |------|---------| 33 | | [aws](#provider\_aws) | >= 4.0 | 34 | 35 | ## Modules 36 | 37 | | Name | Source | Version | 38 | |------|--------|---------| 39 | | [ec2\_instance](#module\_ec2\_instance) | terraform-aws-modules/ec2-instance/aws | n/a | 40 | | [elb](#module\_elb) | ../../ | n/a | 41 | | [log\_bucket](#module\_log\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 3.0 | 42 | | [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 | 43 | 44 | ## Resources 45 | 46 | | Name | Type | 47 | |------|------| 48 | | [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source | 49 | 50 | ## Inputs 51 | 52 | No inputs. 53 | 54 | ## Outputs 55 | 56 | | Name | Description | 57 | |------|-------------| 58 | | [elb\_dns\_name](#output\_elb\_dns\_name) | The DNS name of the ELB | 59 | | [elb\_id](#output\_elb\_id) | The name of the ELB | 60 | | [elb\_instances](#output\_elb\_instances) | The list of instances in the ELB (if may be outdated, because instances are attached using elb\_attachment resource) | 61 | | [elb\_name](#output\_elb\_name) | The name of the ELB | 62 | | [elb\_source\_security\_group\_id](#output\_elb\_source\_security\_group\_id) | The ID of the security group that you can use as part of your inbound rules for your load balancer's back-end application instances | 63 | | [elb\_zone\_id](#output\_elb\_zone\_id) | The canonical hosted zone ID of the ELB (to be used in a Route 53 Alias record) | 64 | 65 | -------------------------------------------------------------------------------- /examples/complete/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = local.region 3 | } 4 | 5 | data "aws_availability_zones" "available" {} 6 | 7 | locals { 8 | region = "eu-west-1" 9 | name = "ex-${basename(path.cwd)}" 10 | 11 | vpc_cidr = "10.0.0.0/16" 12 | azs = slice(data.aws_availability_zones.available.names, 0, 3) 13 | 14 | tags = { 15 | Name = local.name 16 | Example = local.name 17 | Repository = "https://github.com/terraform-aws-modules/terraform-aws-elb" 18 | } 19 | } 20 | 21 | ################################################################## 22 | # Classic Load Balancer 23 | ################################################################## 24 | 25 | module "elb" { 26 | source = "../../" 27 | 28 | name = local.name 29 | 30 | subnets = module.vpc.public_subnets 31 | security_groups = [module.vpc.default_security_group_id] 32 | internal = false 33 | 34 | listener = [ 35 | { 36 | instance_port = "80" 37 | instance_protocol = "http" 38 | lb_port = "80" 39 | lb_protocol = "http" 40 | }, 41 | { 42 | instance_port = "8080" 43 | instance_protocol = "http" 44 | lb_port = "8080" 45 | lb_protocol = "http" 46 | }, 47 | ] 48 | 49 | health_check = { 50 | target = "HTTP:80/" 51 | interval = 30 52 | healthy_threshold = 2 53 | unhealthy_threshold = 2 54 | timeout = 5 55 | } 56 | 57 | access_logs = { 58 | bucket = module.log_bucket.s3_bucket_id 59 | } 60 | 61 | tags = { 62 | Owner = "user" 63 | Environment = "dev" 64 | } 65 | 66 | # ELB attachments 67 | number_of_instances = 1 68 | instances = [module.ec2_instance.id] 69 | } 70 | 71 | ################################################################################ 72 | # Supporting resources 73 | ################################################################################ 74 | 75 | module "vpc" { 76 | source = "terraform-aws-modules/vpc/aws" 77 | version = "~> 5.0" 78 | 79 | name = local.name 80 | cidr = local.vpc_cidr 81 | 82 | azs = local.azs 83 | private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 4, k)] 84 | public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 48)] 85 | 86 | tags = local.tags 87 | } 88 | 89 | module "ec2_instance" { 90 | source = "terraform-aws-modules/ec2-instance/aws" 91 | 92 | name = local.name 93 | 94 | instance_type = "t3.micro" 95 | vpc_security_group_ids = [module.vpc.default_security_group_id] 96 | subnet_id = element(module.vpc.private_subnets, 0) 97 | 98 | tags = local.tags 99 | } 100 | 101 | module "log_bucket" { 102 | source = "terraform-aws-modules/s3-bucket/aws" 103 | version = "~> 3.0" 104 | 105 | bucket_prefix = "${local.name}-logs-" 106 | acl = "log-delivery-write" 107 | 108 | # For example only 109 | force_destroy = true 110 | 111 | control_object_ownership = true 112 | object_ownership = "ObjectWriter" 113 | 114 | attach_elb_log_delivery_policy = true 115 | attach_lb_log_delivery_policy = true 116 | 117 | attach_deny_insecure_transport_policy = true 118 | attach_require_latest_tls_policy = true 119 | 120 | tags = local.tags 121 | } 122 | -------------------------------------------------------------------------------- /examples/complete/outputs.tf: -------------------------------------------------------------------------------- 1 | output "elb_id" { 2 | description = "The name of the ELB" 3 | value = module.elb.elb_id 4 | } 5 | 6 | output "elb_name" { 7 | description = "The name of the ELB" 8 | value = module.elb.elb_name 9 | } 10 | 11 | output "elb_dns_name" { 12 | description = "The DNS name of the ELB" 13 | value = module.elb.elb_dns_name 14 | } 15 | 16 | output "elb_instances" { 17 | description = "The list of instances in the ELB (if may be outdated, because instances are attached using elb_attachment resource)" 18 | value = module.elb.elb_instances 19 | } 20 | 21 | output "elb_source_security_group_id" { 22 | description = "The ID of the security group that you can use as part of your inbound rules for your load balancer's back-end application instances" 23 | value = module.elb.elb_source_security_group_id 24 | } 25 | 26 | output "elb_zone_id" { 27 | description = "The canonical hosted zone ID of the ELB (to be used in a Route 53 Alias record)" 28 | value = module.elb.elb_zone_id 29 | } 30 | -------------------------------------------------------------------------------- /examples/complete/variables.tf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/terraform-aws-modules/terraform-aws-elb/b12738a46921ce86408892229cf6f044b0b35d11/examples/complete/variables.tf -------------------------------------------------------------------------------- /examples/complete/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 4.0" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /main.tf: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Classic Load Balancer 3 | ################################################################################ 4 | 5 | module "elb" { 6 | source = "./modules/elb" 7 | 8 | create_elb = var.create_elb 9 | 10 | name = var.name 11 | name_prefix = var.name_prefix 12 | 13 | subnets = var.subnets 14 | security_groups = var.security_groups 15 | internal = var.internal 16 | 17 | cross_zone_load_balancing = var.cross_zone_load_balancing 18 | idle_timeout = var.idle_timeout 19 | connection_draining = var.connection_draining 20 | connection_draining_timeout = var.connection_draining_timeout 21 | 22 | listener = var.listener 23 | access_logs = var.access_logs 24 | health_check = var.health_check 25 | 26 | tags = merge( 27 | var.tags, 28 | { "Name" = var.name }, 29 | ) 30 | } 31 | 32 | ################################################################################ 33 | # Classic Load Balancer Attachment 34 | ################################################################################ 35 | 36 | module "elb_attachment" { 37 | source = "./modules/elb_attachment" 38 | 39 | create_attachment = var.create_elb 40 | 41 | number_of_instances = var.number_of_instances 42 | 43 | elb = module.elb.elb_id 44 | instances = var.instances 45 | } 46 | -------------------------------------------------------------------------------- /modules/elb/README.md: -------------------------------------------------------------------------------- 1 | # aws_elb 2 | 3 | 4 | ## Requirements 5 | 6 | | Name | Version | 7 | |------|---------| 8 | | [terraform](#requirement\_terraform) | >= 1.0 | 9 | | [aws](#requirement\_aws) | >= 4.0 | 10 | 11 | ## Providers 12 | 13 | | Name | Version | 14 | |------|---------| 15 | | [aws](#provider\_aws) | >= 4.0 | 16 | 17 | ## Modules 18 | 19 | No modules. 20 | 21 | ## Resources 22 | 23 | | Name | Type | 24 | |------|------| 25 | | [aws_elb.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elb) | resource | 26 | 27 | ## Inputs 28 | 29 | | Name | Description | Type | Default | Required | 30 | |------|-------------|------|---------|:--------:| 31 | | [access\_logs](#input\_access\_logs) | An access logs block | `map(string)` | `{}` | no | 32 | | [connection\_draining](#input\_connection\_draining) | Boolean to enable connection draining | `bool` | `false` | no | 33 | | [connection\_draining\_timeout](#input\_connection\_draining\_timeout) | The time in seconds to allow for connections to drain | `number` | `300` | no | 34 | | [create\_elb](#input\_create\_elb) | Create the elb or not | `bool` | `true` | no | 35 | | [cross\_zone\_load\_balancing](#input\_cross\_zone\_load\_balancing) | Enable cross-zone load balancing | `bool` | `true` | no | 36 | | [health\_check](#input\_health\_check) | A health check block | `map(string)` | n/a | yes | 37 | | [idle\_timeout](#input\_idle\_timeout) | The time in seconds that the connection is allowed to be idle | `number` | `60` | no | 38 | | [internal](#input\_internal) | If true, ELB will be an internal ELB | `bool` | n/a | yes | 39 | | [listener](#input\_listener) | A list of listener blocks | `list(map(string))` | n/a | yes | 40 | | [name](#input\_name) | The name of the ELB | `string` | `null` | no | 41 | | [name\_prefix](#input\_name\_prefix) | The prefix name of the ELB | `string` | `null` | no | 42 | | [security\_groups](#input\_security\_groups) | A list of security group IDs to assign to the ELB | `list(string)` | n/a | yes | 43 | | [subnets](#input\_subnets) | A list of subnet IDs to attach to the ELB | `list(string)` | n/a | yes | 44 | | [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)` | `{}` | no | 45 | 46 | ## Outputs 47 | 48 | | Name | Description | 49 | |------|-------------| 50 | | [elb\_arn](#output\_elb\_arn) | The ARN of the ELB | 51 | | [elb\_dns\_name](#output\_elb\_dns\_name) | The DNS name of the ELB | 52 | | [elb\_id](#output\_elb\_id) | The name of the ELB | 53 | | [elb\_instances](#output\_elb\_instances) | The list of instances in the ELB | 54 | | [elb\_name](#output\_elb\_name) | The name of the ELB | 55 | | [elb\_source\_security\_group](#output\_elb\_source\_security\_group) | The name of the security group that you can use as part of your inbound rules for your load balancer's back-end application instances. Use this for Classic or Default VPC only. | 56 | | [elb\_source\_security\_group\_id](#output\_elb\_source\_security\_group\_id) | The ID of the security group that you can use as part of your inbound rules for your load balancer's back-end application instances. Only available on ELBs launched in a VPC. | 57 | | [elb\_zone\_id](#output\_elb\_zone\_id) | The canonical hosted zone ID of the ELB (to be used in a Route 53 Alias record) | 58 | 59 | -------------------------------------------------------------------------------- /modules/elb/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_elb" "this" { 2 | count = var.create_elb ? 1 : 0 3 | 4 | name = var.name 5 | name_prefix = var.name_prefix 6 | 7 | subnets = var.subnets 8 | internal = var.internal 9 | security_groups = var.security_groups 10 | 11 | cross_zone_load_balancing = var.cross_zone_load_balancing 12 | idle_timeout = var.idle_timeout 13 | connection_draining = var.connection_draining 14 | connection_draining_timeout = var.connection_draining_timeout 15 | 16 | dynamic "listener" { 17 | for_each = var.listener 18 | content { 19 | instance_port = listener.value.instance_port 20 | instance_protocol = listener.value.instance_protocol 21 | lb_port = listener.value.lb_port 22 | lb_protocol = listener.value.lb_protocol 23 | ssl_certificate_id = lookup(listener.value, "ssl_certificate_id", null) 24 | } 25 | } 26 | 27 | dynamic "access_logs" { 28 | for_each = length(keys(var.access_logs)) == 0 ? [] : [var.access_logs] 29 | content { 30 | bucket = access_logs.value.bucket 31 | bucket_prefix = lookup(access_logs.value, "bucket_prefix", null) 32 | interval = lookup(access_logs.value, "interval", null) 33 | enabled = lookup(access_logs.value, "enabled", true) 34 | } 35 | } 36 | 37 | health_check { 38 | healthy_threshold = lookup(var.health_check, "healthy_threshold") 39 | unhealthy_threshold = lookup(var.health_check, "unhealthy_threshold") 40 | target = lookup(var.health_check, "target") 41 | interval = lookup(var.health_check, "interval") 42 | timeout = lookup(var.health_check, "timeout") 43 | } 44 | 45 | tags = merge( 46 | var.tags, 47 | { 48 | "Name" = format("%s", var.name) 49 | }, 50 | ) 51 | } 52 | -------------------------------------------------------------------------------- /modules/elb/outputs.tf: -------------------------------------------------------------------------------- 1 | output "elb_id" { 2 | description = "The name of the ELB" 3 | value = try(aws_elb.this[0].id, "") 4 | } 5 | 6 | output "elb_arn" { 7 | description = "The ARN of the ELB" 8 | value = try(aws_elb.this[0].arn, "") 9 | } 10 | 11 | output "elb_name" { 12 | description = "The name of the ELB" 13 | value = try(aws_elb.this[0].name, "") 14 | } 15 | 16 | output "elb_dns_name" { 17 | description = "The DNS name of the ELB" 18 | value = try(aws_elb.this[0].dns_name, "") 19 | } 20 | 21 | output "elb_instances" { 22 | description = "The list of instances in the ELB" 23 | value = flatten(aws_elb.this[*].instances) 24 | } 25 | 26 | output "elb_source_security_group" { 27 | description = "The name of the security group that you can use as part of your inbound rules for your load balancer's back-end application instances. Use this for Classic or Default VPC only." 28 | value = try(aws_elb.this[0].source_security_group, "") 29 | } 30 | 31 | output "elb_source_security_group_id" { 32 | description = "The ID of the security group that you can use as part of your inbound rules for your load balancer's back-end application instances. Only available on ELBs launched in a VPC." 33 | value = try(aws_elb.this[0].source_security_group_id, "") 34 | } 35 | 36 | output "elb_zone_id" { 37 | description = "The canonical hosted zone ID of the ELB (to be used in a Route 53 Alias record)" 38 | value = try(aws_elb.this[0].zone_id, "") 39 | } 40 | -------------------------------------------------------------------------------- /modules/elb/variables.tf: -------------------------------------------------------------------------------- 1 | variable "create_elb" { 2 | description = "Create the elb or not" 3 | type = bool 4 | default = true 5 | } 6 | 7 | variable "name" { 8 | description = "The name of the ELB" 9 | type = string 10 | default = null 11 | } 12 | 13 | variable "name_prefix" { 14 | description = "The prefix name of the ELB" 15 | type = string 16 | default = null 17 | } 18 | 19 | variable "security_groups" { 20 | description = "A list of security group IDs to assign to the ELB" 21 | type = list(string) 22 | } 23 | 24 | variable "subnets" { 25 | description = "A list of subnet IDs to attach to the ELB" 26 | type = list(string) 27 | } 28 | 29 | variable "internal" { 30 | description = "If true, ELB will be an internal ELB" 31 | type = bool 32 | } 33 | 34 | variable "cross_zone_load_balancing" { 35 | description = "Enable cross-zone load balancing" 36 | type = bool 37 | default = true 38 | } 39 | 40 | variable "idle_timeout" { 41 | description = "The time in seconds that the connection is allowed to be idle" 42 | type = number 43 | default = 60 44 | } 45 | 46 | variable "connection_draining" { 47 | description = "Boolean to enable connection draining" 48 | type = bool 49 | default = false 50 | } 51 | 52 | variable "connection_draining_timeout" { 53 | description = "The time in seconds to allow for connections to drain" 54 | type = number 55 | default = 300 56 | } 57 | 58 | variable "tags" { 59 | description = "A mapping of tags to assign to the resource" 60 | type = map(string) 61 | default = {} 62 | } 63 | 64 | variable "listener" { 65 | description = "A list of listener blocks" 66 | type = list(map(string)) 67 | } 68 | 69 | variable "access_logs" { 70 | description = "An access logs block" 71 | type = map(string) 72 | default = {} 73 | } 74 | 75 | variable "health_check" { 76 | description = "A health check block" 77 | type = map(string) 78 | } 79 | -------------------------------------------------------------------------------- /modules/elb/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 4.0" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /modules/elb_attachment/README.md: -------------------------------------------------------------------------------- 1 | # aws_elb_attachment 2 | 3 | 4 | ## Requirements 5 | 6 | | Name | Version | 7 | |------|---------| 8 | | [terraform](#requirement\_terraform) | >= 1.0 | 9 | | [aws](#requirement\_aws) | >= 4.0 | 10 | 11 | ## Providers 12 | 13 | | Name | Version | 14 | |------|---------| 15 | | [aws](#provider\_aws) | >= 4.0 | 16 | 17 | ## Modules 18 | 19 | No modules. 20 | 21 | ## Resources 22 | 23 | | Name | Type | 24 | |------|------| 25 | | [aws_elb_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elb_attachment) | resource | 26 | 27 | ## Inputs 28 | 29 | | Name | Description | Type | Default | Required | 30 | |------|-------------|------|---------|:--------:| 31 | | [create\_attachment](#input\_create\_attachment) | Create the elb attachment or not | `bool` | `true` | no | 32 | | [elb](#input\_elb) | The name of the ELB | `string` | n/a | yes | 33 | | [instances](#input\_instances) | List of instances ID to place in the ELB pool | `list(string)` | n/a | yes | 34 | | [number\_of\_instances](#input\_number\_of\_instances) | Number of instances ID to place in the ELB pool | `number` | n/a | yes | 35 | 36 | ## Outputs 37 | 38 | No outputs. 39 | 40 | -------------------------------------------------------------------------------- /modules/elb_attachment/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_elb_attachment" "this" { 2 | count = var.create_attachment ? var.number_of_instances : 0 3 | 4 | elb = var.elb 5 | instance = element(var.instances, count.index) 6 | } 7 | -------------------------------------------------------------------------------- /modules/elb_attachment/outputs.tf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/terraform-aws-modules/terraform-aws-elb/b12738a46921ce86408892229cf6f044b0b35d11/modules/elb_attachment/outputs.tf -------------------------------------------------------------------------------- /modules/elb_attachment/variables.tf: -------------------------------------------------------------------------------- 1 | variable "create_attachment" { 2 | description = "Create the elb attachment or not" 3 | type = bool 4 | default = true 5 | } 6 | 7 | variable "number_of_instances" { 8 | description = "Number of instances ID to place in the ELB pool" 9 | type = number 10 | } 11 | 12 | variable "elb" { 13 | description = "The name of the ELB" 14 | type = string 15 | } 16 | 17 | variable "instances" { 18 | description = "List of instances ID to place in the ELB pool" 19 | type = list(string) 20 | } 21 | -------------------------------------------------------------------------------- /modules/elb_attachment/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 4.0" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /outputs.tf: -------------------------------------------------------------------------------- 1 | output "elb_id" { 2 | description = "The name of the ELB" 3 | value = module.elb.elb_id 4 | } 5 | 6 | output "elb_arn" { 7 | description = "The ARN of the ELB" 8 | value = module.elb.elb_arn 9 | } 10 | 11 | output "elb_name" { 12 | description = "The name of the ELB" 13 | value = module.elb.elb_name 14 | } 15 | 16 | output "elb_dns_name" { 17 | description = "The DNS name of the ELB" 18 | value = module.elb.elb_dns_name 19 | } 20 | 21 | output "elb_instances" { 22 | description = "The list of instances in the ELB" 23 | value = module.elb.elb_instances 24 | } 25 | 26 | output "elb_source_security_group_id" { 27 | description = "The ID of the security group that you can use as part of your inbound rules for your load balancer's back-end application instances" 28 | value = module.elb.elb_source_security_group_id 29 | } 30 | 31 | output "elb_zone_id" { 32 | description = "The canonical hosted zone ID of the ELB (to be used in a Route 53 Alias record)" 33 | value = module.elb.elb_zone_id 34 | } 35 | -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | variable "name" { 2 | description = "The name of the ELB" 3 | type = string 4 | default = null 5 | } 6 | 7 | variable "name_prefix" { 8 | description = "The prefix name of the ELB" 9 | type = string 10 | default = null 11 | } 12 | 13 | variable "security_groups" { 14 | description = "A list of security group IDs to assign to the ELB" 15 | type = list(string) 16 | } 17 | 18 | variable "subnets" { 19 | description = "A list of subnet IDs to attach to the ELB" 20 | type = list(string) 21 | } 22 | 23 | variable "internal" { 24 | description = "If true, ELB will be an internal ELB" 25 | type = bool 26 | default = false 27 | } 28 | 29 | variable "cross_zone_load_balancing" { 30 | description = "Enable cross-zone load balancing" 31 | type = bool 32 | default = true 33 | } 34 | 35 | variable "idle_timeout" { 36 | description = "The time in seconds that the connection is allowed to be idle" 37 | type = number 38 | default = 60 39 | } 40 | 41 | variable "connection_draining" { 42 | description = "Boolean to enable connection draining" 43 | type = bool 44 | default = false 45 | } 46 | 47 | variable "connection_draining_timeout" { 48 | description = "The time in seconds to allow for connections to drain" 49 | type = number 50 | default = 300 51 | } 52 | 53 | variable "tags" { 54 | description = "A mapping of tags to assign to the resource" 55 | type = map(string) 56 | default = {} 57 | } 58 | 59 | variable "listener" { 60 | description = "A list of listener blocks" 61 | type = list(map(string)) 62 | } 63 | 64 | variable "access_logs" { 65 | description = "An access logs block" 66 | type = map(string) 67 | default = {} 68 | } 69 | 70 | variable "health_check" { 71 | description = "A health check block" 72 | type = map(string) 73 | } 74 | 75 | variable "number_of_instances" { 76 | description = "Number of instances to attach to ELB" 77 | type = number 78 | default = 0 79 | } 80 | 81 | variable "instances" { 82 | description = "List of instances ID to place in the ELB pool" 83 | type = list(string) 84 | default = [] 85 | } 86 | 87 | variable "create_elb" { 88 | description = "Create the elb or not" 89 | type = bool 90 | default = true 91 | } 92 | -------------------------------------------------------------------------------- /versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | } 4 | --------------------------------------------------------------------------------