[SOLVED] Error: multiple EC2 Instances matched; use additional constraints to reduce matches to a single EC2 Instance

When you are using data sources for aws_instance probably to fetch the IP address or something else, data "aws_instance" "foo" { filter { name = "tag:Name" values = ["instance-name"] } } You must have faced the following issues while using Terraform for EC2 instances. │ Error: multiple EC2 Instances matched; use additional constraints to reduce matches to a single EC2 Instance Why this issue occurs? There’s a fair chance that the previous instance with the same name is destroyed, but there’s still an entry with the terminated state....

February 12, 2023 · 1 min · Suraj Narwade

Installing & Setting up Golang

Golang, also known as Go, is a programming language developed by Google. Today, it is used by many organisations for their web applications and CLI tools. Many OpenSource projects in cloud-native spaces, such as Kubernetes and Docker, were written using Go. Golang is known for its simplicity, efficiency, and scalability. This blog post will walk you through installing and setting up Golang on your computer. Downloading the Go Go to this link https://go....

January 19, 2023 · 2 min · Suraj Narwade

Difference between Setting & Adding the Headers in HTTP API in Golang

While working with APIs, headers are an essential aspect. Sometimes we set them, or sometimes we consume them and make decisions. When I was exploring headers in Golang, I came across two methods. Headers.Set() & Headers.Add() Initially, I thought they were the same. But then I wondered if they are the same, then why two methods? Let’s understand. I will be using a proxy which will use Add & Set on headers, as shown below,...

January 18, 2023 · 2 min · Suraj Narwade

Why close the HTTP API response body in Golang? What if you don't...

In the previous article, we saw how to make the HTTP GET API request in Golang. While going through the example, we discussed closing the response body. In this article, Let’s discuss why it is essential to close the response body. What is the response body? The response body is a stream of data that is read from the server. Why should I close it? Ensure all data has been read and the resources associated with it are freed up....

January 14, 2023 · 2 min · Suraj Narwade

How to make an HTTP GET request in Golang?

Golang is one of the widely used languages for designing API Clients. While you design the client, one of the important aspects of the client is fetching the data from the API in some format using a GET request. Here’s the curl command example, which mimics the GET request which we will write code for in Golang, $ curl -XGET localhost:8080 {"message":"hello world !!!"} Note: I already have a basic webserver running, Hence I can get the output on localhost....

January 13, 2023 · 2 min · Suraj Narwade

How to use Golang with MySQL?

Golang is a widely used language for building scalable and reliable web applications. When it comes to Storing data (relational), MySQL is one of the old and preferred ways as a database for many organisations. This blog post will look at how to use Golang with MySQL by establishing the connection and printing the version using a simple query. In upcoming blog posts, we will see advanced operations. Prerequisites To follow along with this tutorial, you should have the following installed on your machine:...

January 9, 2023 · 3 min · Suraj Narwade

Read Terraform's plan the better way

Last year, I started exploring and studying terraform for work. While studying, I mostly relied on Terraform plan command to check the output plan. As terraform module I was writing got bigger, the plan got bigger too, and I needed to store the plan in a file and then read & analyse the file later. For example, I want to read the plan for the following resource & store it in a file,...

December 19, 2022 · 2 min · Suraj Narwade