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

Vee*_*383 6 amazon-web-services aws-cloudformation aws-api-gateway

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

/投资组合

/资源

/ {resourceId}

/
 /portfolio
   GET
   OPTIONS
 /resource
   GET
   OPTIONS
 /{resourceId}
   GET
   OPTIONS
Run Code Online (Sandbox Code Playgroud)

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

/
 /portfolio
   GET
   OPTIONS
 /resource
   GET
   OPTIONS
   /{resourceId}
     GET
     OPTIONS
Run Code Online (Sandbox Code Playgroud)

这是我创建资源的模板

    "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}"
        }
    },
Run Code Online (Sandbox Code Playgroud)

jen*_*ter 9

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}"
  }
},
Run Code Online (Sandbox Code Playgroud)