Hi!
Part of my serverless.yml is defined the following way:
service: api
##plugins
provider
apiGateway:
restApiId:
'Fn::ImportValue': ${opt:stage, self:provider.stage}-api-id
restApiRootResourceId:
'Fn::ImportValue': ${opt:stage, self:provider.stage}-id-rootResourceId
##functions
resources:
Resources:
##dynamo_tables
ApiGw:
Type: AWS::ApiGateway::RestApi
Properties:
Name: ${opt:stage, self:provider.stage}-ApiGw
Outputs:
apiGatewayRestApiId:
Value:
Ref: ApiGw
Export:
Name: ${opt:stage, self:provider.stage}-api-id
apiGatewayRestApiRootResourceId:
Value:
Fn::GetAtt:
- ApiGw
- RootResourceId
Export:
Name: ${opt:stage, self:provider.stage}-id-rootResourceId
I executed the template and everything went ok, the api_id and the root_resource_id exports are referenced on cloudformation, as a mistake I deleted manually my api gateway and I am not able to run again sls deploy --stage qa
because I got the following error:
ServerlessError: An error occurred: api-qa - Template error: API Gateway RestAPI 87xxxxx doesn't exist.
at /opt/homebrew/lib/node_modules/serverless/lib/plugins/aws/lib/monitorStack.js:94:23
at processImmediate (node:internal/timers:464:21)
From previous event:
at /opt/homebrew/lib/node_modules/serverless/lib/plugins/aws/lib/monitorStack.js:27:12
And when I try to remove the stack sls remove --stage qa
this is the following error:
ServerlessError: An error occurred: api-qa - Export qa-id-rootResourceId cannot be deleted as it is in use by api-qa.
at /opt/homebrew/lib/node_modules/serverless/lib/plugins/aws/lib/monitorStack.js:94:23
at processImmediate (node:internal/timers:464:21)
From previous event:
at /opt/homebrew/lib/node_modules/serverless/lib/plugins/aws/lib/monitorStack.js:27:12
I know that I’m facing a circular reference but I don’t know how I can proceed since the exports id’s are stuck on cloudformation.
Thanks