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

fix(cloudfront): Escape hatch support for Distribution #9648

Merged
merged 2 commits into from
Aug 12, 2020
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Resources": {
"DistributionCFDistribution882A7313": {
"Distribution830FAC52": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@
}
}
},
"DistributionCFDistribution882A7313": {
"Distribution830FAC52": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
Expand Down Expand Up @@ -430,4 +430,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}
}
},
"DistributionCFDistribution882A7313": {
"Distribution830FAC52": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
Expand Down Expand Up @@ -141,4 +141,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}
}
},
"DistributionCFDistribution882A7313": {
"Distribution830FAC52": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront/lib/distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class Distribution extends Resource implements IDistribution {
this.certificate = props.certificate;
this.errorResponses = props.errorResponses ?? [];

const distribution = new CfnDistribution(this, 'CFDistribution', { distributionConfig: {
const distribution = new CfnDistribution(this, 'Resource', { distributionConfig: {
enabled: true,
origins: Lazy.anyValue({ produce: () => this.renderOrigins() }),
originGroups: Lazy.anyValue({ produce: () => this.renderOriginGroups() }),
Expand Down
18 changes: 18 additions & 0 deletions packages/@aws-cdk/aws-cloudfront/test/distribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,24 @@ test('price class is included if provided', () => {
});
});

test('escape hatches are supported', () => {
const dist = new Distribution(stack, 'Dist', {
defaultBehavior: { origin: defaultOrigin },
});
const cfnDist = dist.node.defaultChild as CfnDistribution;
cfnDist.addPropertyOverride('DistributionConfig.DefaultCacheBehavior.ForwardedValues.Headers', ['*']);

expect(stack).toHaveResourceLike('AWS::CloudFront::Distribution', {
DistributionConfig: {
DefaultCacheBehavior: {
ForwardedValues: {
Headers: ['*'],
},
},
},
});
});

function defaultOrigin(domainName?: string): IOrigin {
return new TestOrigin(domainName ?? 'www.example.com');
}
Expand Down