Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CloudFront] Check specifically for undefined and determining of the defaultRootObject prop is set or not #801

Merged
merged 4 commits into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export class CloudFrontWebDistribution extends cdk.Construct {
const distributionConfig: cloudformation.DistributionResource.DistributionConfigProperty = {
comment: props.comment,
enabled: true,
defaultRootObject: props.defaultRootObject || "index.html",
defaultRootObject: props.defaultRootObject !== undefined ? props.defaultRootObject : "index.html",
httpVersion: props.httpVersion || HttpVersion.HTTP2,
priceClass: props.priceClass || PriceClass.PriceClass100,
ipv6Enabled: props.enableIpV6 || true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"Resources": {
"AnAmazingWebsiteProbablyCFDistribution47E3983B": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"CacheBehaviors": [],
"DefaultCacheBehavior": {
"AllowedMethods": [
"GET",
"HEAD"
],
"CachedMethods": [
"GET",
"HEAD"
],
"ForwardedValues": {
"Cookies": {
"Forward": "none"
},
"QueryString": false
},
"TargetOriginId": "origin1",
"ViewerProtocolPolicy": "redirect-to-https"
},
"DefaultRootObject": "",
"Enabled": true,
"HttpVersion": "http2",
"IPV6Enabled": true,
"Origins": [
{
"CustomOriginConfig": {
"HTTPPort": 80,
"HTTPSPort": 443,
"OriginKeepaliveTimeout": 5,
"OriginProtocolPolicy": "https-only",
"OriginReadTimeout": 30,
"OriginSSLProtocols": [
"TLSv1.2"
]
},
"DomainName": "brelandm.a2z.com",
"Id": "origin1",
"OriginCustomHeaders": [
{
"HeaderName": "X-Custom-Header",
"HeaderValue": "somevalue"
}
]
}
],
"PriceClass": "PriceClass_100",
"ViewerCertificate": {
"CloudFrontDefaultCertificate": true
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

import cdk = require('@aws-cdk/cdk');
import cloudfront = require('../lib');

const app = new cdk.App(process.argv);

const stack = new cdk.Stack(app, 'aws-cdk-cloudfront-custom');

new cloudfront.CloudFrontWebDistribution(stack, 'AnAmazingWebsiteProbably', {
originConfigs: [
{
originHeaders: {
"X-Custom-Header": "somevalue",
},
customOriginSource: {
domainName: "brelandm.a2z.com",
},
behaviors: [
{
isDefaultBehavior: true,
}
],
}
],
defaultRootObject: ''
});

process.stdout.write(app.run());