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

How to create a nested Resource path in AWS RestAPI using Cloudformation?

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

/投资组合

/资源

/{resourceId}

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

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

/
 /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需要引用你要放入的Resource

"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}"
  }
},