├── .github ├── FUNDING.yml ├── renovate.json └── workflows │ └── pipeline.yml ├── .gitignore ├── .pre-commit-config.yaml ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── examples ├── basic │ ├── main.tf │ └── mock_provider.tf ├── log-configuration-cw │ ├── main.tf │ └── mock_provider.tf ├── log-configuration-s3 │ ├── main.tf │ └── mock_provider.tf ├── service-connect-defaults │ ├── main.tf │ └── mock_provider.tf └── setting-container-insights │ ├── main.tf │ └── mock_provider.tf ├── main.tf ├── outputs.tf ├── variables.tf └── versions.tf /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: jnonino 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "labels": ["enhancement"] 6 | } 7 | -------------------------------------------------------------------------------- /.github/workflows/pipeline.yml: -------------------------------------------------------------------------------- 1 | name: Terraform 2 | on: 3 | push: 4 | branches: [main] 5 | pull_request: 6 | types: [opened, reopened, synchronize] 7 | branches: [main] 8 | release: 9 | types: [published] 10 | 11 | env: 12 | DEFAULT_REGION: us-east-1 13 | AWS_ACCESS_KEY_ID: localstack 14 | AWS_SECRET_ACCESS_KEY: localstack 15 | 16 | jobs: 17 | check-format: 18 | runs-on: ubuntu-latest 19 | container: hashicorp/terraform 20 | steps: 21 | - name: Checkout repository 22 | uses: actions/checkout@v4 23 | - name: Terraform Format Check 24 | run: terraform fmt -check -recursive -diff 25 | 26 | validations: 27 | runs-on: ubuntu-latest 28 | container: hashicorp/terraform 29 | strategy: 30 | matrix: { 31 | dir: [ 32 | 'examples/basic', 33 | 'examples/log-configuration-cw', 34 | 'examples/log-configuration-s3', 35 | 'examples/setting-container-insights', 36 | 'examples/service-connect-defaults' 37 | ] 38 | } 39 | services: 40 | localstack: 41 | image: localstack/localstack 42 | env: 43 | SERVICES: apigateway,cloudformation,cloudwatch,dynamodb,es,firehose,iam,kinesis,lambda,route53,redshift,s3,secretsmanager,ses,sns,sqs,ssm,stepfunctions,sts 44 | ports: 45 | - 4566:4566 46 | steps: 47 | - name: Checkout repository 48 | uses: actions/checkout@v4 49 | - name: Terraform Init 50 | run: terraform init -upgrade 51 | working-directory: ${{ matrix.dir }} 52 | - name: Terraform Validate 53 | run: terraform validate 54 | working-directory: ${{ matrix.dir }} 55 | - name: Terraform Plan (Mock) 56 | run: terraform plan 57 | working-directory: ${{ matrix.dir }} 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .terraform.lock.hcl 2 | 3 | # Created by https://www.toptal.com/developers/gitignore/api/linux,macos,windows,terraform,sublimetext,visualstudiocode 4 | # Edit at https://www.toptal.com/developers/gitignore?templates=linux,macos,windows,terraform,sublimetext,visualstudiocode 5 | 6 | ### Linux ### 7 | *~ 8 | 9 | # temporary files which can be created if a process still has a handle open of a deleted file 10 | .fuse_hidden* 11 | 12 | # KDE directory preferences 13 | .directory 14 | 15 | # Linux trash folder which might appear on any partition or disk 16 | .Trash-* 17 | 18 | # .nfs files are created when an open file is removed but is still being accessed 19 | .nfs* 20 | 21 | ### macOS ### 22 | # General 23 | .DS_Store 24 | .AppleDouble 25 | .LSOverride 26 | 27 | # Icon must end with two \r 28 | Icon 29 | 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | .com.apple.timemachine.donotpresent 42 | 43 | # Directories potentially created on remote AFP share 44 | .AppleDB 45 | .AppleDesktop 46 | Network Trash Folder 47 | Temporary Items 48 | .apdisk 49 | 50 | ### macOS Patch ### 51 | # iCloud generated files 52 | *.icloud 53 | 54 | ### SublimeText ### 55 | # Cache files for Sublime Text 56 | *.tmlanguage.cache 57 | *.tmPreferences.cache 58 | *.stTheme.cache 59 | 60 | # Workspace files are user-specific 61 | *.sublime-workspace 62 | 63 | # Project files should be checked into the repository, unless a significant 64 | # proportion of contributors will probably not be using Sublime Text 65 | # *.sublime-project 66 | 67 | # SFTP configuration file 68 | sftp-config.json 69 | sftp-config-alt*.json 70 | 71 | # Package control specific files 72 | Package Control.last-run 73 | Package Control.ca-list 74 | Package Control.ca-bundle 75 | Package Control.system-ca-bundle 76 | Package Control.cache/ 77 | Package Control.ca-certs/ 78 | Package Control.merged-ca-bundle 79 | Package Control.user-ca-bundle 80 | oscrypto-ca-bundle.crt 81 | bh_unicode_properties.cache 82 | 83 | # Sublime-github package stores a github token in this file 84 | # https://packagecontrol.io/packages/sublime-github 85 | GitHub.sublime-settings 86 | 87 | ### Terraform ### 88 | # Local .terraform directories 89 | **/.terraform/* 90 | 91 | # .tfstate files 92 | *.tfstate 93 | *.tfstate.* 94 | 95 | # Crash log files 96 | crash.log 97 | crash.*.log 98 | 99 | # Exclude all .tfvars files, which are likely to contain sensitive data, such as 100 | # password, private keys, and other secrets. These should not be part of version 101 | # control as they are data points which are potentially sensitive and subject 102 | # to change depending on the environment. 103 | *.tfvars 104 | *.tfvars.json 105 | 106 | # Ignore override files as they are usually used to override resources locally and so 107 | # are not checked in 108 | override.tf 109 | override.tf.json 110 | *_override.tf 111 | *_override.tf.json 112 | 113 | # Include override files you do wish to add to version control using negated pattern 114 | # !example_override.tf 115 | 116 | # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan 117 | # example: *tfplan* 118 | 119 | # Ignore CLI configuration files 120 | .terraformrc 121 | terraform.rc 122 | 123 | ### VisualStudioCode ### 124 | .vscode/* 125 | !.vscode/settings.json 126 | !.vscode/tasks.json 127 | !.vscode/launch.json 128 | !.vscode/extensions.json 129 | !.vscode/*.code-snippets 130 | 131 | # Local History for Visual Studio Code 132 | .history/ 133 | 134 | # Built Visual Studio Code Extensions 135 | *.vsix 136 | 137 | ### VisualStudioCode Patch ### 138 | # Ignore all local history of files 139 | .history 140 | .ionide 141 | 142 | ### Windows ### 143 | # Windows thumbnail cache files 144 | Thumbs.db 145 | Thumbs.db:encryptable 146 | ehthumbs.db 147 | ehthumbs_vista.db 148 | 149 | # Dump file 150 | *.stackdump 151 | 152 | # Folder config file 153 | [Dd]esktop.ini 154 | 155 | # Recycle Bin used on file shares 156 | $RECYCLE.BIN/ 157 | 158 | # Windows Installer files 159 | *.cab 160 | *.msi 161 | *.msix 162 | *.msm 163 | *.msp 164 | 165 | # Windows shortcuts 166 | *.lnk 167 | 168 | # End of https://www.toptal.com/developers/gitignore/api/linux,macos,windows,terraform,sublimetext,visualstudiocode 169 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/antonbabenko/pre-commit-terraform 3 | rev: v1.71.0 4 | hooks: 5 | - id: terraform_docs 6 | - id: terraform_fmt 7 | - id: terraform_validate 8 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Citizen Code of Conduct 2 | 3 | ## 1. Purpose 4 | 5 | A primary goal of Terraform AWS ECS Cluster is to be inclusive to the largest number of contributors, with the most varied and diverse backgrounds possible. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof). 6 | 7 | This code of conduct outlines our expectations for all those who participate in our community, as well as the consequences for unacceptable behavior. 8 | 9 | We invite all those who participate in Terraform AWS ECS Cluster to help us create safe and positive experiences for everyone. 10 | 11 | ## 2. Open [Source/Culture/Tech] Citizenship 12 | 13 | A supplemental goal of this Code of Conduct is to increase open [source/culture/tech] citizenship by encouraging participants to recognize and strengthen the relationships between our actions and their effects on our community. 14 | 15 | Communities mirror the societies in which they exist and positive action is essential to counteract the many forms of inequality and abuses of power that exist in society. 16 | 17 | If you see someone who is making an extra effort to ensure our community is welcoming, friendly, and encourages all participants to contribute to the fullest extent, we want to know. 18 | 19 | ## 3. Expected Behavior 20 | 21 | The following behaviors are expected and requested of all community members: 22 | 23 | * Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community. 24 | * Exercise consideration and respect in your speech and actions. 25 | * Attempt collaboration before conflict. 26 | * Refrain from demeaning, discriminatory, or harassing behavior and speech. 27 | * Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential. 28 | * Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations. 29 | 30 | ## 4. Unacceptable Behavior 31 | 32 | The following behaviors are considered harassment and are unacceptable within our community: 33 | 34 | * Violence, threats of violence or violent language directed against another person. 35 | * Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language. 36 | * Posting or displaying sexually explicit or violent material. 37 | * Posting or threatening to post other people's personally identifying information ("doxing"). 38 | * Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability. 39 | * Inappropriate photography or recording. 40 | * Inappropriate physical contact. You should have someone's consent before touching them. 41 | * Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances. 42 | * Deliberate intimidation, stalking or following (online or in person). 43 | * Advocating for, or encouraging, any of the above behavior. 44 | * Sustained disruption of community events, including talks and presentations. 45 | 46 | ## 5. Weapons Policy 47 | 48 | No weapons will be allowed at Terraform AWS ECS Cluster events, community spaces, or in other spaces covered by the scope of this Code of Conduct. Weapons include but are not limited to guns, explosives (including fireworks), and large knives such as those used for hunting or display, as well as any other item used for the purpose of causing injury or harm to others. Anyone seen in possession of one of these items will be asked to leave immediately, and will only be allowed to return without the weapon. Community members are further expected to comply with all state and local laws on this matter. 49 | 50 | ## 6. Consequences of Unacceptable Behavior 51 | 52 | Unacceptable behavior from any community member, including sponsors and those with decision-making authority, will not be tolerated. 53 | 54 | Anyone asked to stop unacceptable behavior is expected to comply immediately. 55 | 56 | If a community member engages in unacceptable behavior, the community organizers may take any action they deem appropriate, up to and including a temporary ban or permanent expulsion from the community without warning (and without refund in the case of a paid event). 57 | 58 | ## 7. Reporting Guidelines 59 | 60 | If you are subject to or witness unacceptable behavior, or have any other concerns, please notify a community organizer as soon as possible. noninojulian@gmail.com. 61 | 62 | 63 | 64 | Additionally, community organizers are available to help community members engage with local law enforcement or to otherwise help those experiencing unacceptable behavior feel safe. In the context of in-person events, organizers will also provide escorts as desired by the person experiencing distress. 65 | 66 | ## 8. Addressing Grievances 67 | 68 | If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify CN Services with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies. 69 | 70 | 71 | 72 | ## 9. Scope 73 | 74 | We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by this Code of Conduct in all community venues--online and in-person--as well as in all one-on-one communications pertaining to community business. 75 | 76 | This code of conduct and its related procedures also applies to unacceptable behavior occurring outside the scope of community activities when such behavior has the potential to adversely affect the safety and well-being of community members. 77 | 78 | ## 10. Contact info 79 | 80 | noninojulian@gmail.com 81 | 82 | ## 11. License and attribution 83 | 84 | The Citizen Code of Conduct is distributed by [Stumptown Syndicate](http://stumptownsyndicate.org) under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/). 85 | 86 | Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy). 87 | 88 | _Revision 2.3. Posted 6 March 2017._ 89 | 90 | _Revision 2.2. Posted 4 February 2016._ 91 | 92 | _Revision 2.1. Posted 23 June 2014._ 93 | 94 | _Revision 2.0, adopted by the [Stumptown Syndicate](http://stumptownsyndicate.org) board on 10 January 2013. Posted 17 March 2013._ 95 | -------------------------------------------------------------------------------- /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 2019 Julian Nonino, Maria Florencia Caro 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AWS ECS Cluster Terraform Module # 2 | 3 | This Terraform module creates an AWS ECS cluster. 4 | 5 | [![](https://github.com/cn-terraform/terraform-aws-ecs-cluster/workflows/terraform/badge.svg)](https://github.com/cn-terraform/terraform-aws-ecs-cluster/actions?query=workflow%3Aterraform) 6 | [![](https://img.shields.io/github/license/cn-terraform/terraform-aws-ecs-cluster)](https://github.com/cn-terraform/terraform-aws-ecs-cluster) 7 | [![](https://img.shields.io/github/issues/cn-terraform/terraform-aws-ecs-cluster)](https://github.com/cn-terraform/terraform-aws-ecs-cluster) 8 | [![](https://img.shields.io/github/issues-closed/cn-terraform/terraform-aws-ecs-cluster)](https://github.com/cn-terraform/terraform-aws-ecs-cluster) 9 | [![](https://img.shields.io/github/languages/code-size/cn-terraform/terraform-aws-ecs-cluster)](https://github.com/cn-terraform/terraform-aws-ecs-cluster) 10 | [![](https://img.shields.io/github/repo-size/cn-terraform/terraform-aws-ecs-cluster)](https://github.com/cn-terraform/terraform-aws-ecs-cluster) 11 | 12 | ## Usage 13 | 14 | Check valid versions on: 15 | * Github Releases: 16 | * Terraform Module Registry: 17 | 18 | ## Install pre commit hooks. 19 | 20 | Pleas run this command right after cloning the repository. 21 | 22 | pre-commit install 23 | 24 | For that you may need to install the folowwing tools: 25 | * [Pre-commit](https://pre-commit.com/) 26 | * [Terraform Docs](https://terraform-docs.io/) 27 | 28 | In order to run all checks at any point run the following command: 29 | 30 | pre-commit run --all-files 31 | 32 | 33 | ## Requirements 34 | 35 | | Name | Version | 36 | |------|---------| 37 | | [terraform](#requirement\_terraform) | >= 0.13 | 38 | | [aws](#requirement\_aws) | >= 4 | 39 | 40 | ## Providers 41 | 42 | | Name | Version | 43 | |------|---------| 44 | | [aws](#provider\_aws) | 5.15.0 | 45 | 46 | ## Modules 47 | 48 | No modules. 49 | 50 | ## Resources 51 | 52 | | Name | Type | 53 | |------|------| 54 | | [aws_ecs_cluster.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_cluster) | resource | 55 | 56 | ## Inputs 57 | 58 | | Name | Description | Type | Default | Required | 59 | |------|-------------|------|---------|:--------:| 60 | | [configuration](#input\_configuration) | (Optional) The execute command configuration for the cluster. |
object({
# The details of the execute command configuration.
execute_command_configuration = object({
# The AWS Key Management Service key ID to encrypt the data between the local client and the container.
kms_key_id = optional(string)
# The log configuration for the results of the execute command actions Required when logging is OVERRIDE.
log_configuration = object({
# Whether or not to enable encryption on the CloudWatch logs. If not specified, encryption will be disabled.
cloud_watch_encryption_enabled = optional(bool)
# The name of the CloudWatch log group to send logs to.
cloud_watch_log_group_name = optional(string)
# The name of the S3 bucket to send logs to.
s3_bucket_name = optional(string)
# Whether or not to enable encryption on the logs sent to S3. If not specified, encryption will be disabled.
s3_bucket_encryption_enabled = optional(bool)
# An optional folder in the S3 bucket to place logs in.
s3_key_prefix = optional(string)
})
# The log setting to use for redirecting logs for your execute command results. Valid values are NONE, DEFAULT, and OVERRIDE.
logging = optional(string)
})
})
| `null` | no | 61 | | [containerInsights](#input\_containerInsights) | (Optional) Enables container insights if true | `bool` | `false` | no | 62 | | [name](#input\_name) | (Required) Name of the cluster (up to 255 letters, numbers, hyphens, and underscores). | `any` | n/a | yes | 63 | | [service\_connect\_defaults](#input\_service\_connect\_defaults) | (Optional) Configures a default Service Connect namespace. |
object({
# The ARN of the aws_service_discovery_http_namespace that's used when you create a service and don't specify a Service Connect configuration.
namespace = string
})
| `null` | no | 64 | | [tags](#input\_tags) | Resource tags | `map(string)` | `{}` | no | 65 | 66 | ## Outputs 67 | 68 | | Name | Description | 69 | |------|-------------| 70 | | [aws\_ecs\_cluster\_cluster\_arn](#output\_aws\_ecs\_cluster\_cluster\_arn) | The Amazon Resource Name (ARN) that identifies the cluster | 71 | | [aws\_ecs\_cluster\_cluster\_id](#output\_aws\_ecs\_cluster\_cluster\_id) | The Amazon ID that identifies the cluster | 72 | | [aws\_ecs\_cluster\_cluster\_name](#output\_aws\_ecs\_cluster\_cluster\_name) | The name of the cluster | 73 | 74 | -------------------------------------------------------------------------------- /examples/basic/main.tf: -------------------------------------------------------------------------------- 1 | module "cluster" { 2 | source = "../../" 3 | name = "test-cluster" 4 | } 5 | -------------------------------------------------------------------------------- /examples/basic/mock_provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4" 7 | } 8 | } 9 | } 10 | 11 | provider "aws" { 12 | region = "us-east-1" 13 | skip_credentials_validation = true 14 | skip_requesting_account_id = true 15 | skip_metadata_api_check = true 16 | access_key = "mock_access_key" 17 | secret_key = "mock_secret_key" 18 | } 19 | -------------------------------------------------------------------------------- /examples/log-configuration-cw/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_kms_key" "example" { 2 | description = "example" 3 | deletion_window_in_days = 7 4 | } 5 | 6 | resource "aws_cloudwatch_log_group" "example" { 7 | name = "example" 8 | } 9 | 10 | module "cluster" { 11 | source = "../../" 12 | name = "test-cluster" 13 | 14 | configuration = { 15 | execute_command_configuration = { 16 | kms_key_id = aws_kms_key.example.arn 17 | logging = "OVERRIDE" 18 | 19 | log_configuration = { 20 | cloud_watch_encryption_enabled = true 21 | cloud_watch_log_group_name = aws_cloudwatch_log_group.example.name 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/log-configuration-cw/mock_provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4" 7 | } 8 | } 9 | } 10 | 11 | provider "aws" { 12 | region = "us-east-1" 13 | skip_credentials_validation = true 14 | skip_requesting_account_id = true 15 | skip_metadata_api_check = true 16 | access_key = "mock_access_key" 17 | secret_key = "mock_secret_key" 18 | } 19 | -------------------------------------------------------------------------------- /examples/log-configuration-s3/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_kms_key" "example" { 2 | description = "example" 3 | deletion_window_in_days = 7 4 | } 5 | 6 | resource "aws_s3_bucket" "example" { 7 | bucket = "my-tf-test-bucket" 8 | } 9 | 10 | module "cluster" { 11 | source = "../../" 12 | name = "test-cluster" 13 | 14 | configuration = { 15 | execute_command_configuration = { 16 | kms_key_id = aws_kms_key.example.arn 17 | logging = "OVERRIDE" 18 | 19 | log_configuration = { 20 | s3_bucket_name = aws_s3_bucket.example.bucket 21 | s3_bucket_encryption_enabled = true 22 | s3_key_prefix = "test-logs" 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/log-configuration-s3/mock_provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4" 7 | } 8 | } 9 | } 10 | 11 | provider "aws" { 12 | region = "us-east-1" 13 | skip_credentials_validation = true 14 | skip_requesting_account_id = true 15 | skip_metadata_api_check = true 16 | access_key = "mock_access_key" 17 | secret_key = "mock_secret_key" 18 | } 19 | -------------------------------------------------------------------------------- /examples/service-connect-defaults/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_service_discovery_http_namespace" "example" { 2 | name = "development" 3 | description = "example" 4 | } 5 | 6 | module "cluster" { 7 | source = "../../" 8 | name = "test-cluster" 9 | 10 | service_connect_defaults = { 11 | namespace = aws_service_discovery_http_namespace.example.arn 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/service-connect-defaults/mock_provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4" 7 | } 8 | } 9 | } 10 | 11 | provider "aws" { 12 | region = "us-east-1" 13 | skip_credentials_validation = true 14 | skip_requesting_account_id = true 15 | skip_metadata_api_check = true 16 | access_key = "mock_access_key" 17 | secret_key = "mock_secret_key" 18 | } 19 | -------------------------------------------------------------------------------- /examples/setting-container-insights/main.tf: -------------------------------------------------------------------------------- 1 | module "cluster" { 2 | source = "../../" 3 | name = "test-cluster" 4 | 5 | containerInsights = true 6 | } 7 | -------------------------------------------------------------------------------- /examples/setting-container-insights/mock_provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4" 7 | } 8 | } 9 | } 10 | 11 | provider "aws" { 12 | region = "us-east-1" 13 | skip_credentials_validation = true 14 | skip_requesting_account_id = true 15 | skip_metadata_api_check = true 16 | access_key = "mock_access_key" 17 | secret_key = "mock_secret_key" 18 | } 19 | -------------------------------------------------------------------------------- /main.tf: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # ECS CLUSTER 3 | #------------------------------------------------------------------------------ 4 | resource "aws_ecs_cluster" "cluster" { 5 | name = var.name 6 | tags = var.tags 7 | 8 | dynamic "configuration" { 9 | for_each = toset(var.configuration != null ? [var.configuration] : []) 10 | content { 11 | dynamic "execute_command_configuration" { 12 | for_each = [configuration.value.execute_command_configuration] 13 | content { 14 | kms_key_id = try(execute_command_configuration.value.kms_key_id, null) 15 | dynamic "log_configuration" { 16 | for_each = try([execute_command_configuration.value.log_configuration], []) 17 | content { 18 | cloud_watch_encryption_enabled = try(log_configuration.value.cloud_watch_encryption_enabled, null) 19 | cloud_watch_log_group_name = try(log_configuration.value.cloud_watch_log_group_name, null) 20 | s3_bucket_name = try(log_configuration.value.s3_bucket_name, null) 21 | s3_bucket_encryption_enabled = try(log_configuration.value.s3_bucket_encryption_enabled, null) 22 | s3_key_prefix = try(log_configuration.value.s3_key_prefix, null) 23 | } 24 | } 25 | logging = try(execute_command_configuration.value.logging, null) 26 | } 27 | } 28 | } 29 | } 30 | 31 | dynamic "service_connect_defaults" { 32 | for_each = toset(var.service_connect_defaults != null ? [var.service_connect_defaults] : []) 33 | content { 34 | namespace = service_connect_defaults.value.namespace 35 | } 36 | } 37 | 38 | dynamic "setting" { 39 | for_each = var.containerInsights == true ? [1] : [] 40 | content { 41 | name = "containerInsights" 42 | value = "enabled" 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /outputs.tf: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # ECS CLUSTER 3 | #------------------------------------------------------------------------------ 4 | output "aws_ecs_cluster_cluster_name" { 5 | description = "The name of the cluster" 6 | value = aws_ecs_cluster.cluster.name 7 | } 8 | 9 | output "aws_ecs_cluster_cluster_id" { 10 | description = "The Amazon ID that identifies the cluster" 11 | value = aws_ecs_cluster.cluster.id 12 | } 13 | 14 | output "aws_ecs_cluster_cluster_arn" { 15 | description = "The Amazon Resource Name (ARN) that identifies the cluster" 16 | value = aws_ecs_cluster.cluster.arn 17 | } 18 | 19 | -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # ECS CLUSTER 3 | #------------------------------------------------------------------------------ 4 | variable "name" { 5 | description = "(Required) Name of the cluster (up to 255 letters, numbers, hyphens, and underscores)." 6 | } 7 | 8 | variable "configuration" { 9 | description = "(Optional) The execute command configuration for the cluster." 10 | type = object({ 11 | # The details of the execute command configuration. 12 | execute_command_configuration = object({ 13 | # The AWS Key Management Service key ID to encrypt the data between the local client and the container. 14 | kms_key_id = optional(string) 15 | # The log configuration for the results of the execute command actions Required when logging is OVERRIDE. 16 | log_configuration = object({ 17 | # Whether or not to enable encryption on the CloudWatch logs. If not specified, encryption will be disabled. 18 | cloud_watch_encryption_enabled = optional(bool) 19 | # The name of the CloudWatch log group to send logs to. 20 | cloud_watch_log_group_name = optional(string) 21 | # The name of the S3 bucket to send logs to. 22 | s3_bucket_name = optional(string) 23 | # Whether or not to enable encryption on the logs sent to S3. If not specified, encryption will be disabled. 24 | s3_bucket_encryption_enabled = optional(bool) 25 | # An optional folder in the S3 bucket to place logs in. 26 | s3_key_prefix = optional(string) 27 | }) 28 | # The log setting to use for redirecting logs for your execute command results. Valid values are NONE, DEFAULT, and OVERRIDE. 29 | logging = optional(string) 30 | }) 31 | }) 32 | default = null 33 | } 34 | 35 | variable "containerInsights" { 36 | description = "(Optional) Enables container insights if true" 37 | type = bool 38 | default = false 39 | } 40 | 41 | variable "service_connect_defaults" { 42 | description = "(Optional) Configures a default Service Connect namespace." 43 | type = object({ 44 | # The ARN of the aws_service_discovery_http_namespace that's used when you create a service and don't specify a Service Connect configuration. 45 | namespace = string 46 | }) 47 | default = null 48 | } 49 | 50 | variable "tags" { 51 | type = map(string) 52 | default = {} 53 | description = "Resource tags" 54 | } 55 | -------------------------------------------------------------------------------- /versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4" 7 | } 8 | } 9 | } 10 | --------------------------------------------------------------------------------