UNPKG

@incdevco/framework

Version:
202 lines (201 loc) 5.33 kB
{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "Template for Web Client Stack", "Parameters": { "DomainName": { "Default": "incdev.co", "Description": "domain name for dns", "Type": "String" }, "HostedZoneId": { "Type": "String" }, "LoggingBucket": { "Description": "bucket to be used for logging", "Type": "String" }, "LoggingBucketDomainName": { "Description": "domain name for bucket to be used for logging", "Type": "String" }, "SSLCertificateArn": { "Description": "arn for certificate to match domain name", "Type": "String" }, "Stage": { "Description": "stage of the stack", "Type": "String" }, "SubDomainName": { "Default": "www", "Description": "subdomain name for dns", "Type": "String" } }, "Conditions": { "IsProduction": {"Fn::Equals": ["production", {"Ref": "Stage"}]} }, "Mappings": {}, "Resources": { "Bucket": { "Type": "AWS::S3::Bucket", "Properties": { "AccessControl": "PublicRead", "CorsConfiguration": { "CorsRules": [ { "AllowedHeaders": ["*"], "AllowedMethods": ["GET", "HEAD"], "AllowedOrigins": ["*"], "Id": "everyone" } ] }, "LoggingConfiguration": { "DestinationBucketName": {"Ref": "LoggingBucket"}, "LogFilePrefix": {"Fn::Join": ["", [ "bucket/", {"Ref": "SubDomainName"}, ".", {"Ref": "Stage"}, ".", {"Ref": "DomainName"}, "/" ]]} }, "WebsiteConfiguration": { "ErrorDocument": "index.html", "IndexDocument": "index.html" } } }, "Distribution": { "Type": "AWS::CloudFront::Distribution", "DependsOn": [ "Bucket" ], "Properties": { "DistributionConfig": { "Aliases": [ {"Fn::Join": ["", [ {"Ref": "SubDomainName"}, ".", {"Fn::If": [ "IsProduction", "", "development." ]}, {"Ref": "DomainName"} ]]} ], "CacheBehaviors": [], "Comment": {"Fn::Join": ["", [ {"Ref": "SubDomainName"}, "Client" ]]}, "CustomErrorResponses": [ ], "DefaultCacheBehavior": { "AllowedMethods": ["GET", "HEAD", "OPTIONS"], "CachedMethods": ["GET", "HEAD", "OPTIONS"], "Compress": true, "DefaultTTL": 30, "ForwardedValues": { "Cookies": { "Forward": "all" }, "Headers": [], "QueryString": true }, "MaxTTL": 30, "TargetOriginId": {"Fn::Join": ["-", [ "web", "client", "bucket" ]]}, "ViewerProtocolPolicy": "redirect-to-https" }, "DefaultRootObject": "index.html", "Enabled": true, "HttpVersion": "http1.1", "Logging": { "Bucket": {"Ref": "LoggingBucketDomainName"}, "IncludeCookies": true, "Prefix": {"Fn::Join": ["", [ "cloudfront/", {"Ref": "SubDomainName"}, ".", {"Ref": "Stage"}, ".", {"Ref": "DomainName"}, "/" ]]} }, "Origins": [ { "DomainName": {"Fn::GetAtt": ["Bucket", "DomainName"]}, "Id": {"Fn::Join": ["-", [ "web", "client", "bucket" ]]}, "OriginCustomHeaders": [], "OriginPath": "", "S3OriginConfig": { "OriginAccessIdentity": "" } } ], "PriceClass": "PriceClass_All", "ViewerCertificate": { "AcmCertificateArn": {"Ref": "SSLCertificateArn"}, "SslSupportMethod": "sni-only" } } } }, "RecordSetGroup": { "Type": "AWS::Route53::RecordSetGroup", "Properties": { "HostedZoneId": {"Ref": "HostedZoneId"}, "RecordSets": [ { "Name": {"Fn::Join": ["", [ {"Ref": "SubDomainName"}, ".", {"Fn::If": [ "IsProduction", "", "development." ]}, {"Ref": "DomainName"} ]]}, "Type": "A", "AliasTarget": { "HostedZoneId": "Z2FDTNDATAQYW2", "DNSName": {"Fn::GetAtt": ["Distribution", "DomainName"]} } } ] } } }, "Outputs": { "Bucket": { "Value": {"Ref": "Bucket"} }, "Url": { "Value": {"Fn::Join": ["", [ "https://", {"Ref": "SubDomainName"}, ".", {"Fn::If": [ "IsProduction", "", "development." ]}, {"Ref": "DomainName"} ]]} } } }