asg-rolling-deploy: This module creates an ASG that can do a zero-downtime rolling
deployment.
server-group: Run a fixed-size cluster of servers that can automatically attach EBS Volumes
and ENIs, do zero-downtime rolling deployment, and automatically replace failed servers.
Click on each module above to see its documentation. Head over to the examples folder for examples.
What is a module?
At Gruntwork, we've taken the thousands of hours we spent building infrastructure on AWS and
condensed all that experience and code into pre-built packages or modules. Each module is a battle-tested,
best-practices definition of a piece of infrastructure, such as a VPC, ECS cluster, or an Auto Scaling Group. Modules
are versioned using Semantic Versioning to allow Gruntwork clients to keep up to date with the
latest infrastructure best practices in a systematic way.
To use a module in your Terraform templates, create a module resource and set its source field to the Git URL of
this repo. You should also set the ref parameter so you're fixed to a specific version of this repo, as the main
branch may have backward incompatible changes (see module
sources).
For example, to use v1.0.8 of the ecs-cluster module, you would add the following:
module"ecs_cluster" {
source = "git::git@github.com:gruntwork-io/terraform-aws-ecs.git//modules/ecs-cluster?ref=v1.0.8"// set the parameters for the ECS cluster module
}
Note: the double slash (//) is intentional and required. It's part of Terraform's Git syntax (see module
sources).
See the module's documentation and variables.tf file for all the parameters you can set. Run terraform get -update to
pull the latest version of this module from this repo before runnin gthe standard terraform plan and
terraform apply commands.
Using scripts & binaries
You can install the scripts and binaries in the modules folder of any repo using the Gruntwork
Installer. For example, if the scripts you want to install are
in the modules/ecs-scripts folder of the https://github.com/gruntwork-io/terraform-aws-ecs repo, you could install them
as follows:
See the docs for each script & binary for detailed instructions on how to use them.
What's an Auto Scaling Group?
An Auto Scaling Group (ASG) is used to manage a cluster of EC2 Instances. It
can enforce pre-defined rules about how many instances to run in the cluster, scale the number of instances up or
down depending on traffic, and automatically restart instances if they go down.
We are following the principles of Semantic Versioning. During initial development, the major
version is to 0 (e.g., 0.x.y), which indicates the code does not yet have a stable API. Once we hit 1.0.0, we will
follow these rules:
Increment the patch version for backwards-compatible bug fixes (e.g., v1.0.8 -> v1.0.9).
Increment the minor version for new features that are backwards-compatible (e.g., v1.0.8 -> 1.1.0).
Increment the major version for any backwards-incompatible changes (e.g. 1.0.8 -> 2.0.0).
The version is defined using Git tags. Use GitHub to create a release, which will have the effect of adding a git tag.
{"treedata":{"name":"root","toggled":true,"children":[{"name":".circleci","children":[{"name":"config.yml","path":".circleci/config.yml","sha":"f8c94c06f660e12e09d935b7e5a09ed87fcfae22"},{"name":"post-upgrade-test-results.sh","path":".circleci/post-upgrade-test-results.sh","sha":"a4867e8fbdc334b7a90259568ee41ea577fbe764"},{"name":"set-upgrade-test-vars.sh","path":".circleci/set-upgrade-test-vars.sh","sha":"cb49068f21d5e98dcd08650ef09ab5aab78788c9"}]},{"name":".github","children":[{"name":"ISSUE_TEMPLATE","children":[{"name":"bug_report.md","path":".github/ISSUE_TEMPLATE/bug_report.md","sha":"d2e87e27c601e423865ed660ec697082470ca60f"},{"name":"feature_request.md","path":".github/ISSUE_TEMPLATE/feature_request.md","sha":"023a33099be2336476930c96e17ff1ba5dc55348"}]},{"name":"pull_request_template.md","path":".github/pull_request_template.md","sha":"6b100e40e323b5b07f40ed30616277c51c9f4b9e"}]},{"name":".gitignore","path":".gitignore","sha":"fd04ff401a18d9c8595968dbbd3a9996d37b6a8b"},{"name":".pre-commit-config.yaml","path":".pre-commit-config.yaml","sha":"605d316ff7fc0ae6e303f790b71c61a2dc31337a"},{"name":"CODEOWNERS","path":"CODEOWNERS","sha":"5f0e275ee3a38d13d1304c36d5e8640221690376"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","sha":"c992069269419c83cb1f032fd80124cdca22fb02"},{"name":"LICENSE.txt","path":"LICENSE.txt","sha":"f4e3d9bd4717a044ed31ad847a300eee74371a78"},{"name":"README.md","path":"README.md","sha":"28a4240bb0352e8f94eb1f07dd6b602e5858990a","toggled":true},{"name":"examples","children":[{"name":"asg-instance-refresh-with-launch-template","children":[{"name":"README.md","path":"examples/asg-instance-refresh-with-launch-template/README.md","sha":"a4aee07ff69ae8b4b095168c4f8f31a5168b3437"},{"name":"main.tf","path":"examples/asg-instance-refresh-with-launch-template/main.tf","sha":"965779297e8b60cfcb421b9a5bf3d61163df5547"},{"name":"outputs.tf","path":"examples/asg-instance-refresh-with-launch-template/outputs.tf","sha":"c8db3c807aab3d75888c2dd039b9e81b1312a137"},{"name":"variables.tf","path":"examples/asg-instance-refresh-with-launch-template/variables.tf","sha":"d4d4c041884de1f2e31ca0d64c0f4a6031b88ea8"}]},{"name":"asg-instance-refresh","children":[{"name":"README.md","path":"examples/asg-instance-refresh/README.md","sha":"f566fae0867be0be2cecbd8ca6d20234c5cc17dc"},{"name":"with-elb","children":[{"name":"main.tf","path":"examples/asg-instance-refresh/with-elb/main.tf","sha":"19d6976bc01ed3f8f7e86fb8e376a7325847096a"},{"name":"outputs.tf","path":"examples/asg-instance-refresh/with-elb/outputs.tf","sha":"330a02ec9378c2c9c4a1423b075384f4ae3ed241"},{"name":"user-data","children":[{"name":"user-data.sh","path":"examples/asg-instance-refresh/with-elb/user-data/user-data.sh","sha":"7b5fbe6f33805eb5356e9c49db9bd5b141b0816a"}]},{"name":"variables.tf","path":"examples/asg-instance-refresh/with-elb/variables.tf","sha":"2056963b26c09d4579a5a860075e4a7a3d7875e5"}]},{"name":"without-elb","children":[{"name":"main.tf","path":"examples/asg-instance-refresh/without-elb/main.tf","sha":"4b7dca9beec608b873275c7597b15d94ecb5931e"},{"name":"outputs.tf","path":"examples/asg-instance-refresh/without-elb/outputs.tf","sha":"c8db3c807aab3d75888c2dd039b9e81b1312a137"},{"name":"variables.tf","path":"examples/asg-instance-refresh/without-elb/variables.tf","sha":"42452d0ed062cf8afce3f23319bb5e81690d12a1"}]}]},{"name":"asg-rolling-deploy","children":[{"name":"README.md","path":"examples/asg-rolling-deploy/README.md","sha":"48915d8fec1cd3dd0304d9258fdfd3e0b000ec31"},{"name":"with-elb","children":[{"name":"main.tf","path":"examples/asg-rolling-deploy/with-elb/main.tf","sha":"ea00a7e46d893987edcbe6e038c177ffdba5b4ba"},{"name":"outputs.tf","path":"examples/asg-rolling-deploy/with-elb/outputs.tf","sha":"330a02ec9378c2c9c4a1423b075384f4ae3ed241"},{"name":"user-data","children":[{"name":"user-data.sh","path":"examples/asg-rolling-deploy/with-elb/user-data/user-data.sh","sha":"7b5fbe6f33805eb5356e9c49db9bd5b141b0816a"}]},{"name":"variables.tf","path":"examples/asg-rolling-deploy/with-elb/variables.tf","sha":"dab89e417460b5fa2676796e945acf27803c6553"}]},{"name":"without-elb","children":[{"name":"main.tf","path":"examples/asg-rolling-deploy/without-elb/main.tf","sha":"d4cc52df5ee6b5f94088de6bfba2f1f5d9cdc853"},{"name":"outputs.tf","path":"examples/asg-rolling-deploy/without-elb/outputs.tf","sha":"c8db3c807aab3d75888c2dd039b9e81b1312a137"},{"name":"variables.tf","path":"examples/asg-rolling-deploy/without-elb/variables.tf","sha":"34963a1ec3dd6620fe86ab715d49b1bb189f477d"}]}]},{"name":"server-group","children":[{"name":"README.md","path":"examples/server-group/README.md","sha":"10cda1da76dedb61ef2ff8ec8dc11a619d71fff9"},{"name":"ami","children":[{"name":"server.json","path":"examples/server-group/ami/server.json","sha":"cbef2fd26969a6725f4fc0465bb3e5f9dc3bedc9"}]},{"name":"with-alb","children":[{"name":"main.tf","path":"examples/server-group/with-alb/main.tf","sha":"2978f4ff0d8b09f9d395d9dcfd86a2133a4a49a0"},{"name":"outputs.tf","path":"examples/server-group/with-alb/outputs.tf","sha":"3565caece2f11d61dc0b0a6ed23cc58ce7e6e61c"},{"name":"user-data","children":[{"name":"user-data.sh","path":"examples/server-group/with-alb/user-data/user-data.sh","sha":"55d5dff9d84f2e3793f6c669fd0cfa4bd65f287a"}]},{"name":"variables.tf","path":"examples/server-group/with-alb/variables.tf","sha":"dc708850a0e1169ba4101135f6a707e79bd82850"}]},{"name":"with-elb","children":[{"name":"main.tf","path":"examples/server-group/with-elb/main.tf","sha":"c046b5488a151206d5491f55b5936966d8c15a61"},{"name":"outputs.tf","path":"examples/server-group/with-elb/outputs.tf","sha":"fd38915d96770f9588e2fcc79369e64449492286"},{"name":"user-data","children":[{"name":"user-data.sh","path":"examples/server-group/with-elb/user-data/user-data.sh","sha":"3800df7ab47bf43e6253ebeb21d5900585d32b6a"}]},{"name":"variables.tf","path":"examples/server-group/with-elb/variables.tf","sha":"4eb70bfff00b837c8404d044fee311b16e0e0c73"}]},{"name":"without-load-balancer","children":[{"name":"main.tf","path":"examples/server-group/without-load-balancer/main.tf","sha":"333d971cb3c2d0d714f3d2c94a616b2149e9d0e0"},{"name":"outputs.tf","path":"examples/server-group/without-load-balancer/outputs.tf","sha":"27911554f10688f23ba9f8e31eadd4409c635f97"},{"name":"user-data","children":[{"name":"user-data.sh","path":"examples/server-group/without-load-balancer/user-data/user-data.sh","sha":"55d5dff9d84f2e3793f6c669fd0cfa4bd65f287a"}]},{"name":"variables.tf","path":"examples/server-group/without-load-balancer/variables.tf","sha":"ad4828ccf80f57a1021146a753ae0389851d9a1d"}]}]}]},{"name":"modules","children":[{"name":"asg-instance-refresh","children":[{"name":"README.md","path":"modules/asg-instance-refresh/README.md","sha":"bdae794c406e78962ffc06250225b81f6066e944"},{"name":"main.tf","path":"modules/asg-instance-refresh/main.tf","sha":"7e81841b5fd3d7d313a1c347e25596f049a1f8c3"},{"name":"outputs.tf","path":"modules/asg-instance-refresh/outputs.tf","sha":"5225c1f98cfc9f91411d91eae7bd692168ea8f4c"},{"name":"variables.tf","path":"modules/asg-instance-refresh/variables.tf","sha":"5c4156c2671e12ec9a4d098c827a15bfcdf6cd34"}]},{"name":"asg-rolling-deploy","children":[{"name":"README.md","path":"modules/asg-rolling-deploy/README.md","sha":"61f1e1c0f4de369ef2b11c02f849322621812f5a"},{"name":"describe-autoscaling-group","children":[{"name":"README.md","path":"modules/asg-rolling-deploy/describe-autoscaling-group/README.md","sha":"30ba6d6cfb97a09deb821a9037108bbc6abcc276"},{"name":"boto3-1.20.24.zip","path":"modules/asg-rolling-deploy/describe-autoscaling-group/boto3-1.20.24.zip","sha":"b4b675780634cea8a0eb06a0b0458dbb0a39385d"},{"name":"get-desired-capacity.py","path":"modules/asg-rolling-deploy/describe-autoscaling-group/get-desired-capacity.py","sha":"a980df805a4d65e77ecd1dbba5892803415c9c5b"}]},{"name":"main.tf","path":"modules/asg-rolling-deploy/main.tf","sha":"f8b446b4ae270faec807841b304b9901e93ea575"},{"name":"outputs.tf","path":"modules/asg-rolling-deploy/outputs.tf","sha":"5225c1f98cfc9f91411d91eae7bd692168ea8f4c"},{"name":"variables.tf","path":"modules/asg-rolling-deploy/variables.tf","sha":"4e0b69bd79a44adca395bed27b2f05fe3ad09b30"}]},{"name":"server-group","children":[{"name":"README.md","path":"modules/server-group/README.md","sha":"f405b0f4591813d744a1d16dc14ed7ae50595b74"},{"name":"main.tf","path":"modules/server-group/main.tf","sha":"e923a9092765adc072cd9812655a495f4f86bd9d"},{"name":"outputs.tf","path":"modules/server-group/outputs.tf","sha":"c321666d3144ed743a9ad2bdf8acbc1cdbdf70f7"},{"name":"rolling-deploy","children":[{"name":"boto3-1.20.24.zip","path":"modules/server-group/rolling-deploy/boto3-1.20.24.zip","sha":"b4b675780634cea8a0eb06a0b0458dbb0a39385d"},{"name":"helpers.py","path":"modules/server-group/rolling-deploy/helpers.py","sha":"37ee35c8f200ceafdb9f7acf09d2ece1e6adddcb"},{"name":"rolling_deployment.py","path":"modules/server-group/rolling-deploy/rolling_deployment.py","sha":"ee12375530994d9f9faf6aa903543c15998ec4b6"}]},{"name":"variables.tf","path":"modules/server-group/variables.tf","sha":"00932445a55550b9e46b40034dc46d3ac32cebe5"}]}]},{"name":"terraform-cloud-enterprise-private-module-registry-placeholder.tf","path":"terraform-cloud-enterprise-private-module-registry-placeholder.tf","sha":"ae586c0fe830819580e1009d41a9074f16e65bed"},{"name":"test","children":[{"name":"README.md","path":"test/README.md","sha":"cfa55a38cc6fbd09a311291216eb758159973629"},{"name":"asg_instance_refresh_test.go","path":"test/asg_instance_refresh_test.go","sha":"78157f674961278f1381fa9f688c87e7ffabaec4"},{"name":"asg_rolling_deploy_test.go","path":"test/asg_rolling_deploy_test.go","sha":"d6360ae0aedab636e619c67e3a4074d5ad5a04ed"},{"name":"go.mod","path":"test/go.mod","sha":"26c31428cd193b81d32fcc18d5145faa7d3564fe"},{"name":"go.sum","path":"test/go.sum","sha":"7ef564d3e21815e6fabf3796378b8f14fa19a25e"},{"name":"server_group_test.go","path":"test/server_group_test.go","sha":"3659d241c4ca01850e79c2142362e699b81ff696"},{"name":"test_helpers.go","path":"test/test_helpers.go","sha":"d0314394cc9ba247b6a4a052c91fb24570a2b03a"},{"name":"upgrades","children":[{"name":"upgrade_test.go","path":"test/upgrades/upgrade_test.go","sha":"639640870fe05ac69382535a95c39ff7ef9f9926"}]},{"name":"validation","children":[{"name":"validate_all_modules_and_examples_test.go","path":"test/validation/validate_all_modules_and_examples_test.go","sha":"74c928d0cbc2914e5cd708277bd857cb2375b660"}]}]}]},"detailsContent":"<p><img src=\"https://img.shields.io/badge/tf-%3E%3D1.1.0-blue.svg\" alt=\"Terraform Version\" class=\"preview__body--diagram\"></p>\n<h1 class=\"preview__body--title\" id=\"auto-scaling-group-modules\">Auto Scaling Group Modules</h1><div class=\"preview__body--border\"></div><p>This repo contains modules for creating and managing a best-practices <a href=\"https://aws.amazon.com/autoscaling/\" class=\"preview__body--description--blue\" target=\"_blank\">Auto Scaling Group\n(ASG)</a>.</p>\n<p>The main modules are:</p>\n<ul>\n<li><a href=\"/repos/v0.21.15/module-asg/modules/asg-rolling-deploy\" class=\"preview__body--description--blue\">asg-rolling-deploy</a>: This module creates an ASG that can do a zero-downtime rolling\ndeployment.</li>\n<li><a href=\"/repos/v0.21.15/module-asg/modules/server-group\" class=\"preview__body--description--blue\">server-group</a>: Run a fixed-size cluster of servers that can automatically attach EBS Volumes\nand ENIs, do zero-downtime rolling deployment, and automatically replace failed servers.</li>\n</ul>\n<p>Click on each module above to see its documentation. Head over to the <a href=\"/repos/v0.21.15/module-asg/examples\" class=\"preview__body--description--blue\">examples</a> folder for examples.</p>\n<h2 class=\"preview__body--subtitle\" id=\"what-is-a-module\">What is a module?</h2>\n<p>At <a href=\"http://www.gruntwork.io\" class=\"preview__body--description--blue\" target=\"_blank\">Gruntwork</a>, we've taken the thousands of hours we spent building infrastructure on AWS and\ncondensed all that experience and code into pre-built <strong>packages</strong> or <strong>modules</strong>. Each module is a battle-tested,\nbest-practices definition of a piece of infrastructure, such as a VPC, ECS cluster, or an Auto Scaling Group. Modules\nare versioned using <a href=\"http://semver.org/\" class=\"preview__body--description--blue\" target=\"_blank\">Semantic Versioning</a> to allow Gruntwork clients to keep up to date with the\nlatest infrastructure best practices in a systematic way.</p>\n<h2 class=\"preview__body--subtitle\" id=\"how-do-you-use-a-module\">How do you use a module?</h2>\n<p>Most of our modules contain either:</p>\n<ol>\n<li><a href=\"https://www.terraform.io/\" class=\"preview__body--description--blue\" target=\"_blank\">Terraform</a> code</li>\n<li>Scripts & binaries</li>\n</ol>\n<h3 class=\"preview__body--subtitle\" id=\"using-a-terraform-module\">Using a Terraform Module</h3>\n<p>To use a module in your Terraform templates, create a <code>module</code> resource and set its <code>source</code> field to the Git URL of\nthis repo. You should also set the <code>ref</code> parameter so you're fixed to a specific version of this repo, as the <code>main</code>\nbranch may have backward incompatible changes (see <a href=\"https://www.terraform.io/docs/modules/sources.html\" class=\"preview__body--description--blue\" target=\"_blank\">module\nsources</a>).</p>\n<p>For example, to use <code>v1.0.8</code> of the ecs-cluster module, you would add the following:</p>\n<pre><span class=\"hljs-keyword\">module</span> <span class=\"hljs-string\">\"ecs_cluster\"</span> {\n source = <span class=\"hljs-string\">\"git::git@github.com:gruntwork-io/terraform-aws-ecs.git//modules/ecs-cluster?ref=v1.0.8\"</span>\n\n <span class=\"hljs-comment\">// set the parameters for the ECS cluster module</span>\n}\n</pre>\n<p><em>Note: the double slash (<code>//</code>) is intentional and required. It's part of Terraform's Git syntax (see <a href=\"https://www.terraform.io/docs/modules/sources.html\" class=\"preview__body--description--blue\" target=\"_blank\">module\nsources</a>).</em></p>\n<p>See the module's documentation and <code>variables.tf</code> file for all the parameters you can set. Run <code>terraform get -update</code> to\npull the latest version of this module from this repo before runnin gthe standard <code>terraform plan</code> and\n<code>terraform apply</code> commands.</p>\n<h3 class=\"preview__body--subtitle\" id=\"using-scripts-binaries\">Using scripts & binaries</h3>\n<p>You can install the scripts and binaries in the <code>modules</code> folder of any repo using the <a href=\"/repos/gruntwork-installer\" class=\"preview__body--description--blue\">Gruntwork\nInstaller</a>. For example, if the scripts you want to install are\nin the <code>modules/ecs-scripts</code> folder of the https://github.com/gruntwork-io/terraform-aws-ecs repo, you could install them\nas follows:</p>\n<pre><span class=\"hljs-string\">gruntwork-install </span><span class=\"hljs-built_in\">--module-name</span> <span class=\"hljs-string\">\"ecs-scripts\"</span> <span class=\"hljs-built_in\">--repo</span> <span class=\"hljs-string\">\"https://github.com/gruntwork-io/terraform-aws-ecs\"</span> <span class=\"hljs-built_in\">--tag</span> <span class=\"hljs-string\">\"0.0.1\"</span>\n</pre>\n<p>See the docs for each script & binary for detailed instructions on how to use them.</p>\n<h2 class=\"preview__body--subtitle\" id=\"whats-an-auto-scaling-group\">What's an Auto Scaling Group?</h2>\n<p>An <a href=\"https://aws.amazon.com/autoscaling/\" class=\"preview__body--description--blue\" target=\"_blank\">Auto Scaling Group</a> (ASG) is used to manage a cluster of EC2 Instances. It\ncan enforce pre-defined rules about how many instances to run in the cluster, scale the number of instances up or\ndown depending on traffic, and automatically restart instances if they go down.</p>\n<h2 class=\"preview__body--subtitle\" id=\"developing-a-module\">Developing a module</h2>\n<h3 class=\"preview__body--subtitle\" id=\"how-do-i-contribute-to-this-module\">How do I contribute to this Module?</h3>\n<p>Contributions are very welcome! Check out the <a href=\"/repos/v0.21.15/module-asg/CONTRIBUTING.md\" class=\"preview__body--description--blue\">Contribution Guidelines</a> for instructions.</p>\n<h3 class=\"preview__body--subtitle\" id=\"versioning\">Versioning</h3>\n<p>We are following the principles of <a href=\"http://semver.org/\" class=\"preview__body--description--blue\" target=\"_blank\">Semantic Versioning</a>. During initial development, the major\nversion is to 0 (e.g., <code>0.x.y</code>), which indicates the code does not yet have a stable API. Once we hit <code>1.0.0</code>, we will\nfollow these rules:</p>\n<ol>\n<li>Increment the patch version for backwards-compatible bug fixes (e.g., <code>v1.0.8 -> v1.0.9</code>).</li>\n<li>Increment the minor version for new features that are backwards-compatible (e.g., <code>v1.0.8 -> 1.1.0</code>).</li>\n<li>Increment the major version for any backwards-incompatible changes (e.g. <code>1.0.8 -> 2.0.0</code>).</li>\n</ol>\n<p>The version is defined using Git tags. Use GitHub to create a release, which will have the effect of adding a git tag.</p>\n<h3 class=\"preview__body--subtitle\" id=\"tests\">Tests</h3>\n<p>See the <a href=\"/repos/v0.21.15/module-asg/test\" class=\"preview__body--description--blue\">test</a> folder for details.</p>\n<h2 class=\"preview__body--subtitle\" id=\"license\">License</h2>\n<p>Please see <a href=\"/repos/v0.21.15/module-asg/LICENSE.txt\" class=\"preview__body--description--blue\">LICENSE.txt</a> for details on how the code in this repo is licensed.</p>\n","repoName":"module-asg","repoRef":"v0.21.15","serviceDescriptor":{"serviceName":"Auto Scaling Group (stateless)","serviceRepoName":"module-asg","serviceRepoOrg":"gruntwork-io","serviceMainReadmePath":"/modules/asg-rolling-deploy","cloudProviders":["aws"],"description":"Run an Auto Scaling Group for stateless apps. Supports zero-downtime, rolling deployment, auto healing, auto scaling, and IAM Roles.","imageUrl":"auto-scaling2.png","licenseType":"subscriber","technologies":["Terraform","Python","Bash"],"compliance":[],"tags":[""]},"serviceCategoryName":"Server orchestration","fileName":"README.md","filePath":"","title":"Repo Browser: Auto Scaling Group (stateless)","description":"Browse the repos in the Gruntwork Infrastructure as Code Library."}