Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move resource in AWS API gateway

I would like to move a few resources one level above such as:

\v1\test1 -> \test1
\v2\test2 -> \test2

The documentation here say that it is possible. But when I run the following command:

aws apigateway  update-resource \
--rest-api-id xvxi2smff9 \
--resource-id 2r0epq \
--cli-input-json "{\"patchOperations\" : [ 
      {
        \"op\" : \"move\",
        \"path\" : \"eysorw\",
        \"value\" : \"2r0epq\",
        \"from\" : \"xvxi2smff9\"
      } 
]}"

I get the error that it is an invalid patch operation.

A client error (BadRequestException) occurred when calling the UpdateResource operation: Invalid patch operation specified. Must be 'add'|'remove'|'replace'
like image 746
jamborta Avatar asked May 01 '16 23:05

jamborta


People also ask

What is a resource in AWS API gateway?

A collection of HTTP resources and methods that are integrated with backend HTTP endpoints, Lambda functions, or other AWS services. You can deploy this collection in one or more stages. Typically, API resources are organized in a resource tree according to the application logic.

How do I create a proxy resource in API gateway?

To set up a proxy integration in an API Gateway API with a proxy resource, you perform the following tasks: Create a proxy resource with a greedy path variable of { proxy +} . Set the ANY method on the proxy resource. Integrate the resource and method with a backend using the HTTP or Lambda integration type.


1 Answers

You can "reparent" a resource by issuing a replace patch operation to the /parentId path with the resourceId of the new parent:

aws apigateway update-resource \
   --rest-api-id xvxi2smff9 \
   --resource-id 2r0epq \
   --patch-operations op=replace,path=/parentId,value=eysorw

[edited to replace patchOperations with patch-operations - comment to meet 6 character minimum edit]

like image 70
Lorenzo de Lara Avatar answered Sep 21 '22 05:09

Lorenzo de Lara