aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
81 stars 71 forks source link

Setting cloudfront cachebehaviors #970

Open m4tta opened 3 years ago

m4tta commented 3 years ago

Which Category is your question related to? Container Hosting

Amplify CLI Version

You can use amplify -v to check the amplify cli version on your system

4.47.1

What AWS Services are you utilizing? Amplify container hosting. Fargate, ECR, Cloudfront, etc.

Provide additional details e.g. code snippets

The generated container-template.json file does not set AllowedMethods for the cloudfront distribution. Defaults to only allowing GET, HEAD.

I need to be able to add "AllowedMethods": ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"], to the cloudfront cache behavior, but since this file is regenerated constantly I am lost at where to set this without manually changing it in the dashboard after each push.

jhockett commented 3 years ago

Hi @m4tta, we don't expose a flow to configure the AllowedMethods. I've marked the issue as an enhancement. Could you tell us more about your use case?

m4tta commented 3 years ago

Pretty simple use case. Just using container hosting to host a NextJS app with a custom domain. Need all http methods to be allowed so I can do basic things like submit a form on the page with a POST request.

Id love to be told I am doing something wrong or there is a better way to host a containerized NextJS app. As it seems odd to not allow all the basic HTTP methods out of the box.

ruizdurazo commented 3 years ago

I am also facing the same issue as @m4tta.

Same setup (nextjs on fargate containers), same use case (form submission using built-in nextjs API routes).

Any updates on how to set this up automatically?

m4tta commented 3 years ago

I ended up abandoning amplify and just created my own infrastructure setup using AWS CDK . Much happier overall, and not as much work as I thought.