This folder shows examples of how to use the server-group module to deploy a cluster of
servers that can automatically attach EBS Volumes and ENIs, do zero-downtime rolling deployment, and automatically
replace failed servers:
ami: An example AMI meant to be used with all the other examples listed below. It installs the attach-eni
and mount-ebs-volume scripts used by each server during boot to attach an ENI and EBS Volume, respectively.
with-elb: An example of how to deploy a server-group that uses an ELB for health checks.
with-alb: An example of how to deploy a server-group that uses an ALB for health checks.
without-load-balancer: An example of how to deploy a server-group that uses EC2 status
checks instead of load balancers for health checks.
On each EC2 Instance in the server-group examples, for demonstration and testing purposes, we run a dummy web server
that just returns "Hello World". If you update this app (e.g. change the text to "Hello, World v2" or replace the app
with a totally different AMI of your own), the next time you run terraform apply, the new version of the app will
roll out automatically, with no downtime.
How do you run these examples?
Prerequisites: Install Packer and Terraform. Also, make sure you
have Python installed (version 2.x) and in your PATH.
Build the AMI: packer build ami/server.json.
Open vars.tf, set the environment variables specified at the top of the file, and fill in any other variables that
don't have a default, including the ID of the AMI you built in the previous step.
Run terraform get.
Run terraform plan.
If the plan looks good, run terraform apply.
Deploying a new version
Once you have the app up and running, to test out the rolling deployment, make a change to any of the variables passed
into the server-group module. For example, as a quick test, you could change the server_text variable to "Hello,
World, v2.0!". Once you've made your changes, do the following:
Commit your changes to Git so your teammates have access to them.
Run terraform plan.
If the plan looks good, run terraform apply.
The new version of the app will automatically deploy across the server-group with no downtime. Check out the
server-group module documentation for details on how this works.
Questions? Ask away.
We're here to talk about our services, answer any questions, give advice, or just to chat.
{"treedata":{"name":"root","toggled":true,"children":[{"name":".circleci","children":[{"name":"config.yml","path":".circleci/config.yml","sha":"3b69f7bf481fe18ca42e8b40e0e6369d1efb4494"}]},{"name":".gitignore","path":".gitignore","sha":"62841321b0ad8768831d29e34422fafa4c24751e"},{"name":".pre-commit-config.yaml","path":".pre-commit-config.yaml","sha":"c727e29761f9d32c212546d1c47ebc05a16b2d37"},{"name":"CODEOWNERS","path":"CODEOWNERS","sha":"38e274e73edb347a7f35c6d9e84a125a2e7bb063"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","sha":"6ce0d84e615b63ee870e407c93740f491cbcd27d"},{"name":"LICENSE.txt","path":"LICENSE.txt","sha":"f4e3d9bd4717a044ed31ad847a300eee74371a78"},{"name":"README.md","path":"README.md","sha":"648489bca9cb5d56b2a29d0eabf6d5ba5e2639e3"},{"name":"examples","children":[{"name":"asg-rolling-deploy","children":[{"name":"README.md","path":"examples/asg-rolling-deploy/README.md","sha":"f5f2a8e2db00bb7c95975437ac913ef2f9769f7c"},{"name":"with-elb","children":[{"name":"main.tf","path":"examples/asg-rolling-deploy/with-elb/main.tf","sha":"28c2f0037746c32e28e3083a4518c8ff5c03870d"},{"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":"vars.tf","path":"examples/asg-rolling-deploy/with-elb/vars.tf","sha":"dab89e417460b5fa2676796e945acf27803c6553"}]},{"name":"without-elb","children":[{"name":"main.tf","path":"examples/asg-rolling-deploy/without-elb/main.tf","sha":"e4591c78c05fc4178827e9291d55463320a0dea3"},{"name":"outputs.tf","path":"examples/asg-rolling-deploy/without-elb/outputs.tf","sha":"c8db3c807aab3d75888c2dd039b9e81b1312a137"},{"name":"vars.tf","path":"examples/asg-rolling-deploy/without-elb/vars.tf","sha":"1d6d2ee9904841723c7e7c29d9fe5e12e7f6fd6a"}]}]},{"name":"server-group","children":[{"name":"README.md","path":"examples/server-group/README.md","sha":"63c6917a20e10cb2b569e5314bbf3d4ec38ff491","toggled":true},{"name":"ami","children":[{"name":"server.json","path":"examples/server-group/ami/server.json","sha":"8eb0e050068c94f085b4a4bf188365f5c0c45d1b"}]},{"name":"with-alb","children":[{"name":"main.tf","path":"examples/server-group/with-alb/main.tf","sha":"f911b264e56d9a465c703cd244dd82cea05ce29d"},{"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":"064d042a5d0ba6956f4eb8d7ece309b4d6eb4b33"}]},{"name":"vars.tf","path":"examples/server-group/with-alb/vars.tf","sha":"dc708850a0e1169ba4101135f6a707e79bd82850"}]},{"name":"with-elb","children":[{"name":"main.tf","path":"examples/server-group/with-elb/main.tf","sha":"0dcff963a4e68e846366a894c356d37c712918ae"},{"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":"f0b175520e85da002b8c26a4a92347fb1eaa1d13"}]},{"name":"vars.tf","path":"examples/server-group/with-elb/vars.tf","sha":"4eb70bfff00b837c8404d044fee311b16e0e0c73"}]},{"name":"without-load-balancer","children":[{"name":"main.tf","path":"examples/server-group/without-load-balancer/main.tf","sha":"70f8ee203e31736b3a87c273faae98ad0c2c1aa3"},{"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":"064d042a5d0ba6956f4eb8d7ece309b4d6eb4b33"}]},{"name":"vars.tf","path":"examples/server-group/without-load-balancer/vars.tf","sha":"0724aa38905b313165b621e7866575e0e0abdd4b"}]}],"toggled":true}],"toggled":true},{"name":"modules","children":[{"name":"asg-rolling-deploy","children":[{"name":"README.md","path":"modules/asg-rolling-deploy/README.md","sha":"fbbc6657f0cef2493e9fdb7b42549d69e5ff4080"},{"name":"describe-autoscaling-group","children":[{"name":"README.md","path":"modules/asg-rolling-deploy/describe-autoscaling-group/README.md","sha":"062e4ebc0b65610874998a354f441f56114b4e7e"},{"name":"boto3-1.7.10.zip","path":"modules/asg-rolling-deploy/describe-autoscaling-group/boto3-1.7.10.zip","sha":"4b76be11cfa98ddb4314e11a0b28700a11cd2fcc"},{"name":"get-desired-capacity.py","path":"modules/asg-rolling-deploy/describe-autoscaling-group/get-desired-capacity.py","sha":"c4972706f07ca0275c08bb8acbdf03e3a0e7a778"}]},{"name":"main.tf","path":"modules/asg-rolling-deploy/main.tf","sha":"986f00d77f93eb2e6918b692820791451205be20"},{"name":"outputs.tf","path":"modules/asg-rolling-deploy/outputs.tf","sha":"7db73654cd55edcf3706aeb3ba4a2a0ddac8dc5b"},{"name":"vars.tf","path":"modules/asg-rolling-deploy/vars.tf","sha":"1c4052b26ddc2dc4ec71d5d1a759d201e5db9e9f"}]},{"name":"server-group","children":[{"name":"README.md","path":"modules/server-group/README.md","sha":"677f3bef60b5b90a1d2c32220dfd536887d7e805"},{"name":"main.tf","path":"modules/server-group/main.tf","sha":"3a9bd5e1a44f83e6a2161184f827eaf436d08ded"},{"name":"outputs.tf","path":"modules/server-group/outputs.tf","sha":"42217027f4a9807a5eae6e786b7a1cd0f6976137"},{"name":"rolling-deploy","children":[{"name":"boto3-1.7.10.zip","path":"modules/server-group/rolling-deploy/boto3-1.7.10.zip","sha":"852dcda88e4e760ce8bdb5c56823f08659959a50"},{"name":"helpers.py","path":"modules/server-group/rolling-deploy/helpers.py","sha":"cbd7f09f0877e7b18fa39e7db8dd70a7cf6eea02"},{"name":"rolling_deployment.py","path":"modules/server-group/rolling-deploy/rolling_deployment.py","sha":"e63f3e9a2072daf9d261b739ea9b6eddb2a95f0f"}]},{"name":"vars.tf","path":"modules/server-group/vars.tf","sha":"895f03d536d9922a979009284ee40dcea681944a"}]}]},{"name":"test","children":[{"name":"Gopkg.lock","path":"test/Gopkg.lock","sha":"936d6a18e6c09a998aa0e4acabc41edb3bb3d3c6"},{"name":"Gopkg.toml","path":"test/Gopkg.toml","sha":"006fb2dc5bc7b10c5e40bc3dc36eef626b0bc4bc"},{"name":"README.md","path":"test/README.md","sha":"cfa55a38cc6fbd09a311291216eb758159973629"},{"name":"asg_rolling_deploy_test.go","path":"test/asg_rolling_deploy_test.go","sha":"612907b131f214a1b6faa1546be8e1ff2de8b600"},{"name":"server_group_test.go","path":"test/server_group_test.go","sha":"6afc3507ab079a0143ada7dbace01d6f7339dbe5"},{"name":"test_helpers.go","path":"test/test_helpers.go","sha":"4034c4614efff195db3ca30f01301b11dcb8fd56"}]}]},"detailsContent":"<h1 class=\"preview__body--title\" id=\"server-group-examples\">Server Group Examples</h1><div class=\"preview__body--border\"></div><p>This folder shows examples of how to use the <a href=\"/repos/v0.14.2/module-asg/modules/server-group\" class=\"preview__body--description--blue\">server-group module</a> to deploy a cluster of\nservers that can automatically attach EBS Volumes and ENIs, do zero-downtime rolling deployment, and automatically\nreplace failed servers:</p>\n<ul>\n<li><a href=\"/repos/v0.14.2/module-asg/examples/server-group/ami\" class=\"preview__body--description--blue\">ami</a>: An example AMI meant to be used with all the other examples listed below. It installs the <code>attach-eni</code>\nand <code>mount-ebs-volume</code> scripts used by each server during boot to attach an ENI and EBS Volume, respectively.</li>\n<li><a href=\"/repos/v0.14.2/module-asg/examples/server-group/with-elb\" class=\"preview__body--description--blue\">with-elb</a>: An example of how to deploy a server-group that uses an ELB for health checks.</li>\n<li><a href=\"/repos/v0.14.2/module-asg/examples/server-group/with-alb\" class=\"preview__body--description--blue\">with-alb</a>: An example of how to deploy a server-group that uses an ALB for health checks.</li>\n<li><a href=\"/repos/v0.14.2/module-asg/examples/server-group/without-load-balancer\" class=\"preview__body--description--blue\">without-load-balancer</a>: An example of how to deploy a server-group that uses EC2 status\nchecks instead of load balancers for health checks.</li>\n</ul>\n<p>On each EC2 Instance in the server-group examples, for demonstration and testing purposes, we run a dummy web server\nthat just returns "Hello World". If you update this app (e.g. change the text to "Hello, World v2" or replace the app\nwith a totally different AMI of your own), the next time you run <code>terraform apply</code>, the new version of the app will\nroll out automatically, with no downtime.</p>\n<h2 class=\"preview__body--subtitle\" id=\"how-do-you-run-these-examples\">How do you run these examples?</h2>\n<p>Prerequisites: Install <a href=\"https://www.packer.io/\" class=\"preview__body--description--blue\" target=\"_blank\">Packer</a> and <a href=\"https://www.terraform.io/\" class=\"preview__body--description--blue\" target=\"_blank\">Terraform</a>. Also, make sure you\nhave Python installed (version 2.x) and in your <code>PATH</code>.</p>\n<ol>\n<li>Build the AMI: <code>packer build ami/server.json</code>.</li>\n<li>Open <code>vars.tf</code>, set the environment variables specified at the top of the file, and fill in any other variables that\ndon't have a default, including the ID of the AMI you built in the previous step.</li>\n<li>Run <code>terraform get</code>.</li>\n<li>Run <code>terraform plan</code>.</li>\n<li>If the plan looks good, run <code>terraform apply</code>.</li>\n</ol>\n<h2 class=\"preview__body--subtitle\" id=\"deploying-a-new-version\">Deploying a new version</h2>\n<p>Once you have the app up and running, to test out the rolling deployment, make a change to any of the variables passed\ninto the server-group module. For example, as a quick test, you could change the <code>server_text</code> variable to "Hello,\nWorld, v2.0!". Once you've made your changes, do the following:</p>\n<ol>\n<li>Commit your changes to Git so your teammates have access to them.</li>\n<li>Run <code>terraform plan</code>.</li>\n<li>If the plan looks good, run <code>terraform apply</code>.</li>\n</ol>\n<p>The new version of the app will automatically deploy across the server-group with no downtime. Check out the\n<a href=\"/repos/v0.14.2/module-asg/modules/server-group\" class=\"preview__body--description--blue\">server-group module documentation</a> for details on how this works.</p>\n","repoName":"module-asg","repoRef":"v0.8.3","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":"/examples/server-group","title":"Repo Browser: Auto Scaling Group (stateless)","description":"Browse the repos in the Gruntwork Infrastructure as Code Library."}