Review CloudFormation stack template inputs

Supply a template for new stacks and distinguish intentional reuse of an existing template.

Description

A new CloudFormation stack needs a template defining its resources. When updating an existing stack, Ansible can reuse its previous template. Deletion needs no new template.

Potential impact

Creation fails without a template. An update that unintentionally reuses the old one can leave expected resource changes unapplied.

Remediation

For a new stack or StackSet, supply one template source supported by the installed module. For a stack, use template_body or an accessible template_url. For an update, decide whether to reuse the previous template and review the changes.

Examples

Before

yaml
- name: Create the CloudFormation stack
  amazon.aws.cloudformation:
    stack_name: ansible-cloudformation
    state: present
    region: us-east-1
    disable_rollback: true
    template_parameters:
      KeyName: jmartin
      DiskType: ephemeral
      InstanceType: m1.small
      ClusterSize: 3
    tags:
      Stack: ansible-cloudformation

After

yaml
- name: Create the CloudFormation stack
  amazon.aws.cloudformation:
    stack_name: ansible-cloudformation
    state: present
    region: us-east-1
    disable_rollback: true
    template_url: https://s3.amazonaws.com/my-bucket/cloudformation.template
    template_parameters:
      KeyName: jmartin
      DiskType: ephemeral
      InstanceType: m1.small
      ClusterSize: 3
    tags:
      Stack: ansible-cloudformation

Only the second task supplies a new template URL. Verify that the actual template accepts KeyName, DiskType, InstanceType and ClusterSize and that their values suit the deployment.

References