gpt4 book ai didi

amazon-web-services - 如何使用 Cloudformation 在 AWS RestAPI 中创建嵌套资源路径?

转载 作者:行者123 更新时间:2023-12-04 00:15:04 24 4
gpt4 key购买 nike

有人可以解释一下 aws 资源类型 AWS::ApiGateway::ResourceparentId 属性吗?文档可以找到 here ,文档非常有限,仅显示如何获取 rootResourceId。使用它我能够创建以下结构。这给了我这些路径。

/投资组合

/资源

/{resourceId}

/
/portfolio
GET
OPTIONS
/resource
GET
OPTIONS
/{resourceId}
GET
OPTIONS

现在我的问题是如何实现这样的结构,其中 {resourceId} 嵌套在 resource 中,以便我的路径看起来像 /resource/{资源 ID} .

/
/portfolio
GET
OPTIONS
/resource
GET
OPTIONS
/{resourceId}
GET
OPTIONS

这是我创建资源的模板

    "getPortfoliosResource": {
"Type": "AWS::ApiGateway::Resource",
"Properties": {
"RestApiId": {
"Ref": "myAPI"
},
"ParentId": {
"Fn::GetAtt": ["myAPI", "RootResourceId"]
},
"PathPart": "portfolios"
}
},
"getResourcesResource": {
"Type": "AWS::ApiGateway::Resource",
"Properties": {
"RestApiId": {
"Ref": "myAPI"
},
"ParentId": {
"Fn::GetAtt": ["myAPI", "RootResourceId"]
},
"PathPart": "resources"
}
},
"getResourceid": {
"Type": "AWS::ApiGateway::Resource",
"Properties": {
"RestApiId": {
"Ref": "epmoliteAPI"
},
"ParentId": {
"Fn::GetAtt": ["epmoliteAPI", "RootResourceId"]
},
"PathPart": "{resourceId}"
}
},

最佳答案

ParentId 需要引用您想要将其放入的资源。

"getPortfoliosResource": {
"Type": "AWS::ApiGateway::Resource",
"Properties": {
"RestApiId": {
"Ref": "myAPI"
},
"ParentId": {
"Fn::GetAtt": ["myAPI", "RootResourceId"]
},
"PathPart": "portfolios"
}
},
"getResourcesResource": {
"Type": "AWS::ApiGateway::Resource",
"Properties": {
"RestApiId": {
"Ref": "myAPI"
},
"ParentId": {
"Fn::GetAtt": ["myAPI", "RootResourceId"]
},
"PathPart": "resources"
}
},
"getResourceid": {
"Type": "AWS::ApiGateway::Resource",
"Properties": {
"RestApiId": {
"Ref": "myAPI"
},
"ParentId": {
"Ref": "getResourcesResource"
},
"PathPart": "{resourceId}"
}
},

关于amazon-web-services - 如何使用 Cloudformation 在 AWS RestAPI 中创建嵌套资源路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46236946/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com