Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
fix nideveloper#245: make distributionPaths configurable for `Hoste…
Browse files Browse the repository at this point in the history
…dZoneConfig`

previous commit added the feature to `SPADeployConfig`, so this one is also adding it to `HostedZoneConfig`
  • Loading branch information
ppena-LiveData committed Feb 17, 2022
1 parent b8a9b85 commit 0c704ea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/spa-deploy/spa-deploy-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface HostedZoneConfig {
readonly indexDoc:string,
readonly errorDoc?:string,
readonly cfBehaviors?: Behavior[],
readonly distributionPaths?: string[],
readonly websiteFolder: string,
readonly zoneName: string,
readonly subdomain?: string,
Expand Down Expand Up @@ -271,7 +272,7 @@ export class SPADeploy extends Construct {
// Invalidate the cache for / and index.html when we deploy so that cloudfront serves latest site
distribution,
role: config.role,
distributionPaths: ['/', `/${config.indexDoc}`],
distributionPaths: config.distributionPaths || ['/', `/${config.indexDoc}`],
});

new ARecord(this, 'Alias', {
Expand Down
25 changes: 25 additions & 0 deletions test/cdk-spa-deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,31 @@ test('Create From Hosted Zone with Custom Role', () => {
}));
});

test('Create From Hosted Zone with Custom Distribution Paths', () => {
const app = new App();
const stack = new Stack(app, 'testStack', {
env: {
region: 'us-east-1',
account: '1234',
},
});
// WHEN
new SPADeploy(stack, 'spaDeploy', { encryptBucket: true })
.createSiteFromHostedZone({
zoneName: 'cdkspadeploy.com',
indexDoc: 'index.html',
websiteFolder: 'website',
distributionPaths: ['/images/*.png'],
});

const template = Template.fromStack(stack);

// THEN
template.hasResourceProperties('Custom::CDKBucketDeployment', {
DistributionPaths: ['/images/*.png']
});
});

test('Create From Hosted Zone with Error Bucket', () => {
const app = new App();
const stack = new Stack(app, 'testStack', {
Expand Down

0 comments on commit 0c704ea

Please sign in to comment.