Can Ansible reference pre-existing CloudFormation stacks?

24 views
Skip to first unread message

vjorg...@sixfivelabs.com

unread,
Mar 31, 2016, 3:18:45 AM3/31/16
to Ansible Project
Hi! I have an ansible playbook that looks something like the one below (edited for brevity). I have another CloudFormation stack created by another process outside my control that creates many common references. Is there a way to make "common_stack" a variable such that "{{ common_stack.stack_outputs.<NameOfAnOutput> }}" behaves as though the other stack had been created inside this playbook? I have the ARN and stack name, if that helps. If not, how have others solved this problem? Best, Vincent

---
- name: Provision {{ app_name }}
  hosts: localhost
  connection: local
  gather_facts: False
  vars:
    app_name: "new_app"
    region: "us-east-1"
    common_stack_arn: "arn:aws:cloudformation:us-east-1:<account>:stack/stack-common/<hyphen-separated_hexadecimals>"
    stack_common: # I don't know how to do this part
  tasks:
    - name: "{{ app_name }} cloudformation"
      cloudformation:
        stack_name: "stack-{{ app_name }}"
        state: "present"
        region: "{{ aws_region }}"
        disable_rollback: true
        template: "cloudformation.json"
        template_parameters:
          AppName: "{{ app_name }}"
          InstanceType: "{{ stack_common.stack_outputs.InstanceType }}"
          SecurityGroupId:  "{{ stack_common.stack_outputs.CommonSecurityGroup }}"
          VpcId: "{{ stack_common.stack_outputs.VpcId }}"
        tags:
          Stack: "{{ app_name }}"
Reply all
Reply to author
Forward
0 new messages