Terraform repository that contains a stack that deploys an static website based on a private s3 with Cloudfront, and a CI/CD pipeline that works on CodePipeline.
The stack accomplish the following requirements
-
The infrastructure should be codified using Terraform and provisioned in such a way that it can be redeployed to a different account with minor variable changes. ✔️
-
S3 should be configured as a static site and used to host the content. ✔️
-
Amazon CloudFront should be configured to distribute the content from the S3 static site. ✔️
-
Amazon CloudFront’s default behavior should be configured to not cache. ✔️
-
Amazon CloudFront should have an additional behavior configured to cache an image for a default / minimum / maximum TTL = 30 minutes. ✔️
-
Amazon CloudFront should have SSL enabled using the Default CloudFront Certificate ✔️
-
CodePipeline should be configured in such a way to deploy / update the files for the site. ✔️
-
CodePipeline should trigger off any commits or pull requests merged to a specific branch of the site’s source code git repository. ✔️
-
CodePipeline should invalidate the CloudFront Distribution after adding files to the site. ✔️
WARNING
It's important to make the connect between CodeStar-Connections and GitHub before launch first pipeline run, if not, pipeline doesn't work properly. Source: Terraform Docs
Name | Version |
---|---|
terraform | >= v0.14.11 |
Name | Version |
---|---|
aws | >= 3.56 |
Name | Type |
---|---|
aws_cloudfront_distribution.s3_distribution | resource |
aws_cloudfront_origin_access_identity.s3_web_bucket | resource |
aws_codepipeline.website_pipeline | resource |
aws_codestarconnections_connection.github | resource |
aws_iam_role.codepipeline_role | resource |
aws_s3_bucket.web_bucket | resource |
aws_caller_identity.current | data source |
aws_cloudfront_cache_policy.no-cache | data source |
aws_iam_policy_document.assume_role_codepipeline | data source |
aws_iam_policy_document.codepipeline_role_policy | data source |
aws_iam_policy_document.s3_policy | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
bucket_name | n/a | string |
n/a | yes |
pipeline_name | n/a | string |
n/a | yes |
region | AWS Region to deploy infrastructure on it | string |
n/a | yes |
web_repo_name | n/a | string |
n/a | yes |
Name | Description |
---|---|
cloudfront_endpoint | n/a |
s3_website_endpoint | n/a |