Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudFormation Transform::Include parameters

I want to use AWS macro Transform::Include with some dynamic parameters for my file.

Resources:
  'Fn::Transform':
    Name: 'AWS::Include'
    Parameters:
      TestMacroVariable: 
        Default: 2
        Type: Number
      Location: !Sub "s3://${InstallBucketName}/test.yaml"

test.yaml:

DataAutoScalingGroup:
  Type: AWS::AutoScaling::AutoScalingGroup
  Properties:
    LaunchConfigurationName: 
      Ref: DataLaunchConfiguration
    MinSize: '1'
    MaxSize: '100'
    DesiredCapacity: 
      Ref: TestMacroVariable
...

After calling: aws cloudformation describe-stack-events --stack-name $stack

I get:

"ResourceStatusReason": "The value of parameter TestMacroVariable under transform Include must resolve to a string, number, boolean or a list of any of these.. Rollback requested by user."


When I try to do it this way:

Resources:
  'Fn::Transform':
    Name: 'AWS::Include'
    Parameters:
      TestMacroVariable: 2
      Location: !Sub "s3://${InstallBucketName}/test.yaml"

I get:

"ResourceStatusReason": "Template format error: Unresolved resource dependencies [TestMacroVariable] in the Resources block of the template"

Error is the same when I don't provide TestMacroVariable at all.


Tried with different types: String, Number, Boolean, List - none of them work.

like image 485
Dawid Fieluba Avatar asked Jan 03 '19 14:01

Dawid Fieluba


People also ask

How do you reference parameters in CloudFormation?

Referencing a parameter within a template You use the Ref intrinsic function to reference a parameter, and AWS CloudFormation uses the parameter's value to provision the stack. You can reference parameters from the Resources and Outputs sections of the same template.

What is AWS :: NoValue?

AWS::NoValueRemoves the corresponding resource property when specified as a return value in the Fn::If intrinsic function. For example, you can use the AWS::NoValue parameter when you want to use a snapshot for an Amazon RDS DB instance only if a snapshot ID is provided.

What is ImportValue in CloudFormation?

The intrinsic function Fn::ImportValue returns the value of an output exported by another stack. You typically use this function to create cross-stack references. In the following example template snippets, Stack A exports VPC security group values and Stack B imports them.

What is dynamic reference in CloudFormation?

When you use a dynamic reference, CloudFormation retrieves the value of the specified reference when necessary during stack and change set operations. CloudFormation currently supports the following dynamic reference patterns: ssm, for plaintext values stored in AWS Systems Manager Parameter Store.


1 Answers

As i know you cannot have anything other than Location key in the Parameters section of the AWS::Include. Check here AWS DOC

like image 90
Ntwobike Avatar answered Oct 17 '22 01:10

Ntwobike