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

Configurable Invalidation Path #245

Open
desoss opened this issue Mar 5, 2021 · 2 comments
Open

Configurable Invalidation Path #245

desoss opened this issue Mar 5, 2021 · 2 comments

Comments

@desoss
Copy link

desoss commented Mar 5, 2021

When using createSiteWithCloudfront is there a way to configure the Cloudfront invalidation path that should be performed on deploy?

Cause currently, by default, only the configured indexDoc and / are invalidated.

@ppena-LiveData
Copy link

For some reason, the code is explicitly just doing those two, so if that was just removed, then the default of the underlying BucketDeployment.distributionPaths is this:

All files under the destination bucket key prefix will be invalidated.

@ppena-LiveData
Copy link

ppena-LiveData commented Jan 13, 2022

It seems like a simple fix is to add distributionPaths to interface SPADeployConfig, so createSiteWithCloudfront() could optionally use that passed-in value instead of the hard-coded ['/', `/${config.indexDoc}`], like this:

diff --git a/lib/spa-deploy/spa-deploy-construct.ts b/lib/spa-deploy/spa-deploy-construct.ts
index d754f8d..f53e0f4 100644
--- a/lib/spa-deploy/spa-deploy-construct.ts
+++ b/lib/spa-deploy/spa-deploy-construct.ts
@@ -23,6 +23,7 @@ export interface SPADeployConfig {
   readonly certificateARN?: string,
   readonly cfBehaviors?: Behavior[],
   readonly cfAliases?: string[],
+  readonly distributionPaths?: string[],
   readonly exportWebsiteUrlOutput?:boolean,
   readonly exportWebsiteUrlName?: string,
   readonly blockPublicAccess?:s3.BlockPublicAccess
@@ -235,7 +236,7 @@ export class SPADeploy extends Construct {
         destinationBucket: websiteBucket,
         // Invalidate the cache for / and index.html when we deploy so that cloudfront serves latest site
         distribution,
-        distributionPaths: ['/', `/${config.indexDoc}`],
+        distributionPaths: config.distributionPaths || ['/', `/${config.indexDoc}`],
         role: config.role,
       });

ppena-LiveData added a commit to LiveData-Inc/CDK-SPA-Deploy that referenced this issue Jan 18, 2022
ppena-LiveData added a commit to LiveData-Inc/CDK-SPA-Deploy that referenced this issue Feb 17, 2022
…dZoneConfig`

previous commit added the feature to `SPADeployConfig`, so this one is also adding it to `HostedZoneConfig`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants