This example also leverges the Origin Group feature of CloudFront to allow for a failover bucket to be utilized. This example will make a second bucket that will be used as a failover in the event that the first bucket's contents are not accessable.
Quick start
To try these templates out you must have Terraform installed:
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.
Run terraform get.
Run terraform plan.
If the plan looks good, run terraform apply.
When the apply command finishes, this module will output the domain name you can use to test the website in your
browser.
Note that a CloudFront distribution can take a LONG time to deploy (i.e. sometimes as much as 15 - 30 minutes!), so
before testing the URL, head over to the CloudFront distributions
page and wait for the "Status" of your distribution
to show up as "Deployed".
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":"a13b7823aa66e7dc9796b1a0968c6842812b688b"}]},{"name":".gitignore","path":".gitignore","sha":"42cd2961e573dc1870292a576ddbb7d4d07cca6a"},{"name":"CODEOWNERS","path":"CODEOWNERS","sha":"7a0d0af6ee8361466674f9367fab91f9037b5c75"},{"name":"LICENSE.txt","path":"LICENSE.txt","sha":"f4e3d9bd4717a044ed31ad847a300eee74371a78"},{"name":"README.md","path":"README.md","sha":"a940fce1a435db01e0a90343bc30fbc1664d573a"},{"name":"examples","children":[{"name":"bin","children":[{"name":"s3-upload.sh","path":"examples/bin/s3-upload.sh","sha":"616167707b12a9ed678286f6829d06ae39b8bfb0"}]},{"name":"cloudfront-s3-private-origin-group","children":[{"name":"README.md","path":"examples/cloudfront-s3-private-origin-group/README.md","sha":"a0c7c49eb8bb405624377174bf28c48e806baf44"},{"name":"main.tf","path":"examples/cloudfront-s3-private-origin-group/main.tf","sha":"66ed5e32595587b69624bdc5b8f4b6cb39778f9b"},{"name":"outputs.tf","path":"examples/cloudfront-s3-private-origin-group/outputs.tf","sha":"7ad8a7de25248890dd41ec74575fb18e206cf93b"},{"name":"vars.tf","path":"examples/cloudfront-s3-private-origin-group/vars.tf","sha":"58848af7c7064fe5054c4612f3f48911db5182eb"}]},{"name":"cloudfront-s3-private","children":[{"name":"README.md","path":"examples/cloudfront-s3-private/README.md","sha":"03ae92790de376455152698d267caf86d2348911"},{"name":"main.tf","path":"examples/cloudfront-s3-private/main.tf","sha":"9e948f2cbb82473fce9c8ca51557098195840e9e"},{"name":"outputs.tf","path":"examples/cloudfront-s3-private/outputs.tf","sha":"4028b7c112eb547208079b450305f8560d451deb"},{"name":"vars.tf","path":"examples/cloudfront-s3-private/vars.tf","sha":"6c831e531701b3ae5745aa968008d28e1c6bc7a1"}]},{"name":"cloudfront-s3-public-origin-group","children":[{"name":"README.md","path":"examples/cloudfront-s3-public-origin-group/README.md","sha":"80e5a99578d8c9eba230531ac040a8e82aebfebd","toggled":true},{"name":"main.tf","path":"examples/cloudfront-s3-public-origin-group/main.tf","sha":"dbddcbf9bd09eaafd7688dea6e64f270c892b3ac"},{"name":"outputs.tf","path":"examples/cloudfront-s3-public-origin-group/outputs.tf","sha":"7ad8a7de25248890dd41ec74575fb18e206cf93b"},{"name":"vars.tf","path":"examples/cloudfront-s3-public-origin-group/vars.tf","sha":"627d6c64c757b21e2b4ac175dfa72a9cf4df36b9"}],"toggled":true},{"name":"cloudfront-s3-public","children":[{"name":"README.md","path":"examples/cloudfront-s3-public/README.md","sha":"aed32ebaa3e145939ee0e027125583200673c104"},{"name":"main.tf","path":"examples/cloudfront-s3-public/main.tf","sha":"dd356b7e0c0397d35416cc4065533e5da3bcd969"},{"name":"outputs.tf","path":"examples/cloudfront-s3-public/outputs.tf","sha":"4028b7c112eb547208079b450305f8560d451deb"},{"name":"vars.tf","path":"examples/cloudfront-s3-public/vars.tf","sha":"48d19258f4605b2c687d13336f6ac77358d45c54"}]},{"name":"example-website","children":[{"name":"README.md","path":"examples/example-website/README.md","sha":"359ae6d06f8e77244f18c42704637b8e6ef498c6"},{"name":"error.html","path":"examples/example-website/error.html","sha":"b2b8878e00a2f707b709ae699ce466c543eab954"},{"name":"grunty.png","path":"examples/example-website/grunty.png","sha":"fa4bab8d46d843cd22b20f16bcda72e9d4c86680"},{"name":"index.html","path":"examples/example-website/index.html","sha":"a7a486627108114d5ca4a21f856e3b410c6b73e2"}]},{"name":"s3-static-website","children":[{"name":"README.md","path":"examples/s3-static-website/README.md","sha":"a2d9c34b338551214ccf7df40d63bfa98ae5bae6"},{"name":"main.tf","path":"examples/s3-static-website/main.tf","sha":"307eb8cc97c3d9fa63e5dbf7d22f5b351d433d63"},{"name":"outputs.tf","path":"examples/s3-static-website/outputs.tf","sha":"7c6be384ebcdb5c66d9432617ae165919160e006"},{"name":"vars.tf","path":"examples/s3-static-website/vars.tf","sha":"ac474a07ba42f7c39459d1a2a746a3ae3bf543ef"}]}],"toggled":true},{"name":"modules","children":[{"name":"_docs","children":[{"name":"s3-architecture.png","path":"modules/_docs/s3-architecture.png","sha":"24664de39064d5c6767105b75d002bddf763ff82"},{"name":"s3.png","path":"modules/_docs/s3.png","sha":"667a181c90817858914551e9b2fa376fa1c8f177"}]},{"name":"s3-cloudfront","children":[{"name":"README.md","path":"modules/s3-cloudfront/README.md","sha":"5b69068481d80e58832ea79b945458ce392e6ad7"},{"name":"main.tf","path":"modules/s3-cloudfront/main.tf","sha":"3eab2f87292addd1afa54bf0e440d0335633dfc9"},{"name":"outputs.tf","path":"modules/s3-cloudfront/outputs.tf","sha":"fb0e7380080e2b16420ac47f255841ce468686cb"},{"name":"vars.tf","path":"modules/s3-cloudfront/vars.tf","sha":"20e623b6980e6e769a1a59e74a6d1032b0f24720"}]},{"name":"s3-static-website","children":[{"name":"README.adoc","path":"modules/s3-static-website/README.adoc","sha":"b602e5d4fbf1b19d42d3df1c8ff5facfbc9397de"},{"name":"core-concepts.md","path":"modules/s3-static-website/core-concepts.md","sha":"1cb65fe1aeb7081449431c56a8fc7dc5ba05007b"},{"name":"main.tf","path":"modules/s3-static-website/main.tf","sha":"6e6484a4673c538335609539fd980b6b017426f4"},{"name":"outputs.tf","path":"modules/s3-static-website/outputs.tf","sha":"9af4b14aee55ded582d970656949f3f7ae5647af"},{"name":"vars.tf","path":"modules/s3-static-website/vars.tf","sha":"c5e7662c09a410135b72ba115d792e7621631408"}]}]},{"name":"test","children":[{"name":"Gopkg.lock","path":"test/Gopkg.lock","sha":"03773d142d1feac30669f3c13032d289d9e3a398"},{"name":"Gopkg.toml","path":"test/Gopkg.toml","sha":"a84c6ed7e5bfce6f72e9e08666f1665af01a3f84"},{"name":"README.md","path":"test/README.md","sha":"677e87a94c28a43bc370cf3641fa5390a3cd3b63"},{"name":"s3_cloudfront_canonical_user_test.go","path":"test/s3_cloudfront_canonical_user_test.go","sha":"cdddc74e688c82fffea183946fe0ed3d66581de8"},{"name":"s3_cloudfront_origin_group_test.go","path":"test/s3_cloudfront_origin_group_test.go","sha":"46aa9d45071a6d563596e131df875d34df054532"},{"name":"s3_cloudfront_perpetual_diff_test.go","path":"test/s3_cloudfront_perpetual_diff_test.go","sha":"7f08a006ec3dd839af4e0f7456de3648052abf06"},{"name":"s3_cloudfront_test.go","path":"test/s3_cloudfront_test.go","sha":"bd6afba183d1d17670746c3040a2d87f9e6246ee"},{"name":"s3_static_website_test.go","path":"test/s3_static_website_test.go","sha":"57110da7d6ecc3e3b941c59128c84b3c25524cf3"},{"name":"test_helpers.go","path":"test/test_helpers.go","sha":"13abdb0c2881ad74383328a6b7966a6c0a7fb7ce"}]}]},"detailsContent":"<h1 class=\"preview__body--title\" id=\"cloud-front-using-an-origin-group-s-3-public-website-example\">CloudFront (using an Origin Group) + S3 public website example</h1><div class=\"preview__body--border\"></div><p>This folder shows an example of how to use the <a href=\"/repos/v0.17.1/package-static-assets/modules/s3-cloudfront\" class=\"preview__body--description--blue\">s3-cloudfront</a> and\n<a href=\"/repos/v0.17.1/package-static-assets/modules/s3-static-website\" class=\"preview__body--description--blue\">s3-static-website</a> modules to deploy a CloudFront distribution as a CDN in front of a\npublic S3 bucket configured as a website. Make sure to read the <a href=\"/repos/v0.17.1/package-static-assets/modules/s3-cloudfront#public-vs-private-s3-buckets\" class=\"preview__body--description--blue\">Public vs private S3 buckets\ndocumentation</a> to understand the difference between this example\nand the <a href=\"/repos/v0.17.1/package-static-assets/examples/cloudfront-s3-private\" class=\"preview__body--description--blue\">cloudfront-s3-private example</a>.</p>\n<p>This example also leverges the Origin Group feature of CloudFront to allow for a failover bucket to be utilized. This example will make a second bucket that will be used as a failover in the event that the first bucket's contents are not accessable.</p>\n<h2 class=\"preview__body--subtitle\" id=\"quick-start\">Quick start</h2>\n<p>To try these templates out you must have Terraform installed:</p>\n<ol>\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.</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<p>When the <code>apply</code> command finishes, this module will output the domain name you can use to test the website in your\nbrowser.</p>\n<p>Note that a CloudFront distribution can take a LONG time to deploy (i.e. sometimes as much as 15 - 30 minutes!), so\nbefore testing the URL, head over to the <a href=\"https://console.aws.amazon.com/cloudfront/home#distributions:\" class=\"preview__body--description--blue\" target=\"_blank\">CloudFront distributions\npage</a> and wait for the "Status" of your distribution\nto show up as "Deployed".</p>\n","repoName":"package-static-assets","repoRef":"v0.6.2","serviceDescriptor":{"serviceName":"S3","serviceRepoName":"package-static-assets","serviceRepoOrg":"gruntwork-io","serviceMainReadmePath":"/modules/s3-static-website","cloudProviders":["aws"],"description":"Deploy your static content and static websites on S3. Supports bucket versioning, redirects, and access logging.","imageUrl":"amazon-s3.png","licenseType":"subscriber","technologies":["Terraform"],"compliance":[],"tags":[""]},"serviceCategoryName":"Static content","fileName":"README.md","filePath":"/examples/cloudfront-s3-public-origin-group","title":"Repo Browser: S3","description":"Browse the repos in the Gruntwork Infrastructure as Code Library."}