我正在使用无服务器版本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
看看Serverless documentation on sharing API Gateway了吗?
看来你必须创建公共资源路径组件才是CloudFormed对象