首页 文章

无服务器共享API网关部署到不同阶段时出错

提问于
浏览
2

我正在使用无服务器版本1.29.2

我创建了一个初始的cloudformation脚本,它创建了一个将由其他服务使用的API GateWay REST API . 所以这是负责它的cloudformation脚本 .

{
   "AWSTemplateFormatVersion":"2010-09-09",
   "Description":"API",
   "Resources":{
      "APIGw":{
         "Type":"AWS::ApiGateway::RestApi",
         "Properties":{
            "Name":"API-GW"
         }
      }
   },
   "Outputs":{
      "ApiGwRestApiId":{
         "Value":{
            "Ref":"APIGw"
         },
         "Export":{
            "Name":"apigw-restApiId"
         }
      },
      "eyesApiGwRestApiRootResourceId":{
         "Value":{
            "Fn::GetAtt":[
               "APIGw",
               "RootResourceId"
            ]
         },
         "Export":{
            "Name":"apigw-rootResourceId"
         }
      }
   }
}

这是我尝试部署的应用程序的serverless.yml .

service: template-test-service

provider:
  name: aws
  runtime: python3.6
  region: eu-central-1
  stage: ${self:custom.environment.stage}
  environment:
    stage: ${self:custom.environment.stage}
  apiGateway:
    restApiId:
      'Fn::ImportValue': apigw-restApiId
    restApiRootResourceId:
      'Fn::ImportValue': apigw-rootResourceId

当我执行 sls deploy --stage dev 一切正常时,但当我执行另一次部署到 sls deploy --stage prod

出现此错误 .

Another resource with the same parent already has this name

1 回答

相关问题