0

I have the following piece in my CloudFormation template

 PublicSubnetA:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref VPC
      CidrBlock: 10.1.10.0/24
      AvailabilityZone: !Select [ 0, !GetAZs ]    # Get the first AZ in the list        
      Tags:
      - Key: Name
        Value: !Sub
          - ${AWS::StackName}-PUB-${SUFFIX}
          - SUFFIX: !Select [ 0, !GetAZs ]

I need SUFFIX to be in uppercase, how do I do it?

nomadus
  • 859
  • 1
  • 12
  • 28
  • I saw the note, but can't have it working for my case. It keeps saying a template validation error – nomadus Feb 10 '20 at 11:02
  • When I try to chain the functions it give the following error ."..intrinsic functions in transform block must only contain parameter values or stack metadata." – nomadus Feb 10 '20 at 11:35

1 Answers1

0

You could do it with the transform intrinsic function that calls a macro. Somebody has already written a bunch on string manipulation macros so if you deployed them you could use them with no extra coding.

https://github.com/awslabs/aws-cloudformation-templates/tree/master/aws/services/CloudFormation/MacrosExamples/StringFunctions

matt helliwell
  • 2,574
  • 16
  • 24
  • Transform seems not to support functions as parameters. It does not work for my case – nomadus Feb 10 '20 at 19:58
  • I'm sure I've done this at work, if I get chance I'll check when I'm back in tomorrow. – matt helliwell Feb 10 '20 at 20:08
  • It's not clear from the README posted, but you need to add that Python file as a transform function rather than just using the upper function. CF doesn't have any built-in support for this and you need to add your own transform function to do it. – shanet Jun 25 '20 at 00:22