I’m getting `?The bucket you tried to delete is no...
# help
d
I’m getting
?The bucket you tried to delete is not empty
with
ReactStaticSite
. Did something change on the last version?
f
hmm.. doesn’t seem to be caused by recent changes..
From the deploy log, can you see which resource got this error?
d
ReactStaticSite
We added on our app
Copy code
const removalPolicy = app.stage === 'prod'
    ? RemovalPolicy.RETAIN
    : RemovalPolicy.DESTROY;

  app.setDefaultRemovalPolicy(removalPolicy);
When seed deploys our dev environment, now it crashes everytime. It deployed perfectly friday before we added the default removal policy
I added:
Copy code
s3Bucket: {
        autoDeleteObjects: scope.stage !== 'prod',
        removalPolicy: scope.stage === 'prod'
          ? RemovalPolicy.RETAIN
          : RemovalPolicy.DESTROY,
      },
to our
ReactStaticSite
but it does not seem to do the job.
I thing I understood why it is in a deadlock: • My react site was named ‘foo’ • We deployed and it created a bucket …-foo with a custom cname and an entry in route 53. • We (Stupidly) changed the name to ‘bar’ • It didn’t delete the bucket …-foo, when it tries to create …-bar it fails because the CNAME is already in use • Then it tries to delete the freshly created bucket. And it fails because there is objects in it. It shouldn’t fail because of objects as we set the autoDeleteObjects property
f
hmm..
autoDeleteObjects
and
removalPolicy
always had default value of
true
and
RETAIN
for StaticSites’s s3 bucket.
So by setting the
autoDeleteObjects
, a custom resource is created backed by a Lambda function that removes all the files in the bucket. My guess for the scenario you mentioned above is that, after the
xxxx-bar
bucket was created, the CNAME record failed BEFORE the autoDeleteObject custom resource was created.
This unfortunately is a flaw with how custom resource works.