├── .github ├── FUNDING.yml ├── renovate.json └── workflows │ └── pipeline.yml ├── .gitignore ├── .pre-commit-config.yaml ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── examples └── test │ ├── 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: ['examples/test'] 32 | } 33 | services: 34 | localstack: 35 | image: localstack/localstack 36 | env: 37 | SERVICES: apigateway,cloudformation,cloudwatch,dynamodb,es,firehose,iam,kinesis,lambda,route53,redshift,s3,secretsmanager,ses,sns,sqs,ssm,stepfunctions,sts 38 | ports: 39 | - 4566:4566 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v4 43 | - name: Terraform Init 44 | run: terraform init -upgrade 45 | working-directory: ${{ matrix.dir }} 46 | - name: Terraform Validate 47 | run: terraform validate 48 | working-directory: ${{ matrix.dir }} 49 | - name: Terraform Plan (Mock) 50 | run: terraform plan 51 | working-directory: ${{ matrix.dir }} 52 | -------------------------------------------------------------------------------- /.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 Fargate Scheduled Task 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 Fargate Scheduled Task 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 Fargate Scheduled Task 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 Fargate Scheduled Task Terraform Module # 2 | 3 | This Terraform module deploys an AWS ECS Fargate scheduled task service. 4 | 5 | [![](https://github.com/cn-terraform/terraform-aws-ecs-fargate-scheduled-task/workflows/terraform/badge.svg)](https://github.com/cn-terraform/terraform-aws-ecs-fargate-scheduled-task/actions?query=workflow%3Aterraform) 6 | [![](https://img.shields.io/github/license/cn-terraform/terraform-aws-ecs-fargate-scheduled-task)](https://github.com/cn-terraform/terraform-aws-ecs-fargate-scheduled-task) 7 | [![](https://img.shields.io/github/issues/cn-terraform/terraform-aws-ecs-fargate-scheduled-task)](https://github.com/cn-terraform/terraform-aws-ecs-fargate-scheduled-task) 8 | [![](https://img.shields.io/github/issues-closed/cn-terraform/terraform-aws-ecs-fargate-scheduled-task)](https://github.com/cn-terraform/terraform-aws-ecs-fargate-scheduled-task) 9 | [![](https://img.shields.io/github/languages/code-size/cn-terraform/terraform-aws-ecs-fargate-scheduled-task)](https://github.com/cn-terraform/terraform-aws-ecs-fargate-scheduled-task) 10 | [![](https://img.shields.io/github/repo-size/cn-terraform/terraform-aws-ecs-fargate-scheduled-task)](https://github.com/cn-terraform/terraform-aws-ecs-fargate-scheduled-task) 11 | 12 | ## Usage 13 | 14 | Check versions for this module on: 15 | * Github Releases: 16 | * Terraform Module Registry: 17 | 18 | ## Other modules that you may need to use this module 19 | 20 | The Networking module: 21 | * Github Releases: 22 | * Terraform Module Registry: 23 | 24 | The ECS Cluster module: 25 | * Github Releases: 26 | * Terraform Module Registry: 27 | 28 | The ECS Task Definition module: 29 | * Github Releases: 30 | * Terraform Module Registry: 31 | 32 | ## Install pre commit hooks. 33 | 34 | Pleas run this command right after cloning the repository. 35 | 36 | pre-commit install 37 | 38 | For that you may need to install the following tools: 39 | * [Pre-commit](https://pre-commit.com/) 40 | * [Terraform Docs](https://terraform-docs.io/) 41 | 42 | In order to run all checks at any point run the following command: 43 | 44 | pre-commit run --all-files 45 | 46 | 47 | ## Requirements 48 | 49 | | Name | Version | 50 | |------|---------| 51 | | [terraform](#requirement\_terraform) | >= 0.13 | 52 | | [aws](#requirement\_aws) | >= 4 | 53 | | [local](#requirement\_local) | >= 2 | 54 | 55 | ## Providers 56 | 57 | | Name | Version | 58 | |------|---------| 59 | | [aws](#provider\_aws) | 5.41.0 | 60 | 61 | ## Modules 62 | 63 | No modules. 64 | 65 | ## Resources 66 | 67 | | Name | Type | 68 | |------|------| 69 | | [aws_cloudwatch_event_rule.event_rule](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource | 70 | | [aws_cloudwatch_event_target.ecs_scheduled_task](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_target) | resource | 71 | | [aws_iam_role.scheduled_task_cw_event_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | 72 | | [aws_iam_role_policy.scheduled_task_cw_event_role_cloudwatch_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource | 73 | | [aws_iam_policy_document.scheduled_task_cw_event_role_assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 74 | | [aws_iam_policy_document.scheduled_task_cw_event_role_cloudwatch_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 75 | 76 | ## Inputs 77 | 78 | | Name | Description | Type | Default | Required | 79 | |------|-------------|------|---------|:--------:| 80 | | [ecs\_cluster\_arn](#input\_ecs\_cluster\_arn) | The ECS Cluster where the scheduled task will run. | `string` | n/a | yes | 81 | | [ecs\_execution\_task\_role\_arn](#input\_ecs\_execution\_task\_role\_arn) | (Required) The task definition execution role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. | `string` | n/a | yes | 82 | | [ecs\_task\_role\_arn](#input\_ecs\_task\_role\_arn) | (Optional) The task definition role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. | `string` | `null` | no | 83 | | [event\_rule\_description](#input\_event\_rule\_description) | (Optional) The description of the rule. | `string` | `null` | no | 84 | | [event\_rule\_event\_bus\_name](#input\_event\_rule\_event\_bus\_name) | (Optional) The event bus to associate with this rule. If you omit this, the default event bus is used. | `string` | `null` | no | 85 | | [event\_rule\_event\_pattern](#input\_event\_rule\_event\_pattern) | (Optional) The event pattern described a JSON object. At least one of schedule\_expression or event\_pattern is required. | `string` | `null` | no | 86 | | [event\_rule\_name](#input\_event\_rule\_name) | The name of the rule. | `string` | n/a | yes | 87 | | [event\_rule\_role\_arn](#input\_event\_rule\_role\_arn) | (Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation. | `string` | `null` | no | 88 | | [event\_rule\_schedule\_expression](#input\_event\_rule\_schedule\_expression) | (Optional) The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes). At least one of event\_rule\_schedule\_expression or event\_rule\_event\_pattern is required. Can only be used on the default event bus. | `string` | `null` | no | 89 | | [event\_rule\_state](#input\_event\_rule\_state) | (Optional) State of the rule. Valid values are DISABLED, ENABLED, and ENABLED\_WITH\_ALL\_CLOUDTRAIL\_MANAGEMENT\_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED\_WITH\_ALL\_CLOUDTRAIL\_MANAGEMENT\_EVENTS. Defaults to ENABLED. | `string` | `"ENABLED"` | no | 90 | | [event\_target\_ecs\_target\_assign\_public\_ip](#input\_event\_target\_ecs\_target\_assign\_public\_ip) | (Optional) Assign a public IP address to the ENI. Default false. | `bool` | `false` | no | 91 | | [event\_target\_ecs\_target\_group](#input\_event\_target\_ecs\_target\_group) | (Optional) Specifies an ECS task group for the task. The maximum length is 255 characters. | `string` | `null` | no | 92 | | [event\_target\_ecs\_target\_platform\_version](#input\_event\_target\_ecs\_target\_platform\_version) | (Optional) Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 1.1.0. For more information about valid platform versions, see AWS Fargate Platform Versions. Default to LATEST. | `string` | `"LATEST"` | no | 93 | | [event\_target\_ecs\_target\_propagate\_tags](#input\_event\_target\_ecs\_target\_propagate\_tags) | (Optional) Specifies whether to propagate the tags from the task definition to the task. If no value is specified, the tags are not propagated. Tags can only be propagated to the task during task creation. Valid values: `TASK_DEFINITION` or leave empty to avoid propagation. | `string` | `""` | no | 94 | | [event\_target\_ecs\_target\_security\_groups](#input\_event\_target\_ecs\_target\_security\_groups) | (Optional) The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used. | `list(any)` | `null` | no | 95 | | [event\_target\_ecs\_target\_subnets](#input\_event\_target\_ecs\_target\_subnets) | The subnets associated with the task or service. | `list(any)` | n/a | yes | 96 | | [event\_target\_ecs\_target\_task\_count](#input\_event\_target\_ecs\_target\_task\_count) | (Optional) The number of tasks to create based on the TaskDefinition. The default is 1. | `number` | `1` | no | 97 | | [event\_target\_ecs\_target\_task\_definition\_arn](#input\_event\_target\_ecs\_target\_task\_definition\_arn) | (Required) The ARN of the task definition to use if the event target is an Amazon ECS cluster. | `string` | n/a | yes | 98 | | [event\_target\_input](#input\_event\_target\_input) | (Optional) Valid JSON text passed to the target. Conflicts with event\_target\_input\_path. | `string` | `null` | no | 99 | | [event\_target\_input\_path](#input\_event\_target\_input\_path) | (Optional) The value of the JSONPath that is used for extracting part of the matched event when passing it to the target. Conflicts with event\_target\_input. | `string` | `null` | no | 100 | | [event\_target\_target\_id](#input\_event\_target\_target\_id) | (Optional) The unique target assignment ID. If missing, will generate a random, unique id. | `string` | `null` | no | 101 | | [name\_prefix](#input\_name\_prefix) | Name prefix for resources on AWS. | `string` | n/a | yes | 102 | | [permissions\_boundary](#input\_permissions\_boundary) | (Optional) The ARN of the policy that is used to set the permissions boundary for the role. | `string` | `null` | no | 103 | 104 | ## Outputs 105 | 106 | | Name | Description | 107 | |------|-------------| 108 | | [aws\_cloudwatch\_event\_rule\_event\_rule\_arn](#output\_aws\_cloudwatch\_event\_rule\_event\_rule\_arn) | The Amazon Resource Name (ARN) of the CloudWatch Event Rule. | 109 | | [aws\_cloudwatch\_event\_rule\_event\_rule\_id](#output\_aws\_cloudwatch\_event\_rule\_event\_rule\_id) | The name of the rule. | 110 | | [aws\_iam\_role\_policy\_scheduled\_task\_cw\_event\_role\_cloudwatch\_policy\_id](#output\_aws\_iam\_role\_policy\_scheduled\_task\_cw\_event\_role\_cloudwatch\_policy\_id) | The role policy ID, in the form of role\_name:role\_policy\_name. | 111 | | [aws\_iam\_role\_policy\_scheduled\_task\_cw\_event\_role\_cloudwatch\_policy\_name](#output\_aws\_iam\_role\_policy\_scheduled\_task\_cw\_event\_role\_cloudwatch\_policy\_name) | The name of the policy. | 112 | | [aws\_iam\_role\_policy\_scheduled\_task\_cw\_event\_role\_cloudwatch\_policy\_policy](#output\_aws\_iam\_role\_policy\_scheduled\_task\_cw\_event\_role\_cloudwatch\_policy\_policy) | The policy document attached to the role. | 113 | | [aws\_iam\_role\_policy\_scheduled\_task\_cw\_event\_role\_cloudwatch\_policy\_role](#output\_aws\_iam\_role\_policy\_scheduled\_task\_cw\_event\_role\_cloudwatch\_policy\_role) | The name of the role associated with the policy. | 114 | | [scheduled\_task\_cw\_event\_role\_arn](#output\_scheduled\_task\_cw\_event\_role\_arn) | The Amazon Resource Name (ARN) specifying the role. | 115 | | [scheduled\_task\_cw\_event\_role\_create\_date](#output\_scheduled\_task\_cw\_event\_role\_create\_date) | The creation date of the IAM role. | 116 | | [scheduled\_task\_cw\_event\_role\_description](#output\_scheduled\_task\_cw\_event\_role\_description) | The description of the role. | 117 | | [scheduled\_task\_cw\_event\_role\_id](#output\_scheduled\_task\_cw\_event\_role\_id) | The name of the role. | 118 | | [scheduled\_task\_cw\_event\_role\_name](#output\_scheduled\_task\_cw\_event\_role\_name) | The name of the role. | 119 | | [scheduled\_task\_cw\_event\_role\_unique\_id](#output\_scheduled\_task\_cw\_event\_role\_unique\_id) | The stable and unique string identifying the role. | 120 | 121 | -------------------------------------------------------------------------------- /examples/test/main.tf: -------------------------------------------------------------------------------- 1 | module "base-network" { 2 | source = "cn-terraform/networking/aws" 3 | version = "2.0.13" 4 | name_prefix = "test-networking" 5 | vpc_cidr_block = "192.168.0.0/16" 6 | availability_zones = ["us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d"] 7 | public_subnets_cidrs_per_availability_zone = ["192.168.0.0/19", "192.168.32.0/19", "192.168.64.0/19", "192.168.96.0/19"] 8 | private_subnets_cidrs_per_availability_zone = ["192.168.128.0/19", "192.168.160.0/19", "192.168.192.0/19", "192.168.224.0/19"] 9 | } 10 | 11 | module "cluster" { 12 | source = "cn-terraform/ecs-cluster/aws" 13 | version = "1.0.7" 14 | name = "test-cluster" 15 | } 16 | 17 | module "td" { 18 | source = "cn-terraform/ecs-fargate-task-definition/aws" 19 | version = "1.0.24" 20 | name_prefix = "test-td" 21 | container_image = "ubuntu" 22 | container_name = "test" 23 | } 24 | 25 | module "task" { 26 | source = "../../" 27 | name_prefix = "test-task" 28 | event_rule_name = "test-rule" 29 | event_rule_schedule_expression = "cron(0 20 * * ? *)" 30 | ecs_cluster_arn = module.cluster.aws_ecs_cluster_cluster_arn 31 | event_target_ecs_target_subnets = module.base-network.public_subnets_ids 32 | event_target_ecs_target_task_definition_arn = module.td.aws_ecs_task_definition_td_arn 33 | ecs_execution_task_role_arn = "Put your execution role ARN here" 34 | ecs_task_role_arn = "Put your role ARN here" 35 | } 36 | -------------------------------------------------------------------------------- /examples/test/mock_provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4" 7 | } 8 | local = { 9 | source = "hashicorp/local" 10 | version = ">= 2" 11 | } 12 | } 13 | } 14 | 15 | provider "aws" { 16 | region = "us-east-1" 17 | skip_credentials_validation = true 18 | skip_requesting_account_id = true 19 | skip_metadata_api_check = true 20 | s3_use_path_style = true 21 | 22 | endpoints { 23 | apigateway = "http://localstack:4566" 24 | cloudformation = "http://localstack:4566" 25 | cloudwatch = "http://localstack:4566" 26 | dynamodb = "http://localstack:4566" 27 | es = "http://localstack:4566" 28 | firehose = "http://localstack:4566" 29 | iam = "http://localstack:4566" 30 | kinesis = "http://localstack:4566" 31 | lambda = "http://localstack:4566" 32 | route53 = "http://localstack:4566" 33 | redshift = "http://localstack:4566" 34 | s3 = "http://localstack:4566" 35 | secretsmanager = "http://localstack:4566" 36 | ses = "http://localstack:4566" 37 | sns = "http://localstack:4566" 38 | sqs = "http://localstack:4566" 39 | ssm = "http://localstack:4566" 40 | stepfunctions = "http://localstack:4566" 41 | sts = "http://localstack:4566" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /main.tf: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # CLOUDWATCH EVENT ROLE 3 | #------------------------------------------------------------------------------ 4 | data "aws_iam_policy_document" "scheduled_task_cw_event_role_assume_role_policy" { 5 | statement { 6 | effect = "Allow" 7 | actions = ["sts:AssumeRole"] 8 | principals { 9 | identifiers = ["events.amazonaws.com"] 10 | type = "Service" 11 | } 12 | } 13 | } 14 | 15 | data "aws_iam_policy_document" "scheduled_task_cw_event_role_cloudwatch_policy" { 16 | statement { 17 | effect = "Allow" 18 | actions = ["ecs:RunTask"] 19 | resources = ["*"] 20 | condition { 21 | test = "ArnEquals" 22 | variable = "ecs:cluster" 23 | values = [var.ecs_cluster_arn] 24 | } 25 | } 26 | statement { 27 | actions = ["iam:PassRole"] 28 | resources = var.ecs_task_role_arn == null ? [var.ecs_execution_task_role_arn] : [var.ecs_execution_task_role_arn, var.ecs_task_role_arn] 29 | } 30 | } 31 | 32 | resource "aws_iam_role" "scheduled_task_cw_event_role" { 33 | count = var.event_rule_role_arn == null ? 1 : 0 34 | name = "${var.name_prefix}-st-cw-role" 35 | assume_role_policy = data.aws_iam_policy_document.scheduled_task_cw_event_role_assume_role_policy.json 36 | 37 | permissions_boundary = var.permissions_boundary == null ? null : var.permissions_boundary 38 | } 39 | 40 | resource "aws_iam_role_policy" "scheduled_task_cw_event_role_cloudwatch_policy" { 41 | count = var.event_rule_role_arn == null ? 1 : 0 42 | name = "${var.name_prefix}-st-cw-policy" 43 | role = aws_iam_role.scheduled_task_cw_event_role[0].id 44 | policy = data.aws_iam_policy_document.scheduled_task_cw_event_role_cloudwatch_policy.json 45 | } 46 | 47 | #------------------------------------------------------------------------------ 48 | # CLOUDWATCH EVENT RULE 49 | #------------------------------------------------------------------------------ 50 | resource "aws_cloudwatch_event_rule" "event_rule" { 51 | name = var.event_rule_name 52 | schedule_expression = var.event_rule_schedule_expression 53 | event_bus_name = var.event_rule_event_bus_name 54 | event_pattern = var.event_rule_event_pattern 55 | description = var.event_rule_description 56 | role_arn = var.event_rule_role_arn == null ? aws_iam_role.scheduled_task_cw_event_role[0].arn : var.event_rule_role_arn 57 | state = var.event_rule_state 58 | tags = { 59 | Name = "${var.name_prefix}-cw-event-rule" 60 | } 61 | } 62 | 63 | #------------------------------------------------------------------------------ 64 | # CLOUDWATCH EVENT TARGET 65 | #------------------------------------------------------------------------------ 66 | resource "aws_cloudwatch_event_target" "ecs_scheduled_task" { 67 | rule = aws_cloudwatch_event_rule.event_rule.name 68 | event_bus_name = aws_cloudwatch_event_rule.event_rule.event_bus_name 69 | target_id = var.event_target_target_id 70 | arn = var.ecs_cluster_arn 71 | input = var.event_target_input 72 | input_path = var.event_target_input_path 73 | role_arn = aws_cloudwatch_event_rule.event_rule.role_arn 74 | ecs_target { 75 | group = var.event_target_ecs_target_group 76 | launch_type = "FARGATE" 77 | platform_version = var.event_target_ecs_target_platform_version 78 | task_count = var.event_target_ecs_target_task_count 79 | task_definition_arn = var.event_target_ecs_target_task_definition_arn 80 | propagate_tags = var.event_target_ecs_target_propagate_tags == "" ? null : var.event_target_ecs_target_propagate_tags 81 | 82 | network_configuration { 83 | subnets = var.event_target_ecs_target_subnets 84 | security_groups = var.event_target_ecs_target_security_groups 85 | assign_public_ip = var.event_target_ecs_target_assign_public_ip 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /outputs.tf: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # CLOUDWATCH EVENT ROLE 3 | #------------------------------------------------------------------------------ 4 | output "scheduled_task_cw_event_role_arn" { 5 | description = "The Amazon Resource Name (ARN) specifying the role." 6 | value = var.event_rule_role_arn == null ? aws_iam_role.scheduled_task_cw_event_role[0].arn : null 7 | } 8 | 9 | output "scheduled_task_cw_event_role_create_date" { 10 | description = "The creation date of the IAM role." 11 | value = var.event_rule_role_arn == null ? aws_iam_role.scheduled_task_cw_event_role[0].create_date : null 12 | } 13 | 14 | output "scheduled_task_cw_event_role_description" { 15 | description = "The description of the role." 16 | value = var.event_rule_role_arn == null ? aws_iam_role.scheduled_task_cw_event_role[0].description : null 17 | } 18 | 19 | output "scheduled_task_cw_event_role_id" { 20 | description = "The name of the role." 21 | value = var.event_rule_role_arn == null ? aws_iam_role.scheduled_task_cw_event_role[0].id : null 22 | } 23 | 24 | output "scheduled_task_cw_event_role_name" { 25 | description = "The name of the role." 26 | value = var.event_rule_role_arn == null ? aws_iam_role.scheduled_task_cw_event_role[0].name : null 27 | } 28 | 29 | output "scheduled_task_cw_event_role_unique_id" { 30 | description = "The stable and unique string identifying the role." 31 | value = var.event_rule_role_arn == null ? aws_iam_role.scheduled_task_cw_event_role[0].unique_id : null 32 | } 33 | output "aws_iam_role_policy_scheduled_task_cw_event_role_cloudwatch_policy_id" { 34 | description = "The role policy ID, in the form of role_name:role_policy_name." 35 | value = var.event_rule_role_arn == null ? aws_iam_role_policy.scheduled_task_cw_event_role_cloudwatch_policy[0].id : null 36 | } 37 | 38 | output "aws_iam_role_policy_scheduled_task_cw_event_role_cloudwatch_policy_name" { 39 | description = "The name of the policy." 40 | value = var.event_rule_role_arn == null ? aws_iam_role_policy.scheduled_task_cw_event_role_cloudwatch_policy[0].name : null 41 | } 42 | 43 | output "aws_iam_role_policy_scheduled_task_cw_event_role_cloudwatch_policy_policy" { 44 | description = "The policy document attached to the role." 45 | value = var.event_rule_role_arn == null ? aws_iam_role_policy.scheduled_task_cw_event_role_cloudwatch_policy[0].policy : null 46 | } 47 | 48 | output "aws_iam_role_policy_scheduled_task_cw_event_role_cloudwatch_policy_role" { 49 | description = "The name of the role associated with the policy." 50 | value = var.event_rule_role_arn == null ? aws_iam_role_policy.scheduled_task_cw_event_role_cloudwatch_policy[0].role : null 51 | } 52 | 53 | #------------------------------------------------------------------------------ 54 | # CLOUDWATCH EVENT RULE 55 | #------------------------------------------------------------------------------ 56 | output "aws_cloudwatch_event_rule_event_rule_id" { 57 | description = "The name of the rule." 58 | value = aws_cloudwatch_event_rule.event_rule.id 59 | } 60 | 61 | output "aws_cloudwatch_event_rule_event_rule_arn" { 62 | description = "The Amazon Resource Name (ARN) of the CloudWatch Event Rule." 63 | value = aws_cloudwatch_event_rule.event_rule.arn 64 | } 65 | -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # Misc 3 | #------------------------------------------------------------------------------ 4 | variable "name_prefix" { 5 | description = "Name prefix for resources on AWS." 6 | type = string 7 | } 8 | 9 | #------------------------------------------------------------------------------ 10 | # CLOUDWATCH EVENT RULE 11 | #------------------------------------------------------------------------------ 12 | variable "event_rule_name" { 13 | description = "The name of the rule." 14 | type = string 15 | } 16 | 17 | variable "event_rule_schedule_expression" { 18 | description = "(Optional) The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes). At least one of event_rule_schedule_expression or event_rule_event_pattern is required. Can only be used on the default event bus." 19 | default = null 20 | type = string 21 | } 22 | 23 | variable "event_rule_event_bus_name" { 24 | description = "(Optional) The event bus to associate with this rule. If you omit this, the default event bus is used." 25 | default = null 26 | type = string 27 | } 28 | 29 | variable "event_rule_event_pattern" { 30 | description = "(Optional) The event pattern described a JSON object. At least one of schedule_expression or event_pattern is required." 31 | default = null 32 | type = string 33 | } 34 | 35 | variable "event_rule_description" { 36 | description = "(Optional) The description of the rule." 37 | default = null 38 | type = string 39 | } 40 | 41 | variable "event_rule_role_arn" { 42 | description = "(Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation." 43 | default = null 44 | type = string 45 | } 46 | 47 | variable "event_rule_state" { 48 | description = "(Optional) State of the rule. Valid values are DISABLED, ENABLED, and ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. When state is ENABLED, the rule is enabled for all events except those delivered by CloudTrail. To also enable the rule for events delivered by CloudTrail, set state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. Defaults to ENABLED." 49 | default = "ENABLED" 50 | type = string 51 | } 52 | 53 | #------------------------------------------------------------------------------ 54 | # CLOUDWATCH EVENT TARGET 55 | #------------------------------------------------------------------------------ 56 | variable "event_target_target_id" { 57 | description = "(Optional) The unique target assignment ID. If missing, will generate a random, unique id." 58 | default = null 59 | type = string 60 | } 61 | 62 | variable "ecs_cluster_arn" { 63 | description = "The ECS Cluster where the scheduled task will run." 64 | type = string 65 | } 66 | 67 | variable "event_target_input" { 68 | description = "(Optional) Valid JSON text passed to the target. Conflicts with event_target_input_path." 69 | default = null 70 | type = string 71 | } 72 | 73 | variable "event_target_input_path" { 74 | description = " (Optional) The value of the JSONPath that is used for extracting part of the matched event when passing it to the target. Conflicts with event_target_input." 75 | default = null 76 | type = string 77 | } 78 | 79 | variable "ecs_execution_task_role_arn" { 80 | description = "(Required) The task definition execution role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered." 81 | type = string 82 | } 83 | 84 | variable "ecs_task_role_arn" { 85 | description = "(Optional) The task definition role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered." 86 | default = null 87 | type = string 88 | } 89 | 90 | variable "event_target_ecs_target_group" { 91 | description = "(Optional) Specifies an ECS task group for the task. The maximum length is 255 characters." 92 | default = null 93 | type = string 94 | } 95 | 96 | variable "event_target_ecs_target_platform_version" { 97 | description = "(Optional) Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 1.1.0. For more information about valid platform versions, see AWS Fargate Platform Versions. Default to LATEST." 98 | default = "LATEST" 99 | type = string 100 | } 101 | 102 | variable "event_target_ecs_target_task_count" { 103 | description = "(Optional) The number of tasks to create based on the TaskDefinition. The default is 1." 104 | default = 1 105 | type = number 106 | } 107 | 108 | variable "event_target_ecs_target_task_definition_arn" { 109 | description = "(Required) The ARN of the task definition to use if the event target is an Amazon ECS cluster." 110 | type = string 111 | } 112 | 113 | variable "event_target_ecs_target_subnets" { 114 | description = "The subnets associated with the task or service." 115 | type = list(any) 116 | } 117 | 118 | variable "event_target_ecs_target_security_groups" { 119 | description = "(Optional) The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used." 120 | default = null 121 | type = list(any) 122 | } 123 | 124 | variable "event_target_ecs_target_assign_public_ip" { 125 | description = "(Optional) Assign a public IP address to the ENI. Default false." 126 | default = false 127 | type = bool 128 | 129 | } 130 | 131 | variable "event_target_ecs_target_propagate_tags" { 132 | description = "(Optional) Specifies whether to propagate the tags from the task definition to the task. If no value is specified, the tags are not propagated. Tags can only be propagated to the task during task creation. Valid values: `TASK_DEFINITION` or leave empty to avoid propagation." 133 | default = "" 134 | type = string 135 | } 136 | 137 | variable "permissions_boundary" { 138 | description = "(Optional) The ARN of the policy that is used to set the permissions boundary for the role." 139 | default = null 140 | type = string 141 | } -------------------------------------------------------------------------------- /versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4" 7 | } 8 | local = { 9 | source = "hashicorp/local" 10 | version = ">= 2" 11 | } 12 | } 13 | } 14 | --------------------------------------------------------------------------------