<@U01JVDKASAC> I was checking the source for `Stat...
# sst
a
@Frank I was checking the source for
StaticSite
, due I have to deploy multiple React apps into the same bucket… (for the micro-frontend discussion)… And I need to copy the logic for invalidate CFront… but… why is the invalidation done in a lambda, and not done from the stack? is that even possible?
Also, the
deploymentBucket
has this:
Copy code
/**
   * The CloudFront distribution using the destination bucket as an origin.
   * Files in the distribution's edge caches will be invalidated after
   * files are uploaded to the destination bucket.
   *
   * @default No invalidation occurs
   */
  readonly distribution?: cloudfront.IDistribution;

  /**
   * The file paths to invalidate in the CloudFront distribution.
   *
   * @default All files under the destination bucket key prefix will be invalidated.
   */
  readonly distributionPaths?: string[];
Why would SST need a function to invalidate distribution if already uses deploymentBucket?
i
I'm not sure about your second question, but r.e. your first, the CloudFront distribution could be created dynamically by CDK. When CDK synthesises your app into a CloudFormation template it doesn't know the ID of the distribution yet, because it might not exist, so it uses a token. When you pass the token into a Lambda, the Lambda gets the resolved value.
a
But there is a construct called
deploymentBucket
which can do the invalidation.
Why we use a lambda and not that feature?
@Frank if you missed this one 🙂 🙏
f
@Adrián Mouly Invalidation is done by making an AWS SDK call to CloudFront. The
deploymentBucket
also does the invalidation inside a Lambda function.
StaticSite
has very similar logic as
deploymentBucket
with a couple more features: • handles
environment
replacement in ur frontend app • handles large sites (
deploymentBucket
has issues deploying large sites)
a
I see.
So you guys implemented
deploymentBucket
by yourself.
I don’t think I will have large files, I think.
So, now that I’m using
deploymentBucket
I should see a new lambda created for invalidations?