The add-dns-a-record script has the following prerequisites:
It must be run on an EC2 instance
The EC2 instance must have an IAM role with permissions to modify Route 53 entries (see below)
The EC2 instance must have the AWS CLI and jq installed
To run the script, simply pass it the AWS region, the id of the hosted
zone where the DNS entry should be
added, and the hostname to use for the DNS entry:
{"treedata":{"name":"root","toggled":true,"children":[{"name":".circleci","children":[{"name":"config.yml","path":".circleci/config.yml","sha":"b210516f03c95b2a526a67150d18f6219f544aec"}]},{"name":".gitignore","path":".gitignore","sha":"6c4ebe4426586b7febbaba178294ef59b8272c05"},{"name":"CODEOWNERS","path":"CODEOWNERS","sha":"7769a004705df41853017db41c273a1ae668fe49"},{"name":"LICENSE.txt","path":"LICENSE.txt","sha":"f4e3d9bd4717a044ed31ad847a300eee74371a78"},{"name":"README.md","path":"README.md","sha":"bb749b57c528b40496c43682f05a977340840644"},{"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":"624da18516f8eb9556025ab278d40e44554704a7"},{"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":"289179e20edb0b228f886123ec890137f193e4a6"}]},{"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":"0705506a64c05e1def52aa4436c66004c1e68d72"},{"name":"outputs.tf","path":"examples/bastion-host/outputs.tf","sha":"5f0c2d739b9646c39e19bfd05cacb852c6080c0c"},{"name":"user-data","children":[{"name":"user-data.sh","path":"examples/bastion-host/user-data/user-data.sh","sha":"1b42f0578f9db505bca7e5ae649a116818cd5592"}]},{"name":"vars.tf","path":"examples/bastion-host/vars.tf","sha":"3864d03b7a4035b0c6e41d35f8829b886790f282"}]},{"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":"4f63a52e643559cef221b6b0cee31f334da6f7bd"},{"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":"2af311a5e22546182a61d3506c93648ddc9e2299"},{"name":"nvme_build.json","path":"examples/persistent-ebs-volume/packer/nvme_build.json","sha":"f67e4760622729ab762788408ef8a750dfead67c"}]},{"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":"63f89d02af52ada2ae60dd5696f83d0ce2c9df3a"},{"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":"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","toggled":true},{"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"}],"toggled":true},{"name":"single-server","children":[{"name":"README.md","path":"modules/single-server/README.md","sha":"e13edaea6a6642708e8225a236c5a5cd24f9210f"},{"name":"main.tf","path":"modules/single-server/main.tf","sha":"fa5cfba31e449d322027940353c890dd61dafb17"},{"name":"outputs.tf","path":"modules/single-server/outputs.tf","sha":"d741f20d4df1b70b29f3261ef14b8636248c2738"},{"name":"vars.tf","path":"modules/single-server/vars.tf","sha":"15f8bf8f812eff41231df0be6a62930b17a59d39"}]}],"toggled":true},{"name":"test","children":[{"name":"Gopkg.lock","path":"test/Gopkg.lock","sha":"0fa4c35d5eadc7dfc6d357761de6573e1b22c5c5"},{"name":"Gopkg.toml","path":"test/Gopkg.toml","sha":"2d99de7b5a81ebd0fab05a6f77de4aa01d80b7a7"},{"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":"f3ab20153e5d5ce657e054a3fec6a647c914e645"},{"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":"ec0f7a355075ff7d4362203b94abcc5fffaf0c4b"},{"name":"test_helpers.go","path":"test/test_helpers.go","sha":"8709fe4e7bd2d6112fe31a6ce58b62d76c8267fc"}]}]},"detailsContent":"<h1 class=\"preview__body--title\" id=\"route-53-helpers\">Route 53 Helpers</h1><div class=\"preview__body--border\"></div><p>This folder contains helper scripts for working with Amazon's DNS Service, <a href=\"https://aws.amazon.com/route53/\" class=\"preview__body--description--blue\" target=\"_blank\">Route 53</a>.\nThe helpers are:</p>\n<ul>\n<li><code>add-dns-a-record</code>: A script that can be run on an EC2 instance to add a DNS A record pointing to the instance's IP\naddress.</li>\n</ul>\n<p>Check out the <a href=\"/repos/v0.8.1/module-server/examples/route53-helpers\" class=\"preview__body--description--blue\">route53-helpers example</a> for how to use these scripts with Terraform.</p>\n<h2 class=\"preview__body--subtitle\" id=\"installing-the-helpers\">Installing the helpers</h2>\n<p>You can install the helpers using the <a href=\"/repos/gruntwork-installer\" class=\"preview__body--description--blue\">Gruntwork Installer</a>:</p>\n<pre><span class=\"hljs-string\">gruntwork-install </span><span class=\"hljs-built_in\">--module-name</span> <span class=\"hljs-string\">\"route53-helpers\"</span> <span class=\"hljs-built_in\">--repo</span> <span class=\"hljs-string\">\"https://github.com/gruntwork-io/module-server\"</span> <span class=\"hljs-built_in\">--tag</span> <span class=\"hljs-string\">\"0.0.3\"</span>\n</pre>\n<h2 class=\"preview__body--subtitle\" id=\"using-the-add-dns-a-record-helper\">Using the add-dns-a-record helper</h2>\n<p>The <code>add-dns-a-record</code> script has the following prerequisites:</p>\n<ol>\n<li>It must be run on an EC2 instance</li>\n<li>The EC2 instance must have an IAM role with permissions to modify Route 53 entries (see below)</li>\n<li>The EC2 instance must have the AWS CLI and jq installed</li>\n</ol>\n<p>To run the script, simply pass it the AWS region, the id of the <a href=\"http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/AboutHostedZones.html\" class=\"preview__body--description--blue\" target=\"_blank\">hosted\nzone</a> where the DNS entry should be\nadded, and the hostname to use for the DNS entry:</p>\n<pre><span class=\"hljs-comment\">add</span><span class=\"hljs-literal\">-</span><span class=\"hljs-comment\">dns</span><span class=\"hljs-literal\">-</span><span class=\"hljs-comment\">a</span><span class=\"hljs-literal\">-</span><span class=\"hljs-comment\">record</span> --<span class=\"hljs-comment\">aws</span><span class=\"hljs-literal\">-</span><span class=\"hljs-comment\">region</span> <span class=\"hljs-comment\">us</span><span class=\"hljs-literal\">-</span><span class=\"hljs-comment\">east</span><span class=\"hljs-literal\">-</span><span class=\"hljs-comment\">1</span> --<span class=\"hljs-comment\">hosted</span><span class=\"hljs-literal\">-</span><span class=\"hljs-comment\">zone</span><span class=\"hljs-literal\">-</span><span class=\"hljs-comment\">id</span> <span class=\"hljs-comment\">ASDF123456</span> --<span class=\"hljs-comment\">hostname</span> <span class=\"hljs-comment\">foo</span><span class=\"hljs-string\">.</span><span class=\"hljs-comment\">my</span><span class=\"hljs-literal\">-</span><span class=\"hljs-comment\">company</span><span class=\"hljs-string\">.</span><span class=\"hljs-comment\">com</span>\n</pre>\n<p>Run <code>add-dns-a-record --help</code> to see all available options.</p>\n<h2 class=\"preview__body--subtitle\" id=\"iam-permissions\">IAM Permissions</h2>\n<p>Here is an example of an IAM policy your EC2 instance needs attached to its IAM role to run these scripts:</p>\n<pre>{\n <span class=\"hljs-attr\">\"Version\"</span>: <span class=\"hljs-string\">\"2012-10-17\"</span>,\n <span class=\"hljs-attr\">\"Statement\"</span>: [\n {\n <span class=\"hljs-attr\">\"Sid\"</span>: <span class=\"hljs-string\">\"\"</span>,\n <span class=\"hljs-attr\">\"Action\"</span>: <span class=\"hljs-string\">\"route53:ChangeResourceRecordSets\"</span>,\n <span class=\"hljs-attr\">\"Effect\"</span>: <span class=\"hljs-string\">\"Allow\"</span>,\n <span class=\"hljs-attr\">\"Resource\"</span>: <span class=\"hljs-string\">\"arn:aws:route53:::hostedzone/<ID_OF_HOSTED_ZONE>\"</span>\n }\n ]\n}\n</pre>\n<p>Check out the <a href=\"/repos/v0.8.1/module-server/examples/route53-helpers\" class=\"preview__body--description--blue\">route53-helpers example</a> to see what this looks like in action.</p>\n","repoName":"module-server","repoRef":"v0.7.7","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.md","filePath":"/modules/route53-helpers","title":"Repo Browser: Single EC2 Instance","description":"Browse the repos in the Gruntwork Infrastructure as Code Library."}