This repo contains modules that help to deploy, manage, and configure EC2 instances in AWS,
including configuring an IAM role, security group, EIP, ENI, EBS Volumes, and more.
Deploy a single EC2 instance along with the all the resources it typically needs, such as an Elastic IP address, Route 53 DNS entry, IAM Role and IAM instance profile, and security group
Mount and unmount EBS Volumes on your EC2 Instances for Volumes that need to persist between redeploys of the Instance
Create a DNS A record in Route 53 pointing to the EC2 Instance
Configure a DNS A record pointing to the instance’s IP address.
If you need help with this repo or anything else related to infrastructure or DevOps, Gruntwork offers Commercial Support via Slack, email, and phone/video. If you’re already a Gruntwork customer, hop on Slack and ask away! If not, subscribe now. If you’re not sure, feel free to email us at support@gruntwork.io.
Contributions to this repo are very welcome and appreciated! If you find a bug or want to add a new feature or even contribute an entirely new module, we are very happy to accept pull requests, provide feedback, and run your changes through our automated test suite.
{"treedata":{"name":"root","toggled":true,"children":[{"name":".circleci","children":[{"name":"config.yml","path":".circleci/config.yml","sha":"4bb022c45393384455db8c2d9a42780af195a299"}]},{"name":".gitignore","path":".gitignore","sha":"6c4ebe4426586b7febbaba178294ef59b8272c05"},{"name":".pre-commit-config.yaml","path":".pre-commit-config.yaml","sha":"d32719967fe548aec5b26866a86b40273421ddc5"},{"name":"CODEOWNERS","path":"CODEOWNERS","sha":"555c0c6e23a7502acbef94fb0b77bfa759ba11e8"},{"name":"LICENSE.txt","path":"LICENSE.txt","sha":"f4e3d9bd4717a044ed31ad847a300eee74371a78"},{"name":"README.adoc","path":"README.adoc","sha":"e9cfd4edbd25ada4ca72ba77c24b54d239702e2d","toggled":true},{"name":"_docs","children":[{"name":"aws-ec2.png","path":"_docs/aws-ec2.png","sha":"861e17a7d1df585b37d10e3211f71f6a6e182115"},{"name":"single-ec2-instance-architecture.png","path":"_docs/single-ec2-instance-architecture.png","sha":"c44f7efdb936c53fc4988f286ddcf31be8a6fdc9"}]},{"name":"core-concepts.md","path":"core-concepts.md","sha":"e362070162cd37c77875ce4e5f8e4c5f40e4b5c6"},{"name":"examples","children":[{"name":"attach-eni","children":[{"name":"README.md","path":"examples/attach-eni/README.md","sha":"86ce148cc900ce48f3debc490ce771ff5cd9fded"},{"name":"main.tf","path":"examples/attach-eni/main.tf","sha":"c5b359797dbab35bf5872c28b2eb5316278677c7"},{"name":"outputs.tf","path":"examples/attach-eni/outputs.tf","sha":"cf9472109a00b477ec4eb950e5b4e5ce9d21f4d1"},{"name":"packer","children":[{"name":"build.json","path":"examples/attach-eni/packer/build.json","sha":"a5c08a78b21285f18ff16620dbcb10bf0d93fdfc"}]},{"name":"user-data","children":[{"name":"user-data-1.sh","path":"examples/attach-eni/user-data/user-data-1.sh","sha":"978ca952d47f3dcd84881deb3723614339edbd6f"},{"name":"user-data-2.sh","path":"examples/attach-eni/user-data/user-data-2.sh","sha":"898fd7a3c7179cc0c6d595b6ccbb4b92b1b2cedb"}]},{"name":"vars.tf","path":"examples/attach-eni/vars.tf","sha":"c8bd5aa7b155cf011bd03e3c6bf76a79fd1be4d5"}]},{"name":"bastion-host","children":[{"name":"README.md","path":"examples/bastion-host/README.md","sha":"29868dbc60695e2418906c568734eec22a411454"},{"name":"main.tf","path":"examples/bastion-host/main.tf","sha":"f8d1da4a1086f193097cfda85af5a40378f8e965"},{"name":"outputs.tf","path":"examples/bastion-host/outputs.tf","sha":"5f0c2d739b9646c39e19bfd05cacb852c6080c0c"},{"name":"user-data.sh","path":"examples/bastion-host/user-data.sh","sha":"1f5d58de29f4b834fd43db38f2ad8723fa84ec5f"},{"name":"vars.tf","path":"examples/bastion-host/vars.tf","sha":"3864d03b7a4035b0c6e41d35f8829b886790f282"}]},{"name":"ec2-backup","children":[{"name":"README.md","path":"examples/ec2-backup/README.md","sha":"782667373dc4d7cf602fea0e05d6b78ed47d2c42"},{"name":"main.tf","path":"examples/ec2-backup/main.tf","sha":"03c40fb2db38148051702dfbb3f56104d06487aa"},{"name":"outputs.tf","path":"examples/ec2-backup/outputs.tf","sha":"6023311f87f6757e60e5d47600095cbc6dce324a"},{"name":"variables.tf","path":"examples/ec2-backup/variables.tf","sha":"e6e9fa9520608ef0a5cc0aadc70d118775543b03"}]},{"name":"persistent-ebs-volume","children":[{"name":"README.md","path":"examples/persistent-ebs-volume/README.md","sha":"7acf321a8a3183bfe4d7187be94208ed281bcd66"},{"name":"main.tf","path":"examples/persistent-ebs-volume/main.tf","sha":"77ad324e880885974bd90ccd3211c4aa96f696bd"},{"name":"outputs.tf","path":"examples/persistent-ebs-volume/outputs.tf","sha":"54f33c96b796373b12b9702f46d30a1c85043f65"},{"name":"packer","children":[{"name":"build.json","path":"examples/persistent-ebs-volume/packer/build.json","sha":"51f6801445fa7228afe5487fc03fa016a902e7f4"},{"name":"nvme_build.json","path":"examples/persistent-ebs-volume/packer/nvme_build.json","sha":"505d130d5bad4983fa6b3dcbae1f39d02daa7643"}]},{"name":"user-data","children":[{"name":"user-data.sh","path":"examples/persistent-ebs-volume/user-data/user-data.sh","sha":"6793c2066296ff24917f6a86c43ad9674dd53624"}]},{"name":"vars.tf","path":"examples/persistent-ebs-volume/vars.tf","sha":"6f26667744846a28777af25bb3b311b1bf34a1bf"}]},{"name":"route53-helpers","children":[{"name":"README.md","path":"examples/route53-helpers/README.md","sha":"e302ef0f18f85a3a191105dea785005685b9522f"},{"name":"main.tf","path":"examples/route53-helpers/main.tf","sha":"6c9796c7577bf30cb600c6145a6f7320f43160e6"},{"name":"outputs.tf","path":"examples/route53-helpers/outputs.tf","sha":"4c3c3ccccf964155ffbce7546fcbc9ef6e886de6"},{"name":"packer","children":[{"name":"build.json","path":"examples/route53-helpers/packer/build.json","sha":"b419e0ef86077ce8149908febbf7049c5e7eb659"}]},{"name":"user-data","children":[{"name":"user-data.sh","path":"examples/route53-helpers/user-data/user-data.sh","sha":"7f4de426ead32d966fe46d7091a1d293cb3ca099"}]},{"name":"vars.tf","path":"examples/route53-helpers/vars.tf","sha":"3c990b1e4ae4da54aac558cf24124e29cd362931"}]}]},{"name":"modules","children":[{"name":"attach-eni","children":[{"name":"README.md","path":"modules/attach-eni/README.md","sha":"baa975b1c3bf21ec9ed61792f983ae2cd889570e"},{"name":"bin","children":[{"name":"attach-eni","path":"modules/attach-eni/bin/attach-eni","sha":"451ce2e389f74b988a0a3bdc4a1ac28fd150a8e3"}]},{"name":"install.sh","path":"modules/attach-eni/install.sh","sha":"542cbd93ca08fd9cbe6f121f4d8fea2b1d76ca8b"}]},{"name":"ec2-backup","children":[{"name":"README.md","path":"modules/ec2-backup/README.md","sha":"d5846d75798a42be721ce2742f4449f33c03356e"},{"name":"main.tf","path":"modules/ec2-backup/main.tf","sha":"f3b85a2ebf42dd908b2b3d9f6e288247af578e2c"},{"name":"outputs.tf","path":"modules/ec2-backup/outputs.tf","sha":"19b7bd464c3c0916e03bff6f4f2cf69b671041ed"},{"name":"variables.tf","path":"modules/ec2-backup/variables.tf","sha":"d590cf90b9a1060c9f003f64d82085d183c5e8f2"}]},{"name":"persistent-ebs-volume","children":[{"name":"README.md","path":"modules/persistent-ebs-volume/README.md","sha":"d1c5af199f667269db707427f7aa4df745242a98"},{"name":"bin","children":[{"name":"mount-ebs-volume","path":"modules/persistent-ebs-volume/bin/mount-ebs-volume","sha":"46cc65171354b261affdccde92f846d43b39268a"},{"name":"unmount-ebs-volume","path":"modules/persistent-ebs-volume/bin/unmount-ebs-volume","sha":"2eddbccd97812577f68964e3903a46953611a270"}]},{"name":"install.sh","path":"modules/persistent-ebs-volume/install.sh","sha":"e0ce5862cd6975992dc011a6dfe94fdf14a9b607"}]},{"name":"route53-helpers","children":[{"name":"README.md","path":"modules/route53-helpers/README.md","sha":"5db9fd7c46f8ea3abdaf7b58da18a22a09762e9e"},{"name":"bin","children":[{"name":"add-dns-a-record","path":"modules/route53-helpers/bin/add-dns-a-record","sha":"7195a02479864ec79071cfae429bd545bf7d8d32"}]},{"name":"install.sh","path":"modules/route53-helpers/install.sh","sha":"535ed35d64611c5f12e9924b3cb8df0a77180ab8"}]},{"name":"single-server","children":[{"name":"README.md","path":"modules/single-server/README.md","sha":"06e89161f791d6e25a489567aae25c9171b1a723"},{"name":"main.tf","path":"modules/single-server/main.tf","sha":"662c79dca46711799da496acb3bf37607215b940"},{"name":"outputs.tf","path":"modules/single-server/outputs.tf","sha":"b9f31b1a8dcdcd8b93d7f8abed97bb6280da9fc6"},{"name":"vars.tf","path":"modules/single-server/vars.tf","sha":"db49b23120dde69d8984503225b799a3874d2870"}]}]},{"name":"test","children":[{"name":"README.md","path":"test/README.md","sha":"ef26d3851db2fff0b36dfa61379724c0db9ff281"},{"name":"attach_eni_test.go","path":"test/attach_eni_test.go","sha":"9f09501b7854ae6853a96810042b1b0be794a997"},{"name":"bastion_host_test.go","path":"test/bastion_host_test.go","sha":"0001a84a6a1a5081175de46d8ec13b0057754976"},{"name":"ec2_backup_test.go","path":"test/ec2_backup_test.go","sha":"73ae620eb4bbec7771bfc614e676935956134e9d"},{"name":"go.mod","path":"test/go.mod","sha":"b0aa30822b7ababcec6c50856b02e85d5f76ea81"},{"name":"go.sum","path":"test/go.sum","sha":"a8d936c3427cf59e7d52d2d5285f96d19a53fe5d"},{"name":"persistent_ebs_volume_test.go","path":"test/persistent_ebs_volume_test.go","sha":"d03eab0c1940e15396b047e24d12b4ac8b0f54b1"},{"name":"route53_helpers_test.go","path":"test/route53_helpers_test.go","sha":"0470764ebb949ddcfe484f2164d48884fd503cf2"},{"name":"test_helpers.go","path":"test/test_helpers.go","sha":"88a0a959547631589f956f6ae8304429a51a6ea2"}]}]},"detailsContent":"<div id=\"preamble\">\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p><span class=\"image\"><a class=\"image\" href=\"https://gruntwork.io/?ref=repo_module-server\" target=\"_blank\"><img src=\"https://img.shields.io/badge/maintained%20by-gruntwork.io-%235849a6.svg\" alt=\"maintained%20by gruntwork.io %235849a6\" class=\"preview__body--diagram\"></a></span>\n<span class=\"image\"><img src=\"https://img.shields.io/badge/tf-%3E%3D0.12.0-blue.svg\" alt=\"Terraform version\" class=\"preview__body--diagram\"></span></p>\n</div>\n<div class=\"paragraph\">\n<p>This repo contains modules that help to deploy, manage, and configure EC2 instances in <a href=\"https://aws.amazon.com\" target=\"_blank\">AWS</a>,\nincluding configuring an IAM role, security group, EIP, ENI, EBS Volumes, and more.</p>\n</div>\n<div class=\"imageblock\">\n<div class=\"content\">\n<img src=\"/repos/images/v0.9.3/module-server/_docs/single-ec2-instance-architecture.png?raw=true\" alt=\"Module Server\" class=\"preview__body--diagram\">\n</div>\n</div>\n<div id=\"toc\" class=\"toc\">\n<div id=\"toctitle\" class=\"title\"></div>\n<ul class=\"sectlevel1\">\n<li><a href=\"#_features\">Features</a></li>\n<li><a href=\"#_learn\">Learn</a>\n<ul class=\"sectlevel2\">\n<li><a href=\"#_core_concepts\">Core concepts</a></li>\n<li><a href=\"#_repo_organization\">Repo organization</a></li>\n</ul>\n</li>\n<li><a href=\"#_deploy\">Deploy</a>\n<ul class=\"sectlevel2\">\n<li><a href=\"#_non_production_deployment_quick_start_for_learning\">Non-production deployment (quick start for learning)</a></li>\n<li><a href=\"#_production_deployment\">Production deployment</a></li>\n</ul>\n</li>\n<li><a href=\"#_support\">Support</a></li>\n<li><a href=\"#_contributions\">Contributions</a></li>\n<li><a href=\"#_license\">License</a></li>\n</ul>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_features\"><a class=\"anchor\" href=\"#_features\"></a><a class=\"link\" href=\"#_features\">Features</a></h2>\n<div class=\"sectionbody\">\n<div class=\"ulist\">\n<ul>\n<li>\n<p>Deploy a single EC2 instance along with the all the resources it typically needs, such as an Elastic IP address, Route 53 DNS entry, IAM Role and IAM instance profile, and security group</p>\n</li>\n<li>\n<p>Mount and unmount EBS Volumes on your EC2 Instances for Volumes that need to persist between redeploys of the Instance</p>\n</li>\n<li>\n<p>Create a DNS A record in Route 53 pointing to the EC2 Instance</p>\n</li>\n<li>\n<p>Configure a DNS A record pointing to the instance’s IP address.</p>\n</li>\n</ul>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_learn\"><a class=\"anchor\" href=\"#_learn\"></a><a class=\"link\" href=\"#_learn\">Learn</a></h2>\n<div class=\"sectionbody\">\n<div class=\"sect2\">\n<h3 id=\"_core_concepts\"><a class=\"anchor\" href=\"#_core_concepts\"></a><a class=\"link\" href=\"#_core_concepts\">Core concepts</a></h3>\n<div class=\"ulist\">\n<ul>\n<li>\n<p><a href=\"https://gruntwork.io/guides/foundations/how-to-configure-production-grade-aws-account-structure/#iam-users\" target=\"_blank\">Learn about IAM Users, Roles and Policies</a></p>\n</li>\n<li>\n<p><a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html\" target=\"_blank\">What is Amazon EC2?</a></p>\n</li>\n<li>\n<p><a href=\"https://aws.amazon.com/answers/security/aws-securing-ec2-instances/\" target=\"_blank\">Securing Amazon EC2 Instances</a></p>\n</li>\n<li>\n<p><a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html\" target=\"_blank\">Learn about Elastic IP Addresses</a></p>\n</li>\n<li>\n<p><a href=\"https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html\" target=\"_blank\">What is Amazon Route 53?</a></p>\n</li>\n<li>\n<p><a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html\" target=\"_blank\">Learn about Amazon EBS</a></p>\n</li>\n</ul>\n</div>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_repo_organization\"><a class=\"anchor\" href=\"#_repo_organization\"></a><a class=\"link\" href=\"#_repo_organization\">Repo organization</a></h3>\n<div class=\"ulist\">\n<ul>\n<li>\n<p><a href=\"/repos/v0.9.3/module-server/modules\">modules</a>: the main implementation code for this repo, broken down into multiple standalone, orthogonal submodules.</p>\n</li>\n<li>\n<p><a href=\"/repos/v0.9.3/module-server/examples\">examples</a>: This folder contains working examples of how to use the submodules.</p>\n</li>\n<li>\n<p><a href=\"/repos/v0.9.3/module-server/test\">test</a>: Automated tests for the modules and examples.</p>\n</li>\n</ul>\n</div>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_deploy\"><a class=\"anchor\" href=\"#_deploy\"></a><a class=\"link\" href=\"#_deploy\">Deploy</a></h2>\n<div class=\"sectionbody\">\n<div class=\"sect2\">\n<h3 id=\"_non_production_deployment_quick_start_for_learning\"><a class=\"anchor\" href=\"#_non_production_deployment_quick_start_for_learning\"></a><a class=\"link\" href=\"#_non_production_deployment_quick_start_for_learning\">Non-production deployment (quick start for learning)</a></h3>\n<div class=\"paragraph\">\n<p>If you just want to try this repo out for experimenting and learning, check out the following resources:</p>\n</div>\n<div class=\"paragraph\">\n<p><a href=\"/repos/v0.9.3/module-server/examples\">examples folder</a>: The examples folder contains sample code optimized for learning, experimenting, and testing (but not production usage).</p>\n</div>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_production_deployment\"><a class=\"anchor\" href=\"#_production_deployment\"></a><a class=\"link\" href=\"#_production_deployment\">Production deployment</a></h3>\n<div class=\"paragraph\">\n<p>We do not have any production examples of single-server, as we typically use Amazon Scaling Groups(ASGs) for high availability.</p>\n</div>\n<div class=\"paragraph\">\n<p>For production examples of <code>mount-ebs-volume</code> and <code>attach-eni</code>, you can view the <a href=\"/repos/infrastructure-modules-multi-account-acme/data-stores/zookeeper\">ZooKeeper module</a>.</p>\n</div>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_support\"><a class=\"anchor\" href=\"#_support\"></a><a class=\"link\" href=\"#_support\">Support</a></h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>If you need help with this repo or anything else related to infrastructure or DevOps, Gruntwork offers <a href=\"https://gruntwork.io/support/\" target=\"_blank\">Commercial Support</a> via Slack, email, and phone/video. If you’re already a Gruntwork customer, hop on Slack and ask away! If not, <a href=\"https://www.gruntwork.io/pricing/\" target=\"_blank\">subscribe now</a>. If you’re not sure, feel free to email us at <a href=\"mailto:support@gruntwork.io\" target=\"_blank\">support@gruntwork.io</a>.</p>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_contributions\"><a class=\"anchor\" href=\"#_contributions\"></a><a class=\"link\" href=\"#_contributions\">Contributions</a></h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>Contributions to this repo are very welcome and appreciated! If you find a bug or want to add a new feature or even contribute an entirely new module, we are very happy to accept pull requests, provide feedback, and run your changes through our automated test suite.</p>\n</div>\n<div class=\"paragraph\">\n<p>Please see <a href=\"https://gruntwork.io/guides/foundations/how-to-use-gruntwork-infrastructure-as-code-library/#contributing-to-the-gruntwork-infrastructure-as-code-library\" target=\"_blank\">Contributing to the Gruntwork Infrastructure as Code Library</a> for instructions.</p>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_license\"><a class=\"anchor\" href=\"#_license\"></a><a class=\"link\" href=\"#_license\">License</a></h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>Please see <a href=\"/repos/v0.9.3/module-server/LICENSE.txt\">LICENSE.txt</a> for details on how the code in this repo is licensed.</p>\n</div>\n</div>\n</div>","repoName":"module-server","repoRef":"v0.9.0","serviceDescriptor":{"serviceName":"Single EC2 Instance","serviceRepoName":"module-server","serviceRepoOrg":"gruntwork-io","cloudProviders":["aws"],"description":"Run a single EC2 instance for stateless or stateful apps. Supports IAM roles, EBS volumes, ENIs, and EIPs.","imageUrl":"single-service.png","licenseType":"subscriber","technologies":["Terraform","Bash"],"compliance":[],"tags":[""]},"serviceCategoryName":"Server orchestration","fileName":"README.adoc","filePath":"","title":"Repo Browser: Single EC2 Instance","description":"Browse the repos in the Gruntwork Infrastructure as Code Library."}