aws-samples / amazon-cloudfront-secure-static-site

Create a secure static website with CloudFront for your registered domain.
Apache License 2.0
389 stars 140 forks source link

CopyCustomResource | CREATE_FAILED | Response object is too long. #23

Closed ZacharyRSmith closed 3 years ago

ZacharyRSmith commented 4 years ago

when i first deployed, a nested stack err'd with

CopyCustomResource | CREATE_FAILED | Response object is too long.
-- | -- | --

i successfully deployed after replacing www/ with www/index.html where index.html is just 'hi'.

i think CopyCustomResource was hitting the 4kb limit. I think it's trying to copy all of www/ in 1 go:

  CopyFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: ../www
      Environment:
        Variables:
          BUCKET: !Ref S3BucketRoot
      Handler: witch.staticHandler
      Layers:
        - !Ref CopyLayerVersion
      Role: !GetAtt CopyRole.Arn
      Runtime: nodejs12.x
      Timeout: 300

but of course my www/ will have >4kb.

i was able to comment out CopyCustomResource and run an aws s3 sync outside cloudformation. But is there a way to do this inside cloudformation when www/ >4kb?

thomasturrell commented 3 years ago

@ZacharyRSmith I have encountered the same issue. I agree with your assessment that CopyCustomResource was hitting the 4kb limit.

I believe that the issue is the number of files in the www folder (and sub folders). I do not believe that the total size of the files is the issue.

The response from the witch.staticHandler function includes a list of all of files that were copied.

It is my belief that nothing in this stack needs to know the filenames of the files from the www folder that were copied into the S3 bucket.

I will open a pull request with a preposed fix.