Your containerized application with IAC on AWS — Pt.1
Published: 2024-05-03 17:09:58

These days, automation and efficiency are critical in the realm of cloud computing. The administration of your containerized apps may be optimized with AWS Fargate and Infrastructure as Code (IaC). This blog article will walk you through the process of utilizing these potent technologies to increase your applications scalability and efficiency.

**FARGATE**
Amazon’s container computing service, Fargate, allows you to use AWS containers without the need to manage servers.
[I have written a blog article regarding Fargate that you may read here.](https://medium.com/@shescloud_/what-is-aws-fargate-4387f7ea31d1)

**INTRODUCTION TO INFRASTRUCTURE AS CODE (IAC)**
Infra as code is super important when we think about a stable, scalable and prepared infrastructure for any accident. You may use software development methods like code review and continuous testing, as well as version, reuse and share your configuration by describing your infrastructure in configuration files.

[I’ve written a blog article about Terraform and Terragrunt, which we’ll be using in this instance.](I’ve written a blog article about Terraform and Terragrunt, which we’ll be using in this instance.)

**CONNECTING AWS TO YOUR COMPUTER**
With the help of the AWS CLI, you can easily control AWS services from the terminal on your PC. It allows you to use scripts to automate operations and manage a variety of AWS services.

_**INSTALLATION OF AWS CLI**
windows_
Go to the [official AWS website](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-version.html) and download the MSI installation.

_Linux_
To download the installation package, use curl. Apply the subsequent command:

```
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.0.30.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
```

To confirm if it was installed, run the command:

```
aws --version
```

**MacOs**
Run the installer after downloading it from this link: [https://awscli.amazonaws.com/AWSCLIV2-2.0.30.pkg](https://awscli.amazonaws.com/AWSCLIV2-2.0.30.pkg)

```
which aws
aws --version
```
…………………………………

**INSTALLATION OF TERRAFORM AND TERRAGRUNT
TERRAFORM**
_**Linux**_
First, open your terminal. We’ll use wget or curl to download the latest version of Terraform:

```
wget https://releases.hashicorp.com/terraform/1.1.0/terraform_1.1.0
```

Now, if unzip isn’t already installed, let’s install it before unzipping the file:

```
sudo apt-get install unzip -y
unzip terraform_1.1.0_linux_amd64.zip
```

In this step, we will move the terraform executable to a directory included in your system PATH, such as /usr/local/bin:

```
sudo mv terraform /usr/local/bin/
```

Finally, we’ll check if the installation is legitimate:

```
terraform -version
```

_**Windows**_

1.[Visit the official Terraform website](https://developer.hashicorp.com/terraform/install) and get the Windows binary that is needed.
2. Use WinZip, WinRAR or another unzip application, to extract the file.

3. Put Terraform in the Path System

Click “This Computer” with a right-click, then choose “Properties.”
Select ‘Environment Variables’ after selecting ‘Advanced System Settings’.
Locate the Path variable under ‘System Variables’ and modify it by adding the path of the directory where you unpacked Terraform.
4. Use the Command Prompt to Confirm Installation:

```
terraform -version
```

**_MacOs_**
We are going to start installing Homebrew. If you do not yet have Homebrew, you may install it using this command on the terminal:

```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

Here, we will install the terraform using Brew. Without a terminal, run:

```
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
```

Finally, we will check whether everything is well with our installation:

```
terraform -version
```
---

**TERRGRUNT
_Windows_ :** You can install Terragrunt on Windows by using Chocolatey :.choco install terragrunt

**_MacOS :_** You can install Terragrunt on Mac by using Homebrew :.brew install terragrunt

_**Linux :**_ Most Linux users are able to use Homebrew : brew install terragrunt. Users of Arch Linux can utilize pacman -S terragruntto install it community-terragrunt.

**_FreeBSD :_** You can install Terragrunt on FreeBSD by using Pkg :.pkg install terragrunt

……………………………………

**Configure AWS CLI**
In this blog article, we will create a new user and configure our credentials. This user here belongs to the adm group, but be careful when it is necessary to give permissions to other people who use your account or who are users of your organization. Adopt the concept of least privilege always. [You may read more about IAM on my blog post here](https://medium.com/@shescloud_/aws-iam-identity-and-access-management-7700ecf4dec7).

We navigate to IAM -> Users -> Create User. Once the user is created, we will create the credentials. To do this, log in with your credentials and select Security Credentials -> Access Keys -> Create Access Key.

Remember to copy the credentials exactly as they were created.

After creating the credentials, lets open a terminal and set up the AWS CLI. To do this, type the command below and provide your credentials:

```
aws configure
```

To test, simply run a command for any service. Here we will try to list the EC2 instances of the account.

```
aws ec2 describe-instances
```

If it returns anything like the code below, it means that it worked. If there is no instance, the code below will be returned; if there is an instance, the information from the GIF conformation will be returned.

```
{
    "Reservations": []
}

```
……………………………………

Now that the requirements are all up and operational, we can use Terraform and Terragrunt to build our infrastructure.
In part two of this series, let’s see how. See Ya!