Skip to content

Conversation

oscar-dbbs
Copy link
Contributor

  • if custom cloudfront was passed, avoid creating new cloudfront and use existing instead
  • attach origin, update existing behavior and add additional behaviors for existing cloudfront together with lambda edge

additionalBehaviors: {
['/_next/data/*']: {
if (customCloudFrontId && customCloudFrontDomainName) {
this.cf = cloudfront.Distribution.fromDistributionAttributes(this, id, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need to add new rules and lambda to existing cloudfront

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can call this.cf.addBehaviour

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this isn't supported by the cloudformation stack. we can only add existing id to the cloud formation template (which is what I did here by setting it to the output).
aws/aws-cdk#12524

@@ -190,6 +204,18 @@ export const deploy = async (config: DeployConfig) => {
VersionLabel: versionLabel
})

// if custom cf distribution, update it
if (customCFDistribution) {
await updateDistribution(cloudfrontClient, customCFDistribution, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should do that inside stack, otherwise we will keep changing cloudfront with each deployment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the above comment. I searched and there is no way to update the distribution inside the stack.
aws/aws-cdk#12524

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we check at least that those origins and rules were already added, so we can skip that step?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will create a function to check this then.

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

Successfully merging this pull request may close these issues.

2 participants