Harsh Saudagar
Harsh Saudagar

Reputation: 478

How do you import value from a nested stack to a parent stack resource's dependson?

I'm trying to pass values from my nested stack to the parent. I need to access the output from the nested stack in a resource's DependsOn. This is how I'm passing the value from my nested stack :

"API": {            "Description": "invocation URN to be passed as env variable for ebs",
    "Value":  {"Ref":"ApiGatewayMethodPortfoliosPortfolioidVarProjectsProjectidVarFinancialsGet"},
    "Export": {
        "Name": {"Fn::Sub":"${AWS::FinancialStack}-API"}
    }       }

And this is how I'm trying to access the output in my parent stack:

    "DependsOn": [
"ApiGatewayMethodPortfoliosPortfolioidVarProjectsGet",
"ApiGatewayMethodPortfoliosPortfolioidVarProjectsProjectidVarFinancialsGet" : {"Fn::ImportValue" : {"Fn::Sub" : "${FinancialStack}-API"}}},

I got an error saying that DependsOn requires a string.How should I be passing the values in this case?

Upvotes: 0

Views: 1307

Answers (1)

Laurent Jalbert Simard
Laurent Jalbert Simard

Reputation: 6349

From the parent stack, use the Fn::GetAtt function to pull an output from a nested stack. For example:

{ "Fn::GetAtt" : [ "MyNestedStack", "Outputs.API" ] }

Upvotes: 3

Related Questions