RJPearson94 / terraform-aws-open-next-examples

examples for the Open Next Terraform module
https://github.com/RJPearson94/terraform-aws-open-next
9 stars 0 forks source link

Image optimisation does not appear to be working #3

Closed adatoo closed 4 months ago

adatoo commented 4 months ago

Technical Details

Describe the bug

Image optimisation not working.

Steps to Reproduce

Steps to reproduce the behaviour:

  1. Using the v3 Single Zone Sample
  2. Add a (jpeg) image to the /public folder
  3. Update the root page.tsx to reference the image using the NextJS Image component
  4. Test the image displays correctly in dev
  5. Build the open-next distribution
  6. Deploy with terragrunt
  7. Open the CloudFront URL and view the root/home page.

Expected behaviour

Expected: Expect the image to display Actual: The image is not displayed

Logs

No logs generated by image optimisation function.

Browser network trace returns a 403 error with the following body:

<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>PHKAYV759GD08WKH</RequestId><HostId>BuLhAVTeQQ9Tpa3RUACkRSc5+9F1KfaQTuRNtAPdk7dyal2z+1UMEJxfLqmN5Qf5+vNtuFc4eMM=</HostId></Error>

Additional context

Add any other context about the problem here.

adatoo commented 4 months ago

I have just been investigating this further and have some interesting observations:

  1. The NHS England OpenNext Terraform provider seems to have the same issue.
  2. The issue seems to be with the AWS CloudFront behaviors - the precendence is not quite correct. I have rearraged the precendence on my sample deployment and the issue is resolved.
RJPearson94 commented 4 months ago

Hi @adatoo,

Apologies for the slow response. I have been able to replicate this too.

That is interesting, about the NHS provider too. Are you able to share any more information on how you change the precedence order to resolve the issue? I am also happy to review any PRs, if you are happy to make the necessary changes.

adatoo commented 4 months ago

Hi @RJPearson94

Thanks for investigating.

Give me a couple of days to investigate further. Happy to make updates and submit a PR.

Regards

Arif

adatoo commented 4 months ago

Closing this issue and moving it to the module repository. See: https://github.com/RJPearson94/terraform-aws-open-next/issues/31