Skip to main content

Posts

can( ) and try( ) built-in functions of Terraform

There are a lot of built-in functions available in Terraform to use. These built-in functions can improve your code and its readability. So let's get started with some of the built-in functions that can be beneficial for you while writing terraform code. 1. Can Function can function evaluates the given expression and returns a boolean value. Return value would be 'true', if the expression produces a result without any errors otherwise it will return 'false'. The primary purpose of can function is to turn an error condition into a boolean validation result when writing custom variable validation rules. Let's take a look at a few examples to understand the working of can function.  variable "eip_name" { type = string default = "eip-test" validation { condition = can( regex ( "^eip-" , var . eip_name )) error_message = "The external IP name must be a valid name starting with \" eip- \" ....

SSL Certificate and Handshake Process

A protocol is a set of rules which defines, how a particular thing will happen. HTTP is a network protocol which allows the fetching of resources, such as HTML documents. It is the foundation of any data exchange on the Web. We usually see a lock symbol in websites which has https. Here, "s" stands for security. To achieve this security, another protocol "SSL/TLS" is used. SSL is an encryption protocol which ensures the encrypted communication between two parties (i.e. client and a server). SSL (Secure Socket Layer) is now known as TLS (Transport Layer Security).  To achieve a secure communication between client and server using SSL/TLS, a series of steps happens which are known as SSL/TLS Handshake. Note SSL Certificate works on a TCP (Transmission Control Protocol) protocol to send data over the internet. All TLS handshake works on Public Key Cryptography. Public-key cryptography or asymmetric cryptography uses a pair of keys to encrypt and decrypt the data. The p...

Variables and Data Types in Terraform

A variable is something which can hold a value of a particular type that we usually use to make our configuration dynamic by passing those variables as parameters. Variable Declaration To declare any variable in terraform, use "variable" key word before variable name with a pair of curly braces. Below are the arguments which we can use for it to define its properties and other stuffs. Though all of these are optional. We can use them as per our need. 1. default -  This is to provide a default value for the variable. 2. type -  This is to specify the variable's data type. 3. description -  This is used to provide a description of variable for better understanding of code. 4. validation -  This block is used to do a certain type of validation against the variable value. 5. sensitive -  If this is set to true, you won't see these values in output console and these values won't be captured in Log files. Example 01: variable "sa_name" {} Example 02: variabl...