eternitysharp
eternitysharp

Reputation: 559

Can I skip generating the {proxy+} when creating Rest API using Amplify

I am currently playing around with creating rest-api:s with amplify. I am trying to create the following structure:

But I get the following error when trying to push the backend:

Unable to create resource at path '/helloText/{proxy+}': A sibling ({name}) of this resource already has a variable path part -- only one is allowed

As I understand, it is because Amplify is creating "greedy paths" by default.

When manually removing these "greedy paths" from the template file RestTest-cloudformation-template.json it works.

Is it somehow possible to create these paths by using only the command line?

Upvotes: 3

Views: 726

Answers (1)

Karol Perec
Karol Perec

Reputation: 51

There is no configuration switch for that in amplify-cli. You need to create an override. Reference: Amplify override api. Run:

amplify override api

Then edit generated override.ts like:

import { AmplifyApiRestResourceStackTemplate } from '@aws-amplify/cli-extensibility-helper';

export function override(resources: AmplifyApiRestResourceStackTemplate) {
  const {paths} = resources.restApi.body;
  Object.keys(paths).forEach((path) => {
    if (path.includes('{proxy+}')) {
      delete paths[path];
    }
  });
}

Upvotes: 5

Related Questions