@incdevco/framework
Version:
node.js lambda framework
168 lines (166 loc) • 4.6 kB
JSON
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Template for Web Client with Api Key But No Domain Name Stack",
"Parameters": {
"LoggingBucket": {
"Description": "bucket to be used for logging",
"Type": "String"
},
"LoggingBucketDomainName": {
"Description": "domain name for bucket to be used for logging",
"Type": "String"
},
"UsagePlanId": {
"Description": "id for usage plan the api key will be added to",
"Type": "String"
},
"Stage": {
"Description": "stage of the stack",
"Type": "String"
},
"WebACLId": {
"Default": "",
"Description": "id of the web acl you want to attach",
"Type": "String"
}
},
"Conditions": {
"HasWebACL": {"Fn::Not": [{"Fn::Equals": ["", {"Ref": "WebACLId"}]}]},
"IsProduction": {"Fn::Equals": ["production", {"Ref": "Stage"}]}
},
"Mappings": {},
"Resources": {
"ApiKey": {
"Type": "AWS::ApiGateway::ApiKey",
"Properties": {
"Description": "api key for client",
"Enabled": true
}
},
"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": "Stage"},
"/"
]]}
},
"WebsiteConfiguration": {
"ErrorDocument": "index.html",
"IndexDocument": "index.html"
}
}
},
"Distribution": {
"Type": "AWS::CloudFront::Distribution",
"DependsOn": [
"Bucket"
],
"Properties": {
"DistributionConfig": {
"Aliases": [
],
"CacheBehaviors": [],
"Comment": "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": "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": "Stage"},
"/"
]]}
},
"Origins": [
{
"DomainName": {"Fn::GetAtt": ["Bucket", "DomainName"]},
"Id": "web-client-bucket",
"OriginCustomHeaders": [],
"OriginPath": "",
"S3OriginConfig": {
"OriginAccessIdentity": ""
}
}
],
"PriceClass": "PriceClass_All",
"ViewerCertificate": {
"CloudFrontDefaultCertificate": true
},
"WebACLId": {"Fn::If": [
"HasWebACL",
{"Ref": "WebACLId"},
{"Ref": "AWS::NoValue"}
]}
}
}
},
"GetApiKey": {
"Type": "Custom::ApiGatewayGetApiKey",
"Properties": {
"ServiceToken": {"Fn::ImportValue": "CustomCFResourceFunctionArn"},
"Options": {
"ApiKeyId": {"Ref": "ApiKey"}
}
}
},
"UsagePlanKey": {
"Type": "Custom::ApiGatewayUsagePlanKey",
"Properties": {
"ServiceToken": {"Fn::ImportValue": "CustomCFResourceFunctionArn"},
"Options": {
"ApiKeyId": {"Ref": "ApiKey"},
"UsagePlanId": {"Ref": "UsagePlanId"}
}
}
}
},
"Outputs": {
"ApiKey": {
"Value": {"Fn::GetAtt": ["GetApiKey", "ApiKey"]}
},
"Bucket": {
"Value": {"Ref": "Bucket"}
},
"Url": {
"Value": {"Fn::Join": ["", [
"https://",
{"Fn::GetAtt": ["Distribution", "DomainName"]}
]]}
}
}
}