AWS Cloudformation- How to do string Uppercase or lowercase in json/yaml template
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
CloudFormation does not provide a built-in intrinsic function for converting strings to uppercase or lowercase inside a template. If you need case transformation, the practical options are to pass the already transformed value into the stack, use a custom resource or macro, or redesign the template so case conversion is not required at deploy time.
There Is No Native upper or lower
CloudFormation supports intrinsic functions such as Ref, Fn::Sub, Fn::Join, Fn::If, and Fn::FindInMap, but none of them perform string case conversion.
For example, this is valid string composition:
But there is no equivalent intrinsic such as !Upper or !Lower.
That means you cannot transform Prod into prod purely with standard CloudFormation functions.
Best Option: Pass the Correct Value In
The simplest answer is often to avoid conversion in the template and pass the exact string you need as a parameter.
Then the caller is responsible for supplying lowercase input. This is usually cleaner than embedding transformation logic into stack provisioning.
If a CI pipeline already knows the environment name, normalize it there:
For most teams, that is the right solution.
Use a Mapping If the Set of Values Is Small
If the input values are limited and predictable, a mapping can emulate case conversion indirectly.
This is workable for a fixed vocabulary, but it is not general-purpose string manipulation.
Custom Resource for True Transformation
If you genuinely need arbitrary runtime case conversion, use a Lambda-backed custom resource.
Template example:
Then use the returned value where needed:
This works, but it adds operational weight. You now own Lambda code, IAM permissions, logging, and failure handling.
Macros Are Another Option
CloudFormation macros can transform template fragments before resource creation. They are more powerful than custom resources for template rewriting, but they are also more infrastructure to maintain.
Macros are worth considering only if:
- many stacks need the same transformation
- you already operate CloudFormation extensions
- template preprocessing is part of your platform design
For a one-off lowercase need, a pipeline transform or parameter discipline is simpler.
Choose the Simplest Layer
Case conversion is rarely an infrastructure concern. Ask where it belongs:
- in the CI pipeline
- in the application build step
- in parameter validation
- in a custom CloudFormation extension
The answer is usually not "inside raw CloudFormation itself."
That design choice matters because templates should stay declarative. Once you push too much logic into deployment-time extensions, stacks become harder to reason about and debug.
Common Pitfalls
- Assuming CloudFormation has a built-in uppercase or lowercase intrinsic.
- Adding a custom resource when a normalized parameter would solve the problem.
- Using mappings for values that are not actually fixed and enumerable.
- Forgetting that custom resources introduce IAM, logging, and failure-handling overhead.
- Treating deployment-time string conversion as mandatory when the pipeline could provide the final value directly.
Summary
- CloudFormation has no native function for uppercase or lowercase conversion.
- The simplest fix is to pass the correctly cased parameter into the stack.
- Mappings work only for small, known sets of values.
- Custom resources or macros can do real transformation but add operational complexity.
- Prefer solving case normalization before the template runs whenever possible.
Related reading
- AWS Cloudformation Conditionally create properties of resources
- AWS CloudFormation create-stack vs deploy
- AWS Cloudformation How to reuse bash script placed in user-data parameter when creating EC2?
- AWS CloudFormation Stack update error Requires capabilities CAPABILITY_IAM
- Aws cloudformation validate-template keeps giving error Template format error
- AWS CloudFront access denied to S3 bucket
- AWS CloudFront Custom domain name with HTTPS not working
- AWS CloudFront Font from origin has been blocked from loading by Cross-Origin Resource Sharing policy

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.