Skip to main content

Posts

Showing posts with the label devops

The new way of importing resources in Terraform

Terraform has recently launched the version 1.5.0 which introduced the much awaited feature of creation of configurations for imported resources. With the introduction of this new feature, users don't need to write the imported resources configuration manually.  Let's understand in detail about this new way of importing the resources to bring them under the management of terraform. The new way of Terraform Import In new way of terraform import, Terraform has introduced a new import block which you can add to any Terraform configuration file. A common pattern is to create a separate file for all of your import blocks with the name "imports.tf". Syntax # Write an import block import { to = RESOURCE_ADDRESS id = RESOURCE_ID } Let's see the new workflow for importing the resources. Example : Let's say, we have manually created a vpc and two subnets inside it in google cloud. Now we want to import and manage these manually created resources using terraform. Ste...

The comparison between Old vs New way of Terraform Import

Recently, Terraform has launched the version 1.5.0 with the feature of configuration generation for resources to be imported and bring them under terraform management. But make a note of it that configuration generation is available in Terraform v1.5 as an experimental feature. Terraform Import before Terraform v1.5 Before v1.5, `terraform import` command was used to import existing resources into Terraform.  The import command takes two arguments - the resource address and ID. Import will find the existing resource using its ID and import it into your Terraform state at the given ADDRESS in your state file. Syntax > terraform import ADDRESS ID Let's see the import workflow in steps to understand it better. Example : Let's say, we have manually created a subnet inside a VPC in google cloud. Now we want to import and manage this manually created subnet using terraform. Step 01 Write a blank resource block according to the resource being imported. In our case, we will use the ...

Implicit Type Conversion in Terraform

Where possible, Terraform automatically converts values from one type to another in order to produce the expected type. If this isn't possible, Terraform will produce a type mismatch error and you must update the configuration with a more suitable expression. Example 01 If, You have declared a variable with the type - bool and provided its value - "true" i.e. string as mentioned below. # Variable  Declaration variable "example" { type = bool } # Variable  Definition example = "true" In this case, Terraform will internally transform the value to "true" to true (i.e. a bool type). Example 02 If, You have declared a variable with the type - list(string) and provided its value - ["a", 15, true] i.e. Tuple as mentioned below. # Variable  Declaration variable "example" { type = list(string) } # Variable  Definition example = ["a", 15, true] In this case, Terraform will internally transform the value to ["a...

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...

Git Credentials Storage

To contribute to a git repository, Git asks your username and password. Passing the credential every time could be hectic for us. Git has a credentials system to solve this. Git provides credential helpers to save the credentials more securely. Git has a few options provided in the box: 1.  The default is not to cache at all. Every connection will prompt you for your username and password. 2.  Cache: credentials stored in memory for short durations. 3.  Store: credentials stored indefinitely on disk. 4.  If you’re using a Mac, Git comes with an “osxkeychain” mode. This method stores the credentials on disk, and they never expire, but they’re encrypted with the same system that stores HTTPS certificates and Safari auto-fills. 5.   If you’re using Windows, you can install a helper called “Git Credential Manager for Windows.” This is similar to the “osxkeychain” helper described above, but uses the Windows Credential Store to control sensitive information. Git Conf...