DEPRECATED
Use the
cloudfront
module instead
Common infrastructure for single page applications
Module creates:
- AWS S3 bucket for storing assets
- AWS CloudFront distribution for serving the assets
- AWS IAM role for adding middleware Lambda@Edge functions
- Optional basic auth and pull request routing Lambdas
Name | Version |
---|---|
terraform | >= 0.12, <2.0 |
aws | >= 2.40.0 |
Name | Version |
---|---|
aws | >= 2.40.0 |
Name | Source | Version |
---|---|---|
basic_auth | ./middleware | n/a |
middleware_common | ./middleware_common | n/a |
pull_request_router | ./middleware | n/a |
Name | Type |
---|---|
aws_cloudfront_distribution.assets | resource |
aws_cloudfront_origin_access_identity.assets | resource |
aws_iam_policy.ci | resource |
aws_s3_bucket.assets | resource |
aws_s3_bucket_policy.assets | resource |
aws_iam_policy_document.assets_cdn | data source |
aws_iam_policy_document.assets_cdn_website | data source |
aws_iam_policy_document.ci | data source |
aws_region.current | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
basic_auth_archive_path | Path where the basic auth lambda package will be created. See spa/middleware archive_path input for details. |
string |
null |
no |
basic_auth_credentials | Basic auth credentials in user:pass format | string |
null |
no |
basic_auth_exclusions | List of regular expressions describing paths excluded from the basic auth | list(string) |
[] |
no |
bucket | Kebab-cased bucket name override | string |
null |
no |
certificate_arn | ACM certificate ARN to use instead of the default cloudfront certificate | string |
null |
no |
cloudfront_price_class | CloudFront price class, which specifies where the distribution should be replicated, one of: PriceClass_100, PriceClass_200, PriceClass_All | string |
"PriceClass_100" |
no |
cloudfront_ssl_policy | Cloudfront SSL policy, used only when certificate_arn is provided. See https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/secure-connections-supported-viewer-protocols-ciphers.html |
string |
"TLSv1.2_2019" |
no |
create | Should resources be created | bool |
true |
no |
domains | List of domains which will serve the application. If empty, will use the default cloudfront domain | list(string) |
[] |
no |
environment | Kebab-cased name of the environment, eg. production, staging, development, preview. Will be included in resource names | string |
n/a | yes |
name_prefix | Kebab-cased resource name prefix, defaults to project-environment | string |
null |
no |
project | Kebab-cased name of the project. Will be included in resource names | string |
n/a | yes |
pull_request_path_re | Regular expression which extracts the base directory of a PR as it's first match group | string |
`"^/(PR-\d+)($ | /)"` |
pull_request_router | Enables routing for pull request subdirectories | bool |
false |
no |
pull_request_router_archive_path | Path where the PR router lambda package will be created. See spa/middleware archive_path input for details. |
string |
null |
no |
static_cors_max_age_seconds | How long can CORS OPTIONS request responses be cached | number |
3600 |
no |
static_path | Base path for static assets | string |
"/static" |
no |
static_website | Use S3 static website hosting | bool |
false |
no |
static_website_error | S3 static website hosting error document path | string |
"404.html" |
no |
static_website_index | S3 static website index document | string |
"index.html" |
no |
static_website_routing_rules | S3 static website hosting routing rules | string |
null |
no |
tags | Additional tags to add to each resource that supports them | map(string) |
{} |
no |
Name | Description |
---|---|
bucket_arn | ARN of the created assets S3 bucket |
bucket_name | Name of the created assets S3 bucket |
ci_policy_arn | ARN of the IAM policy which grants actions needed for CI/CD |
distribution_arn | ARN of the created assets CloudFront distribution |
distribution_domain | Domain of the created assets CloudFront distribution, eg. d604721fxaaqy9.cloudfront.net. |
distribution_id | ID of the created assets CloudFront distribution |
distribution_url | URL of the created assets CloudFront distribution, eg. https://d604721fxaaqy9.cloudfront.net. |
distribution_zone_id | The CloudFront Route 53 zone ID that can be used to route an Alias Resource Record Set to. |