amazon web services - AWS/Cloudformation: How to export/import parameter value to another stack (YAML) -


i have simple question. testing export/import of values in cloud formation.

question is: how create resources based on linked conditions stack?

i think should import value other stack, don't know how....

this "export-test-stack"

awstemplateformatversion: '2010-09-09'    description: export    parameters:    envtype:       description: how many instances want deploy?      default: 2      type: string      allowedvalues:         - 2        - 3      constraintdescription: must specify number of deployed instances    conditions:     deploy3ec2: !equals [ !ref envtype, 3 ]           resources:    ec2instance1:      type: aws::ec2::instance      properties:        instancetype: t2.micro        securitygroupids:        - sg-5d011027        imageid: ami-0b33d91d    ec2instance2:      type: aws::ec2::instance      properties:        instancetype: t2.micro          securitygroupids:        - sg-5d011027        imageid: ami-0b33d91d    ec2instance3:      type: aws::ec2::instance      condition: deploy3ec2      properties:        instancetype: t2.micro        securitygroupids:        - sg-5d011027        imageid: ami-0b33d91d            outputs:    ec2conditions:      description: number of deployed instances      value: !ref envtype      export:        name: blablabla

this "import-test-stack"

awstemplateformatversion: '2010-09-09'    description: import            resources:    ec2instance1:      type: aws::ec2::instance      properties:        instancetype: t2.micro        securitygroupids:        - sg-7309dd0a        imageid: ami-70edb016    ec2instance2:      type: aws::ec2::instance      condition: ??????  <<<<<<<<<      properties:        instancetype: t2.micro          securitygroupids:        - sg-7309dd0a        imageid: ami-70edb016

it's cross stack reference, want deploy ec2instance2 in "import-test-stack" if choose deploy 3 instances in previous "export-test-stack". how this?

so if choose deploy 3 instances, want use condition in "import stack" deploy 2 instances, if choose deploy two, deploy 1 instance in "import-stack"

i know how conditions working, still not able find way, how use in cross reference stacks.

i know it's stupid example, wanted test on simple template possible.

you have 2 choices: continue separated stacks or combine them create nested stack.

with nested stacks can use outputs 1 stack inputs stack.

if want keep using separated stacks use fn::importvalue function import output values exported stack.

the both angles have been covered in exporting stack output values page. also, cross-stack reference walkthrough might if choose use fn::importvalue.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -