Terraform Best Practices

introduction

Nowadays, Cloud Computing is a de-facto standard adopted by companies or individuals to create their applications. Companies that offer solutions, that could be one of the main three models (IaaS – Infrastructure as a Service, PaaS – Platform as a Service, and Software as a Service) are called cloud providers, or simply providers.

Providers offer resources that are like building blocks for DevOps people to create suitable infrastructure for their applications. The number, type, and cost of resources may vary from provider to provider. There should be a study before choosing what provider better fits the project

To create those resources, providers offer a web console that DevOps can manage them. The problem of managing the resources on the web console is to keep track of what was created. That’s nothing that a plain text file or an Excel sheet can solve, right? Nope!

Then providers created a more fun way (yeah, fun!) to create the resources: a command-line interface (CLI). Now DevOps can create scripts (Shell or Power Shell Script) to manage when creating, modifying, or destroying a resource. The problem is when adding some new resources, that are not in the scripts, a new script should be created only for this to manage its lifecycle.

Don’t worry, there is a solution that can be adopted: Terraform, which is a provider agnostic CLI that interprets its own programming language (HCL – HashiCorp Configuration Language) that describes Cloud Computing Provider resources. With this tool, it’s possible to manage the infrastructure without taking notes on Excel or Notepad or even creating Scripts to manage the infrastructure. Ok, it can do more than this as it’ll be explained here.

In this article, I will list some tips best practices I reunited during my experience with Terraform.

Read more

Folding Hash

Sometimes, it’s needed to implement a different algorithm to solve problems in the developing system. All the algorithms are challenging. Some are used to improve the system because they represent a structure that repeats with a certain frequency. They are called patterns. Others are business algorithms, that dictates the way that received data should be treated inside a system. Anyway, there’s a lot of categories of algorithms.

This article is about the implementation of the Folding Hash Algorithm. It’s based upon another article, providing an implementation.


Read more

Where in the Code is Carmen Sandiego?

Back in the ’90s, Carmen Sandiego recruited the most expert burglars around the world (and in time) to steal paintings, sculptures, and other humanity’s important legacy creations. Every time that an investigator (in this case: you) start its endeavor to arrest one member of Carmen’s gang or herself, in the scene of the crime there are two clues:

  1. The first clue is about where the burglar goes next
  2. The second is about the burglar (some characteristic)

The mission ends when the investigator is at the same location (or time) and when there’s a prison order emitted to the member of the gang. With these two things combined, the investigator can capture the gang member and complete the mission.

This article is about the search of the suspect according to the clues, that can be the gender, the color of the eyes or hair, the occupation and the burglar’s favorite food using functional programming in Java.

Read more

JEP 286 – Java 10 Local-Variable Type Inference – The var reserved word

The Java version 10 brought a new reserved word (var) and with it a new mechanism to the language: the Local-Variable Type Inference.

Source code

The code that was used to create this article is versioned in Java10Examples project on github. Fork or clone to execute in your computer. Please, star this project and follow me on github.

The old way

Sure that every developer declares local variables and follows the Java common syntax to do it:

(...)
    type variableName = variableConstruct
(...)

Everybody knows that it’s needed to tell java what kind of variable developers are working, so type is the variable type that should be told to Java.

Read more

Common method implementation in Java (equals, hashCode and toString)

Some methods in Java are special and help developers to implement rules of equality between two objects. Some classes need that those methods are implemented to system’s good behaviour. In this article will be discussed those methods.

About the code

The code that was used to create this article is versioned in JavaBasicConcepts project on github. Fork or clone to execute in your computer. Please, star this project and follow me on github.

This project will be updated sometimes with other basic Java programming concepts.

Equality in Java

Sometimes developers need the if conditional to commute to alternate flows or to test the consistency of data. The Java programming language has the == operator and the equals method to perform these tasks.

Read more

The for loop evolution in Java

Introduction

This article shows how the for loop evolved along the versions of Java.

Java is a C-Like programming language and it means that programmers don’t need to learn new program structure before coding. the loop and conditional statements are almost the same.

In a given moment, Java and C evolved separately adding new structures or updating the existents.

Read more

Learning the basics of Java 8 Lambda with Star Wars

Introduction

Star Wars is the most famous brand in this side of the universe. All it’s stories occurs a long time ago in a galaxy far far away. It generated tons of fans around the world within many and many generations. With eight movies, seven in the main saga and one spin-off (at the moment I am writing this article there were two upcoming movies, one of the main saga and other spin-off), many things can be done to browse data. I’m ignoring the Holiday Special and the two Ewoks movies. Feel free to input these movies data in the all_star_wars_movie.json data file.

Read more

The physicist swift

This article provides a way to implement the functional way of thinking in swift. Will be used the Torricelli formula for illustrating the examples.

Introduction

Evangelista Torricelli was an italian physicist and mathematician that invented the barometer and make valuable contributions to the optics field. He created the following formula to find the final velocity of am object moving along an axis (x or y) with constant accelearation.

His formula is:

torricelli_en

Where

  • vf is the final velocity
  • vi is the initial velocity
  • a the acceleration
  • x the displacement

Read more

Constants in your application

Introduction

Variables are the core of all programs. Some kind of variables are special and they will not change, they are called constants. If you introduce a constant to your program, there’s a good to reason. Maybe it’s documented, maybe not. Well, it should be. Sometime, other programmer, or even you, will see that constant and ask what that piece of code (or other word from your preference) is that.

This article intends to explain some options to put and manage constants using the Java Programming Language.

Read more