Tried to rename a path variable and got the error.
Deployed a service with the following yml config:
service: aws-nodejs
provider:
name: aws
runtime: nodejs6.10
functions:
hello:
handler: handler.hello
events:
- http:
path: /{pathvar}
method: put
Then changed it to
service: aws-nodejs
provider:
name: aws
runtime: nodejs6.10
functions:
hello:
handler: handler.hello
events:
- http:
path: /{pathVar} # Changed this variable
method: put
Then tried to redeploy the service to update the variable name and got the error.
For bug reports:
An error occurred while provisioning your stack: ApiGatewayResourcePathvarVar. A sibling ({pathvar}) of this resource already has a variable path part -- only one is allowed.pathvar to pathVar.An error occurred while provisioning your stack: ApiGatewayResourcePathvarVar - A sibling ({pathvar}) of this resource already has a variable path part -- only one is allowedSimilar or dependent issues:
An error occurred while provisioning your stack: ApiGatewayResourcePathvarVar. A sibling ({pathvar}) of this resource already has a variable path part -- only one is allowed.If more information is needed, just let me know.
I have the same issue when removing variable from path.
Old yml config:
load:
handler: handler.load
events:
- http:
path: load/{key}/{account}/{id}
method: get
cors: true
integration: lambda
request:
parameters:
paths:
id: true
key: true
account: true
Updated yml:
load:
handler: handler.load
events:
- http:
path: load/{key}/{id}
method: get
cors: true
integration: lambda
request:
parameters:
paths:
id: true
key: true
Error:
An error occurred while provisioning your stack: ApiGatewayResourceLoadKeyVarIdVar
- A sibling ({account}) of this resource already has
a variable path part -- only one is allowed.
It seems that CF first tries to add the new resource, and then to remove the old resource. This leads to an intermediate state where both resources will exist, which is of course not possible, because they interfere with each other.
Just some unordered thoughts to get a discussion running:
Workaround for now:
Comment out the function from your serverless.yml, run a full deployment. This will delete the API gateway endpoint entirely, and then you can uncomment the function and run a deployment to deploy the new function with the new pathParam.
@pettyalex
thanks, It was quite a relief.
Someone know why serverless removes the older at last instead of doing it first,
Is that because someone may be using the older versions at the deployment time of new one
I'm using the workaround suggested by @pettyalex but unfortunately makes me hit another issue where cloudformation stalls in the state UPDATE_COMPLETE_CLEANUP_IN_PROGRESS where it is taking a long time to delete lambdas inside VPCs: https://forum.serverless.com/t/very-long-delay-when-doing-sls-remove-of-lambda-in-a-vpc/2535
Thing is, deleting the API and then creating it again changes the URL endpoint. This is pretty destructive, is there a less destructive solution to this?
Im new to serverless framework, but found workaround that worked for me and didnt result in a change _to the endpoint hostname_. It might still cause a short outage for your service because it seems the resource paths are not responding correctly, but that might be acceptable considering you are changing the paths. Its better than deleting the entire api endpoint tho.
This workaround changes the path from /{one}/{two}/{proxy+} to /{one}/{two}/{three}/{proxy+}.
path: /{one}/{two}/{proxy+}path: /sls deploysls deploy againcurl http://<api>/ was now working but curl http://<api>/arg1/arg2/the/rest was also still was working even tho I had removed it from serverless.yml. maybe i just needed to wait longer than a few minutes for an update?path: /{one}/{two}/{three}/{proxy+}sls deploysls deploy againcurl http://<api>/arg1/arg2/arg3/the/rest was now working but curl http://<api>/ was also still was working even tho I had removed it from serverless.yml. maybe i just needed to wait longer than a few minutes for an update?It seems there is something very wrong with the CloudFormation updates to ApiGatewayResourcePathvarVar resources, but I could see the argument that this is not _that_ big of an issue because changing path variables is not something that will be done in production very often. I think api developers would be better off adding new endpoints and deprecating old ones (tho maybe I am misunderstanding the workflow here, like I said Im new to this framework). I only ran into this issue making a simple example serverless app.
So the accepted solution here requires you to take down the routes. Not really acceptable if you are just changing marginal things (e.g. making path parameter required) and the route are live in production and used heavily. Bleeding edge is bleeding edge....
This can be a problem for when a route has been deleted, and a new route with a variable in the same part of the path is now being added.
IE:
some/{path}
# some/{path} (removing the url from API gateway)
some/{path2} (fails to deploy)
It looks to me that this has something to do with the way stage works, and the workaround is still to destroy the entire API gateway and rebuild.
Any news on this issue? We have trouble as well and undeploying the entire api/path is not really acceptable since it runs live in production.
Is canary maybe a solution to make it a more smooth transition?
update: Nevermind, it looks like its not a problem with Serverless, its in cloudformation. When you change your path in ApiGateway it creates the new resources and then directly starts the deployment.
Including your old path/methods.
After the deployment it starts the cleanup and removes your old resources.
Is any solution available?
So the accepted solution here requires you to take down the routes. Not really acceptable if you are just changing marginal things (e.g. making path parameter required) and the route are live in production and used heavily. Bleeding edge is bleeding edge....
I agree, this should have way higher priority and should have been fixed a long time ago. This issue is close to being 2.5 years old and this bug can be a real showstopper for some applications.
@laurensV We stopped using path parameter entirely and route and validate in application logic with a single resolver route (using lambda-serverless-api on npm, disclaimer I'm the author).
There are still problems with rouge routes in stage as @MacMcIrish described, but if you do a drift detection in cf after a deploy the next deploy seems to be removing the stage path.
Not ideal but at least we don't need to remove and redeploy anymore.
@josephnaber no, cloudformation considers that a conflicting path.
Please read the previous comments.
As an aside, your paths should probably look like
/notes/{noteid}
/entities/{entityid}/notes/{noteid}
@laurensV We stopped using path parameter entirely and route and validate in application logic with a single resolver route (using lambda-serverless-api on npm, disclaimer I'm the author).
There are still problems with rouge routes in stage as @MacMcIrish described, but if you do a drift detection in cf after a deploy the next deploy seems to be removing the stage path.
Not ideal but at least we don't need to remove and redeploy anymore.
Nice I will take a look at the package! Kinda goes against the idea of serverless where each function is deployed and scaled separately as you now use 1 lambda for your entire application, but these kind of bugs make it almost impossible to use serverless in a good way
For me the issue was that the path parameters that are in the same place in the path should have the same names. E.g., if you have the paths /user/{userId} and the path /user/{accountId}/{userId} it throws this error. Changing the latter path to /user/{userId}/{accountId} fixes the error.
See this answer https://github.com/serverless/serverless/issues/1909#issuecomment-282899881
For me the issue was that the path parameters that are in the same place in the path should have the same names. E.g., if you have the paths
/user/{userId}and the path/user/{accountId}/{userId}it throws this error. Changing the latter path to/user/{userId}/{accountId}fixes the error.See this answer #1909 (comment)
That is a different problem, as this bug also appears even when you only have one path and you try to rename one of the parameters
That is a different problem, as this bug also appears even when you only have one path and you try to rename one of the parameters
Wouldn't it still be the same problem though? If you rename a parameter and then deploy, as stated above the deployment includes new _and_ old paths, where the old paths are only cleaned up after the deployment. This means that at deployment time, you would have the paths /user/{oldParamName} and /user/{newParamName}, which is in fact the same as the scenario I described above.
Difference is that in my case it's not exactly a bug, but in the case of renaming path variables it is a bug stemming from the deployment workflow.
FWIW, I just ran into this today. Very frustrating to have to take the function down.
My team also ran into this. I'd like to see this fixed in the near future to at least be able to gracefully change or some kind of warning explaining what's what.
Have been watching this issue for some time because I ran into it a while back. Ran into it again today. Not sure how this hasn't been fixed yet... it's been open a long time and the solutions offered are not viable for live production systems. Would love to see this addressed asap. Pretty please...
Confirm that we are also seeing this error.
Same thing here...
Still seeing this issue
Getting this issue.
I suspect a workaround/fix for this is tricky in that it smells more like a cloudformation issue than a serverless one...
still a thing
Still experiencing this issue
It has been solved!
That's what I'm gonna say some magical day in the future, because right now it's still an issue 馃憥馃徏
Confirmed, I still have this issue where we update the {proxy+} and keep the rest the same
E.g: Change from "api/v1/user/{userName}" to "api/v1/user/{userID}"
This is still a problem. The work around of commenting out the function in serverless.yml, deploying, un-commenting out, and then redeploying fixes it.
Not a good solution for production apps.
If your problem is specifically having to comment the paths, deploy, remove comments and redeploy, I'm not sure what you're expecting serverless to do. This is a problem with CloudFormation, the service serverless wraps around.
CF is very flaky on its own and it's better if you take this issue to AWS directly.
So the accepted solution here requires you to take down the routes. Not really acceptable if you are just changing marginal things (e.g. making path parameter required) and the route are live in production and used heavily. Bleeding edge is bleeding edge....
Makes me worried if this is still the case today (edit: given the open status of the ticket). 2 years on shouldn't be considered "bleeding edge" any more :(
I am also running into this issue when I try to create all the way new api under existing.
I have api already there which is
api/account/{accountId}/user/{userId}/enrollment and I am trying to create new api api/account/{accountId}/user/{userId}/rule .
Its giving me error like "A sibling ({userId}) of this resource already has a variable path part -- only one is allowed". Any help here? Is it the same issue?
same here happens when I rename the path from/locations/{id} to /locations/{identifier}
Will this be fixed at some point?
The API Gateway only allows one resource with variable path part under a parent resource.
That works for me:
serverless.ymlserverless deployserverless.ymlserverelss deployProfit!
That works for me:
- Comment out function definition in
serverless.ymlserverless deploy- Uncomment function definition in
serverless.ymlserverelss deployProfit!
For maximum breakage best done with a live production environment that is hooked to a domain. Enjoy! 馃構
anything/{user_id}/getsomething
anything/{user_id}/somethingelse
anything/getsomething/{user_id}
anything/somethingelse/{user_id}
use 'any' as a method
use
switch (event.httpMethod) {
case 'GET':
//
case 'POST':
//
Still an issue. Having resources and custom domains makes things a lot more difficult than just "re-setting" functions.
What's the serverless team's status on this?
Ran into this today. Is this still not fixed in newer versions?
Ran into this today also, not keen on tearing down production resources just to rebuild them with the new path variable name
It'll be good to coin where exactly the source of an issue lays. Is it:
(1) Related to how Framework lays out dependencies across CF resources that configure needed routes
(2) Limitation on CF side which cannot be workaround by tweaking the template
Has anyone investigated it in more depth (e.g. by playing directly with generated CF template)?
Having an answer to that, may push us closer to eventually having a fix for that
Most helpful comment
Workaround for now:
Comment out the function from your
serverless.yml, run a full deployment. This will delete the API gateway endpoint entirely, and then you can uncomment the function and run a deployment to deploy the new function with the new pathParam.