@incdevco/framework
Version:
node.js lambda framework
206 lines (205 loc) • 5.41 kB
JSON
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Template for Content Delivery Network Stack",
"Parameters": {
"DefaultTTL": {
"Default": 3600,
"Type": "Number"
},
"DomainName": {
"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"
},
"MaxTTL": {
"Default": 21600,
"Type": "Number"
},
"SSLCertificateArn": {
"Description": "arn for certificate to match domain name",
"Type": "String"
},
"Stage": {
"Description": "stage of the stack",
"Type": "String"
},
"SubDomainName": {
"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": "error.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": {"Ref": "DefaultTTL"},
"ForwardedValues": {
"Cookies": {
"Forward": "all"
},
"Headers": [],
"QueryString": true
},
"MaxTTL": {"Ref": "MaxTTL"},
"TargetOriginId": {"Fn::Join": ["-", [
"cdn",
"bucket"
]]},
"ViewerProtocolPolicy": "allow-all"
},
"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": ["-", [
"cdn",
"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"}
]]}
}
}
}