Skip to content

tournamentmgr/web-infra

Repository files navigation

SPA Infrastructure

The following modules allow for simple to provision single page application environments. The following resources are provisioned:

  • Cloudfront Functions HTTP Strict Transport Security
  • Cloudfront Functions Basic Auth (optional)
  • Private S3 Bucket with SSE AES256
  • Cloudfront distribution with OIA read access to bucket
  • Route 53 DNS entry

Migrate to v2

  • S3 bucket resource renamed to this from bucket: terraform state mv module.x.aws_s3_bucket.bucket module.x.aws_s3_bucket.this
  • Import needed terraform import module.x.aws_s3_bucket_server_side_encryption_configuration.this <bucket name>
  • Import needed terraform import module.x.aws_s3_bucket_cors_rule.this <bucket name>

Requirements

Name Version
aws >= 4.0

Providers

Name Version
archive n/a
aws >= 4.0
template n/a

Modules

No modules.

Resources

Name Type
aws_cloudfront_distribution.s3_distribution resource
aws_cloudfront_function.auth resource
aws_cloudfront_function.index_redirect resource
aws_cloudfront_origin_access_identity.origin_access_identity resource
aws_cloudfront_response_headers_policy.this resource
aws_iam_role.lambda_at_edge_role resource
aws_lambda_function.prerender resource
aws_route53_record.domain resource
aws_s3_bucket.this resource
aws_s3_bucket_cors_configuration.this resource
aws_s3_bucket_policy.allow_access_from_another_account resource
aws_s3_bucket_public_access_block.this resource
aws_s3_bucket_server_side_encryption_configuration.this resource
archive_file.prerender_zip data source
aws_caller_identity.current data source
aws_cloudfront_cache_policy.cache_optimized data source
aws_cloudfront_origin_request_policy.personalized_manifest data source
aws_iam_policy_document.edge data source
aws_iam_policy_document.s3_get_policy data source
aws_region.current data source
template_file.auth data source
template_file.prerender data source

Inputs

Name Description Type Default Required
allowed_headers Allowed Methods list
[
"*"
]
no
allowed_methods Allowed Methods list
[
"GET",
"HEAD"
]
no
allowed_origins Allowed Headers list
[
"*"
]
no
basic_auth Enable basic auth bool false no
certificate_id Certificate ID any n/a yes
custom_error_responses Error Responses within cloudfront
list(object({
error_code = number,
response_code = number,
response_page_path = string
}))
[
{
"error_code": 404,
"response_code": 200,
"response_page_path": "/index.html"
},
{
"error_code": 403,
"response_code": 200,
"response_page_path": "/index.html"
}
]
no
domain the domain you want to deploy to any n/a yes
enable_prerender Enable SEO Prerender bucket routing bool false no
environment the subdomain environment you want to deploy to. If domain is naked, do not specify string "" no
index_redirect Enable index redirect https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/example-function-add-index.html bool false no
password the password to utilize for the domain string "" no
prerender_bucket Prerender Bucket name string "" no
username the username to utilize for the domain string "" no
zoneid route53 zone id string "" no

Outputs

Name Description
bucket n/a
distribution n/a
identity n/a
route n/a