如何使用CloudFormation在AWS RESTAPI中创建嵌套资源路径



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

/portfolio

/资源

/{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需要参考要放入的资源。

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

相关内容

  • 没有找到相关文章

最新更新