Terraform Numeric Functions Cheatsheet

Search for a command to run...

No comments yet. Be the first to comment.
Intro When working on a monolith and traffic increases, you might decide to start caching to manage the new volume. If your system is modern or small, you have several caching strategies: Handle the caching logic within the code by integrating somet...
The AWS CLI sync command is a powerful tool for copying new and updated files between a source and destination, with at least one of them being an S3 Bucket. This command can also be used to perform sync between S3 Buckets without the need to transit...

A tutorial using the AWS console

A Step Function Distributed Map and Lambda Demo

Amazon CloudFront CloudFront is Amazon’s offer for Content Delivery Network. The CDN is composed of a globally distributed set of caching servers that provide low latency and high throughput all around the world. The network is based on more than 300...

This is a recap of Terraform numeric functions, to read the updated and complete documentation visit the hashicorp page.
min(set number) number
Given a set of numbers (or a compatible structure), this function returns the smallest one
>min(1,55,127,4,10)
1
>min([55,4,10]...)
4
max(set number) number
Given a set of numbers (or a compatible structure), this function returns the biggest one
>max(1,55,127,4,10)
127
>max([55,4,10]...)
55
parseint(string stringNumber, number base) number
Given a string representation of a number and its base, this function will return an integer.
The base must be between 2 and 62 inclusive.
>parseint("25", 10)
25
>parseint("1FF", 16)
511
>parseint("111", 2)
7
floor(number num)
This function will return the closest whole number that is less or equal to the input number. The input number can be decimal.
>floor(11.9)
11
>floor(11)
11
floor(9.1)
9
ceil(number num)
This function will return the closest whole number that is greater or equal to the input number. The input number can be decimal.
>ceil(11.9)
12
>floor(11)
11
floor(9.1)
10
abs(number num) number
Given an integer number, abs will return its absolute value. If the input number is negative, it will be multiplied by -1.
>abs(10)
10
>abs(-10)
10
>abs(0)
0
pow(number num, number elevation)
This function will elevate the first argument num to the second argument elevation.
>pow(4,2)
16
>pow(3,1)
3
>pow(9,0)
1
signum(number num)
This function returns a number representing the symbol of the input number.
>signum(-1)
-1
>signum(1)
1
>signum(9999)
1
>signum(0)
0