{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "AWS CloudFormation Custom::Variable demo stack", "Parameters": { "VariableCustomResourceName": { "Type": "String", "Default": "cfn-variable-0-2-0", "Description": "The name of the Variable Custom Resource Lambda you deployed to test this stack." }, "RestApiCustomResourceName": { "Type": "String", "Default": "cfn-api-gateway-restapi-0-5-0", "Description": "The name of the RestApi Custom Resource Lambda you deployed to test this stack." }, "ResourceTreeCustomResourceName": { "Type": "String", "Default": "cfn-api-gateway-resource-tree-0-2-0", "Description": "The name of the ResourceTree Custom Resource Lambda you deployed to test this stack." }, "aNameForNestedApi": { "Type": "String", "Default": "CfnVariableDemoApi", "Description": "The name of the RestApi to build for this demo." } }, "Resources": { "ExpandedResourceTree": { "DependsOn": [ "MyRestApi", "MyVariable" ], "Type": "Custom::ApiGatewayResourceTree", "Properties": { "ServiceToken": { "Fn::Join": [ ":", [ "arn", "aws", "lambda", { "Ref": "AWS::Region" }, { "Ref": "AWS::AccountId" }, "function", { "Ref": "ResourceTreeCustomResourceName" } ] ] }, "RestApiId": { "Ref": "MyRestApi" }, "ParentId": { "Fn::GetAtt": [ "MyRestApi", "RootResourceId" ] }, "ChildResources": [ { "PathPart": "alpha", "__default__": { "Fn::GetAtt": [ "MyVariable", "Value" ] } }, { "PathPart": "beta", "__default__": { "Fn::GetAtt": [ "MyVariable", "Value" ] } }, { "PathPart": "gamma", "__default__": { "Fn::GetAtt": [ "MyVariable", "Value" ] } } ] } }, "MyRestApi": { "Type": "Custom::ApiGatewayRestApi", "Properties": { "ServiceToken": { "Fn::Join": [ ":", [ "arn", "aws", "lambda", { "Ref": "AWS::Region" }, { "Ref": "AWS::AccountId" }, "function", { "Ref": "RestApiCustomResourceName" } ] ] }, "Name": { "Ref": "aNameForNestedApi" } } }, "MyVariable": { "Type": "Custom::Variable", "Properties": { "ServiceToken": { "Fn::Join": [ ":", [ "arn", "aws", "lambda", { "Ref": "AWS::Region" }, { "Ref": "AWS::AccountId" }, "function", { "Ref": "VariableCustomResourceName" } ] ] }, "VariableValue": { "ChildResources": [ { "PathPart": "a", "ChildResources": [ { "PathPart": "aa", "ChildResources": [ { "PathPart": "aaa" }, { "PathPart": "aab" }, { "PathPart": "aac" } ] }, { "PathPart": "ab", "ChildResources": [ { "PathPart": "aba" }, { "PathPart": "abb" }, { "PathPart": "abc" } ] }, { "PathPart": "ac", "ChildResources": [ { "PathPart": "aca" }, { "PathPart": "acb" }, { "PathPart": "acc" } ] } ] }, { "PathPart": "b", "ChildResources": [ { "PathPart": "ba", "ChildResources": [ { "PathPart": "baa" }, { "PathPart": "bab" }, { "PathPart": "bac" } ] }, { "PathPart": "bb", "ChildResources": [ { "PathPart": "bba" }, { "PathPart": "bbb" }, { "PathPart": "bbc" } ] }, { "PathPart": "bc", "ChildResources": [ { "PathPart": "bca" }, { "PathPart": "bcb" }, { "PathPart": "bcc" } ] } ] }, { "PathPart": "c", "ChildResources": [ { "PathPart": "ca", "ChildResources": [ { "PathPart": "caa" }, { "PathPart": "cab" }, { "PathPart": "cac" } ] }, { "PathPart": "cb", "ChildResources": [ { "PathPart": "cba" }, { "PathPart": "cbb" }, { "PathPart": "cbc" } ] }, { "PathPart": "cc", "ChildResources": [ { "PathPart": "cca" }, { "PathPart": "ccb" }, { "PathPart": "ccc" } ] } ] } ] } } } }, "Outputs": { "aConsoleLinkToLargeResourceTree": { "Description": "Link to the RestApi with a large tree created with CfnVariables", "Value": { "Fn::Join": [ "", [ "https://console.aws.amazon.com/apigateway/home?region=", { "Ref": "AWS::Region" }, "#/restapis/", { "Ref": "MyRestApi" }, "/resources/", { "Fn::GetAtt": [ "MyRestApi", "RootResourceId" ] } ] ] } }, "Variable": { "Description": "Value for base64(JSON.stringify(Variable))", "Value": { "Fn::GetAtt": [ "MyVariable", "Value" ] } } } }