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

How to handle AWS cache policy limit #368

Open
nserbass opened this issue May 4, 2024 · 3 comments
Open

How to handle AWS cache policy limit #368

nserbass opened this issue May 4, 2024 · 3 comments
Assignees

Comments

@nserbass
Copy link

nserbass commented May 4, 2024

Use case: My team is using SST to deploy a Nextjs application in multiple stage environments for testing feeatures before deploy to production (another env deployed by sst).

Problem: Due to aws cloudfront cache policy limit, we can't create too many environments because we reach the limit quickly (20)

I've followed your documentation about transform function. I've tried several implementations but always creates a new one and throws errors with missing defaultCacheBehavior parameters:

new sst.aws.Nextjs("MyWeb", {
  environment,
  transform: {
    cdn: {
      defaultCacheBehavior: {
        cachePolicyId: 'f99c40f2-50bf-4215-8023-125e7a46fb0e'
      }
    }
  },
});
new sst.aws.Nextjs("MyWeb", {
  environment,
  transform: {
    cdn: (cdnArgs) => {
      cdnArgs.defaultCacheBehavior = {
        cachePolicyId: 'f99c40f2-50bf-4215-8023-125e7a46fb0e'
      }
    }
  },
});
// it doesn't throw errors but creates a new cache policy as well
new sst.aws.Nextjs("MyWeb", {
  environment,
  domain: customDomain,
  transform: {
    cdn: (args) => ({
      ...args,
      defaultCacheBehavior: {
        ...args.defaultCacheBehavior,
        cachePolicyId: 'f99c40f2-50bf-4215-8023-125e7a46fb0e'
      }
    })
  }
});

Any ideas?

Thank you!

@eschaefer
Copy link
Contributor

eschaefer commented May 10, 2024

Just chiming in to +1 this since we have a similar limit for our team. I imagine this would be a common use-case for teams that work in orgs with arbitrary limits on cache policies.

@jschuur
Copy link

jschuur commented May 13, 2024

I also ran into this the other week after capriciously creating a bunch of SST Ion prototypes until this popped up. Luckily, I was able to delete other ones as a short term stop gap.

Based on the docs, it wasn't clear to me how to use this transform param.

@jayair
Copy link
Contributor

jayair commented May 14, 2024

Yeah this sounds like something we should try and handle internally. Let me ask the team.

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

5 participants