Ingesting AWS CloudFormation Templates Larger than 51200 Bytes as an Artifact


Issue

Executing an AWS CloudFormation Template which is larger than 51200 bytes as an artifact leads to the following error in Spinnaker when using the CloudFormation Stage

'templateBody' failed to satisfy constraint: Member must have length less than or equal to 51200

Cause

The process of ingesting an Artifact, even from S3, is to take the artifact into Spinnaker so it can be manipulated and used across stages.  At that point, the file is no longer being ingested direction from S3, and is therefore, constrained by the AWS file size limitations outlined here:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html

Solution

To get around this issue, we recommend either restructuring your CloudFormation Templates using Nested Stacks as suggested by AWS

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html



Or you can also create a simple AWS CloudFormation template using the aws::include function 

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/create-reusable-transform-function-snippets-and-add-to-your-template-with-aws-include-transform.html


With the AWS Include Function, you can simply create an AWS CloudFormation Template which will be used to only ingest your YAML or JSON file from an S3 Bucket location.  An example of this would be to do the following

  1. Create your CloudFormation Stage in Spinnaker
  2. Your Template Configuration can be as simple as
    AWSTemplateFormatVersion: '2010-09-09'
    Transform:
      Name: 'AWS::Include'
      Parameters:
        Location: 's3://<bucketName>/<folderPath>/<filename>'
  3. Make sure you include the Capability, CAPABILITY_AUTO_EXPAND within the stage 
    or you will receive an error 

    Error Code: InsufficientCapabilitiesException;

  4. Save and run your pipeline

As Tested On Version

2.19.x