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

Viewed 6311

Can somebody explain the parentId property of aws resource type AWS::ApiGateway::Resource ? Documentation can be found here , Documentation is very much limited and only shows how to get the rootResourceId. Using that i was able to create the following structure. which gives me these paths.

/portfolio

/resource

/{resourceId}

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

Now my question is how to achieve structure like this where in {resourceId} is nested inside resource, so that my path looks like /resource/{resourceId} .

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

This is my template that create resources

    "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}"
        }
    },
1 Answers
Related