Home > Mobile >  How to import cloudformation stack output inside another stack parameter?
How to import cloudformation stack output inside another stack parameter?

Time:04-29

We are trying to import the output value of the base stack into the new stack parameter rather than the resource itself. Please help us to achieve that.

BASE STACK - Below is the output defined in the base stack

Outputs:
    Asset:
        Value:
            Ref: Asset
        Export:
            Name:
                'Fn::Sub': '${AWS::StackName}-Asset'

We would like to import this value into the new stack but the CFN is throwing an error that Every Default member must be a string.

NEW STACK

Parameters:
    BaseStackNameParameter:
        Type: String
        Default: assetstack
        
    AssetVal:
        Type: String
        Default: !ImportValue
                  'Fn::Sub': '${BaseStackNameParameter}-Asset'

CodePudding user response:

The error is correct. You can't do this. Such functionality is not supported by CloudFormation.

CodePudding user response:

you should try and write the import syntax that way:

Fn::ImportValue: !Sub '${BaseStackNameParameter}-Asset'
  • Related