amplify-hosting
amplify-hosting copied to clipboard
Saving rewrites and redirects to configuration file?
** Please describe which feature you have a question about? ** Rewrites and Redirects
** Provide additional details**
I plan on having a bunch of rewrites and redirects and would feel more secure if I could save them in my repository. Is it possible to have the rewrite data saved in a config file like the amplify.yml
file?
Another benefit of this approach is the rewrites & redirects can differ per connected branch, which can be helpful as things change over time.
Oh and if possible in this process it would also be nice if env vars can be referenced somehow in the rewrites so that secret things can be left in the env vars as usual.
We are experiencing the same issue, it would be great if we can limit the scope of the rewrites and redirects by branch.
Another benefit of this approach is the rewrites & redirects can differ per connected branch, which can be helpful as things change over time.
@smakinson @dbrunet73 if you would like to setup redirects per branch, one workaround is to create two amplify console apps and re-connect the same repo: you will be able to setup different redirects then.
@swaminator I'm looking at using a reverse proxy rewrite to point to proxy a rest api url and the url format is:
https://{restapi_id}.execute-api.{region}.amazonaws.com/{stage_name}/
since stage_name
needs to be provided I would like to be able to proxy the dev stage_name in the dev environment and the prod stage_name in the prod environment, etc. Perhaps this feature request could solve this? Or maybe we need a similar override option like the env vars have? Or maybe I'm just missing how to do it? 😄
By the way, after taking a pause on checking out Amplify console and coming back to it only months later, it's encouraging to see the good progress being made. Thanks for the hard work.
This would be a helpful feature to manage this configuration with the rest of the application instead of tweaking things on a config page.
This is super important for agile workflows, please prioritize. thanks!
Great idea here - this would simplify on-boarding new members who don't need access to AWS.
Currently the best option it to do this via CDK
It would be beneficial to have it within the amplify development workflow.
FYI: Netlify has two ways to configure rewrites and redirects.
Rewrites and redirects specific config file _redirects
and general config file netlify.toml
.
I would like to see the same mechanism as Netlify's _redirects
introduced to AWS.
Here is a _redirects
example:
# Redirects from what the browser requests to what we serve
/home /
/blog/my-post.php /blog/my-post
/news /blog
/cuties https://www.petsofnetlify.com
Any updates on this? I saw mentioned in the other ticket that this is on the roadmap :)
It would be super helpful to manage redirects and rewrites through a configuration file.
I have a project with a large number of redirects (~3000). This would be most helpful to be able to manage redirects from a config file in the project vs. the amplify console/CDK. Looking forward to seeing updates on this.
@dmuensterman I pity you. That's a ton of rewrites.....
@boatcoder you are telling me! I'm working on getting them cleaned up. It was autogenerated from a shopify site. So everytime they changed blog tags and stuff, shopify would spit out a bunch...
amplify.yml
for build settings per branch.
customHttp.yml
for header rules per branch.
Environment Variables can have variable overrides for branches.
No options for redirects and rewrites? This forces us to push changes directly and immediately into our production applications which is high risk. We need a way to test pre-production environments.
This feature would be very valuable.
+1 on this issue.
For the sake of DX and productivity, it would make a LOT of sense for users/customers to be able to specify rewrites somewhere within the "amplify development workflow" (not needing to use CDK/CFN, or needing access to Amplify Console) by specifying rewrites directly in a config/yaml file, like @jasonrundell mentioned.
From a "have we seen this before" perspective, this would be a familiar pattern for many people - since we've all seen .htaccess
files before, and they fundamentally serve the same function. It would be great to have, and easy to understand.
Being able, also, to specify branch-specific rewrites would be a major +1 stretch-goal.
Another comment on DX - would be an awesome outcome (if a stretch goal) if we could configure SPA apps easily, so:
</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|woff2|ttf|map|json|webp)$)([^.]+$)/>
reeduicrecting to index.html
with status 200
by declaring something simple like spa
.
+1 on this. Managing multiple projects via console is not easiest way to go. Please add ability to allow defining redirect via some file e.g. redirects.yml
or as a section inside amplify.yml
.
This is a much needed feature. Accessing the web console for this appears unnecessary. Amplify has come a long way, and this just appears to be something easy, as the web console already supports it.
I'd encourage people to use a Terraform or CDK setup and handle this with a CustomRule
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/amplify_app#example-usage
I'd encourage people to use a Terraform or CDK setup and handle this with a
CustomRule
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/amplify_app#example-usage
^^ This can be achieved with a simple custom resource that plugs right into Amplify + a straightforward CloudFormation template. Not a bad idea, actually. 👍🏼
I'd encourage people to use a Terraform or CDK setup and handle this with a CustomRule https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/amplify_app#example-usage
this is valid point but for most cases where I want to use Amplify to host static site via connect to Github repo (similar to what Netlify does) setting up a CDK or Terraform is overkill. Amplify should provide "config" file where these basic things can be defined (again Netlify as an example with their netlify.toml file)
2nd this and any guidance for a work around would be appreciated.
Hi team, any news for this feature?
IDK if this thread is dead or has been fixed differently.
I have had some success doing the following:
- Create/Update routes in a file called
customRules.json
in the root of the repo with all the rewrites/redirects in it.[ { "source": "/<*>", "status": "404-200", "target": "/index.html" }, .... other rewrites/redirects.... ]
- Run the following command to update Rewrites and Redirects for an app
aws amplify update-app --app-id YOUR_APP_ID --custom-rules file://customRules.json
It's still a manual step, but is less painful than using the Web GUI for a large number of entries, keeps a record in git, and is easier to use between multiple apps.