0

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'
Marcin
  • 215,873
  • 14
  • 235
  • 294
Nitin G
  • 714
  • 7
  • 31
  • 1
    Does this answer your question? [how to use ImportValue in parameters?](https://stackoverflow.com/questions/60446398/how-to-use-importvalue-in-parameters) – Paolo Apr 28 '22 at 11:23
  • Hey, @Paolo thanks for the suggested post. The question is almost similar but doesn't have an answer. Therefore that doesn't answer my question. – Nitin G Apr 28 '22 at 12:25
  • Yes, it does have an answer https://stackoverflow.com/a/63691486/3390419 , and it's exactly what you want to do – Paolo Apr 28 '22 at 12:28
  • By answer, I meant an accepted answer. Not the general answer. Also, my motive is to import the value in the parameter itself, not the resources. which I don't see happening in the shared link answer. – Nitin G Apr 28 '22 at 12:47

1 Answers1

1

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

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • Thanks, Marcin for the info, but is there any alternate solution? This question is in succession to my previous question i.e. https://stackoverflow.com/q/71908962/9548311 – Nitin G Apr 28 '22 at 10:58
  • 1
    @NitinGarg You have to use `ImportValue` in your resources, not `Parameters`. If you require other functionality, CloudFormation may be the wrong tool for your job. – Marcin Apr 28 '22 at 10:59