Botocore: CloudFormation create_stack_set: ValidationError Parameters must have values when using empty default parameter values

Created on 1 Nov 2018  路  5Comments  路  Source: boto/botocore

When using boto3/botocore via a Python script and when using the AWS CLI to create a CloudFormation stack set using a template that has a parameter whose default is set to '' and a value for that parameter is not provided on the create_stack_set() call, botocore complains with the following error:

botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the CreateStackSet operation: Parameters: [pTestParm1] must have values

Versions

Name: boto3
Version: 1.9.14

Name: botocore
Version: 1.12.15

Sample Template

Here's an example template:

AWSTemplateFormatVersion: 2010-09-09

Parameters:
  pTestParm:
    Type: String
    Default: ''

Conditions:
  cTestParmPresent: !Not [ !Equals [ !Ref pTestParm, '' ] ]

Resources:
  rTestBucket:
    Type: AWS::S3::Bucket
    Condition: cTestParmPresent

AWS CLI

Here's the command used to reproduce the issue using the AWS CLI:

aws cloudformation create-stack-set \
                     --stack-set-name test-empty-parm \
                     --template-body file://./test-empty-parm.yml \
                     --capabilities CAPABILITY_NAMED_IAM \
                     --administration-role-arn ... \
                     --execution-role-name ... \
                     --region us-east-1 \
                     --profile ...

Works With AWS Console

When the AWS console is used to create the stack set with the same test template as shown above, the stack set is created successfully.

Works When Creating a Stack

The template is processed successfully when a CloudFormation stack is created:

aws cloudformation create-stack \
                     --stack-name test-empty-parm \
                     --template-body file://./test-empty-parm.yml \
                     --capabilities CAPABILITY_NAMED_IAM \
                     --region us-east-1 \
                     --profile ...

Workaround

As a workaround, an arbitrary value can be used as the default value and the associated conditions can test for equivalence on that value.

A downside of this workaround is that the dummy value used as the default value would need to conform to an AllowedPattern if it was useful to have an AllowedPattern for a given parameter. e.g. if the parameter represented an ARN, then the AllowedPattern would be the form of an ARN and the dummy value would have to be as equally complicated and long with the condition check.

For example:

AWSTemplateFormatVersion: 2010-09-09

Parameters:
  pTestParm:
    Type: String
    Default: 'None'

Conditions:
  cTestParmPresent: !Not [ !Equals [ !Ref pTestParm, 'None' ] ]

Resources:
  rTestBucket:
    Type: AWS::S3::Bucket
    Condition: cTestParmPresent
service-api

All 5 comments

CloudFormation has a built in None / Null equivalent AWS::NoValue that you could probably also use here, though I don't know how it interacts with AllowedPattern.

Also encountering this bug with templates that work outside of StackSets. I don't believe that the AWS::NoValue suggestion will work since Fn::Ref is invalid within the Parameters section.

I'm also facing the same issue here in StackSet, trying to update a stackset using a default empty value in the template. I'm gonna try the workaround to see if that works for me.

@ckamps - The error you are getting is coming from the service. I have reached out to the cloudformation stack set team and they are working on a fix for it. Once i hear back from them i will update the issue accordingly.

The service team has fixed the issue. Now it is possible to create a stack set using empty default parameter value.

I am closing the issue as the issue has been fixed. Please reopen you are still getting error.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kjschiroo picture kjschiroo  路  4Comments

ThisGuyCodes picture ThisGuyCodes  路  5Comments

kapilt picture kapilt  路  5Comments

stig picture stig  路  3Comments

jagill picture jagill  路  3Comments