<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: frankfolabi</title>
    <description>The latest articles on DEV Community by frankfolabi (@frankfolabi).</description>
    <link>https://dev.to/frankfolabi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1091285%2F29598e79-86c1-4dab-8b42-976ce25aa3d5.png</url>
      <title>DEV Community: frankfolabi</title>
      <link>https://dev.to/frankfolabi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/frankfolabi"/>
    <language>en</language>
    <item>
      <title>Managing Terraform State: Best Practices for DevOps</title>
      <dc:creator>frankfolabi</dc:creator>
      <pubDate>Sun, 01 Sep 2024 05:01:52 +0000</pubDate>
      <link>https://dev.to/frankfolabi/managing-terraform-state-best-practices-for-devops-1kg1</link>
      <guid>https://dev.to/frankfolabi/managing-terraform-state-best-practices-for-devops-1kg1</guid>
      <description>&lt;p&gt;How does Terraform knows which resources it manages? It uses a JSON format that records a mapping of the resources in the configuration files and the representation in those resources in the real world. This is known as Terraform state file. This is usually named &lt;code&gt;terraform.tfstate&lt;/code&gt;. For personal project, the state file can live on the local machine called the local backend. However, when working with a team, having the state files on numerous local machines can be a disaster, neither would it be great to have it in a version control system due to some sensitive secrets that the state file contains. What are some best practices for managing state in Terraform?&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage of State Files
&lt;/h3&gt;

&lt;p&gt;The best practice for storing state files is to use remote backends. Amazon S3, Azure Storage, Google Cloud Storage, Terraform Cloud and Terraform Enterprise all support remote backends. These storage options help to avoid manual error, support locking so that no two persons would run &lt;code&gt;terraform apply&lt;/code&gt; at the same time and protect secrets that may be contained in state files.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to create a remote backend on S3
&lt;/h4&gt;

&lt;p&gt;You can create an S3 bucket to store your state files. S3 buckets support versioning, encryption and security from public access. This makes the state file safe. You can also use DynamoDB to achieve state locking. Here is a Terraform configuration that can be deployed from another directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;provider "aws" {
    region = "us-east-2"
}
// Create a unique bucket
resource "aws_s3_bucket" "tf_state" {
  bucket ="&amp;lt;your-bucket-name&amp;gt;"

  # Prevent accidental deletion of the S3 bucket
  lifecycle {
    prevent_destroy = true
  }
}

// Enable bucket versioning
resource "aws_s3_bucket_versioning" "enables" {
  bucket = aws_s3_bucket.tf_state.id
  versioning_configuration {
    status = "Enabled"
  }
}

// Enable S3 server side encryption 
resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
  bucket = aws_s3_bucket.tf_state.id

  rule {
    apply_server_side_encryption_by_default {
      sse_algorithm = "AES256"
    }
  }
}

// Block public access
resource "aws_s3_bucket_public_access_block" "public_access" {
  bucket = aws_s3_bucket.tf_state.id
  block_public_acls = true
  block_public_policy = true
  ignore_public_acls = true
  restrict_public_buckets = true
}

// Create DynamoDB for locking
resource "aws_dynamodb_table" "terraform_locks" {
  name = "&amp;lt;your-table-name&amp;gt;"
  billing_mode = "PAY_PER_REQUEST"
  hash_key = "LockID"

  attribute {
    name = "LockID"
    type = "S"

  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now run the following Terraform commands in order &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;terraform init&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;code&gt;terraform plan&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;terraform apply&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An S3 bucket along with a DynamoDB table would be created. Next, configure the backend to store the state files remotely in the S3 bucket just created. This is the Terraform block to set the backend.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform {
  backend "s3" {
    bucket = "&amp;lt;your-bucket-name&amp;gt;"
    key = "global/s3/terraform.tfstate"
    region = "us-east-2"

    dynamodb_table = "&amp;lt;your-table-name&amp;gt;"
    encrypt = true
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you will need to run &lt;code&gt;terraform init&lt;/code&gt; again which will allow Terraform to configure the remote backend and copy the state file to the specified S3 bucket.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgtligy2ll4ndsir6nhz0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgtligy2ll4ndsir6nhz0.png" alt="configuring the backend" width="587" height="156"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a confirmation of &lt;code&gt;yes&lt;/code&gt;, the state file is no longer on a local machine but stored remotely. This will allow teams to collaborate efficiently without wreaking havoc on existing infrastructure. This is the best practice. However, how can environments be isolated? A future blog would provide a solution.&lt;/p&gt;

</description>
      <category>terraform</category>
      <category>devops</category>
      <category>aws</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Managing High Traffic Applications with AWS Elastic Load Balancer and Terraform</title>
      <dc:creator>frankfolabi</dc:creator>
      <pubDate>Sat, 31 Aug 2024 10:58:54 +0000</pubDate>
      <link>https://dev.to/frankfolabi/managing-high-traffic-applications-with-aws-elastic-load-balancer-and-terraform-4np8</link>
      <guid>https://dev.to/frankfolabi/managing-high-traffic-applications-with-aws-elastic-load-balancer-and-terraform-4np8</guid>
      <description>&lt;p&gt;You just configured your infrastructure to auto scale when the traffic increases. How would you manage the traffic and ensure some servers are not overwhelmed while others are not underserved? This is the essence of load balancing - to ensure traffic is distributed to your servers in a manner not  &lt;/p&gt;

&lt;p&gt;AWS offers elastic load balancing resources for layers 3, 4, and 7 of the OSI model. These are the Gateway load balancer, Network load balancer, and the Application load balancer types. The application load balancer (ALB) would be used for this webapp.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the ALB
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "aws_lb" "webserver" {
  name = "tf-example"
  load_balancer_type = "application"
  subnets = data.aws_subnets.default.ids
  security_groups = [aws_security_group.alb.id]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that the code block references the available subnet data, and the security group created for the ALB.  The ALB security group would be covered soon. Next, create the ALB listener.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the ALB listener
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "aws_lb_listener" "webserver" {
  load_balancer_arn = aws_lb.webserver.arn
  port = 80
  protocol ="HTTP"

  default_action {
    type = "fixed-response"

    fixed_response {
      content_type = "text/plain"
      message_body ="404: page not found"
      status_code = 404
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This resource used the port &lt;code&gt;80&lt;/code&gt; and the &lt;code&gt;http&lt;/code&gt; protocol. A fixed response was also set in case there is an error on the page and a status code of &lt;code&gt;404&lt;/code&gt; was used. &lt;/p&gt;

&lt;h3&gt;
  
  
  Create security group for load balancer
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "aws_security_group" "alb" {
  name = "tf-example"

  # Allow inbound HTTP request
  ingress {
    from_port = 80
    to_port = 80
    protocol = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

   #Allow outbound requests
  egress {
    from_port = 0
    to_port = 0
    protocol = "-1"
    cidr_blocks = ["0.0.0.0/0"]   
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The security group rule for the ALB is different from the one set for the webapp. Here the ALB accepts traffic from port &lt;code&gt;80&lt;/code&gt; from any traffic on the internet while it sends out request to all ports. Let's set the target group that would be used of the autoscaling.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create target group for auto scaling group
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "aws_lb_target_group" "webserver" {
  name = "tf-example"
  port =  var.server_port
  protocol = "HTTP"
  vpc_id = data.aws_vpc.default.id

  health_check {
    path = "/"
    protocol = "HTTP"
    matcher = "200"
    interval = 15
    timeout = 3
    healthy_threshold = 2
    unhealthy_threshold = 2
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a health check set up to confirm if the webservers are healthy or unhealthy. The target group will health check the webservers by periodically sending an &lt;code&gt;HTTP&lt;/code&gt; request to each webserver. If the response matches the &lt;code&gt;matcher&lt;/code&gt; then it determines it is healthy. Otherwise, it would be marked as unhealthy. The webserver will be using the port already defined in the variable and it will be placed in the default VPC. Finally, the ALB listener rules need to be created.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create the ALB listener rules
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "aws_lb_listener_rule" "asg" {
  listener_arn = aws_lb_listener.webserver.arn
  priority = 100

  condition {
    path_pattern {
      values = ["*"]
    }
  }
  action {
    type = "forward"
    target_group_arn = aws_lb_target_group.webserver.arn
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This listener rule sends request that matches any path to the terget group that contains the autoscaling group. The output block will filter out the application load balancer DNS name. This would be used to check the webapp.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;output "alb_dns_name" {
    value = aws_lb.webserver.dns_name
    description = "The domain name of the load balancer"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You are now good to go. Run &lt;code&gt;terraform validate&lt;/code&gt; to check if the configuration file syntax is valid. The run &lt;code&gt;terraform plan&lt;/code&gt; to check the changes that will take place. After seeing the new resources that would be created, run &lt;code&gt;terraform apply&lt;/code&gt;. Here is the output.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fca244xmbpwavgwz6nhbu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fca244xmbpwavgwz6nhbu.png" alt="outputs" width="461" height="60"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the terminal, you can verify the webapp is running by using the &lt;code&gt;curl&lt;/code&gt; comand. Run &lt;code&gt;curl http://&amp;lt;alb-dns-name&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcsj4dbah1pxo1xy5lp01.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcsj4dbah1pxo1xy5lp01.png" alt="curl on terminal" width="800" height="35"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The webserver is now highly available and receiving its traffic from a load balancer which is more secure. &lt;/p&gt;

&lt;p&gt;We can check the AWS console to see some of the resources created by Terraform. Here are the instances running &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fktpy9kv2i9p2n3g4o1yn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fktpy9kv2i9p2n3g4o1yn.png" alt="Instances running" width="800" height="93"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and the security groups created&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdtvgjmz8cwt784ydlx7b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdtvgjmz8cwt784ydlx7b.png" alt="security group" width="800" height="134"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;as well as the load balancer&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0wx6cogdosb859n9oe17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0wx6cogdosb859n9oe17.png" alt="load balancer" width="800" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;along with the autoscaling group.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fltiaqnff6ulbg4alsjkw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fltiaqnff6ulbg4alsjkw.png" alt="auto scaling group" width="800" height="99"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To clean up all resources, simply run &lt;code&gt;terraform destroy&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In the future, other components would be added to the architecture. Feel free to ask your questions.&lt;/p&gt;

</description>
      <category>terraform</category>
      <category>aws</category>
      <category>devops</category>
      <category>infrastructureascode</category>
    </item>
    <item>
      <title>Deploying a Highly Available Web App on AWS Using Terraform</title>
      <dc:creator>frankfolabi</dc:creator>
      <pubDate>Wed, 28 Aug 2024 18:01:13 +0000</pubDate>
      <link>https://dev.to/frankfolabi/deploying-a-highly-available-web-app-on-aws-using-terraform-230</link>
      <guid>https://dev.to/frankfolabi/deploying-a-highly-available-web-app-on-aws-using-terraform-230</guid>
      <description>&lt;p&gt;It is so exciting to launch a single webserver, and you are now online. The media has made your product popular, and the internet traffic to your website is increasing greatly. How would we handle such a large number of requests? How can we ensure that out server does not go down due to overwhelming request? It would make sense to have additional servers to help hand this situation. Here come scaling which is the ability to increase the number or instance size of your server which we call horizontal or vertical scaling. Would it not be nice to automatically do this? Let us improve our architecture from the &lt;a href="https://dev.to/frankfolabi/deploying-your-first-server-with-terraform-a-beginners-guide-2jaa"&gt;previous post&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring the web server with variables
&lt;/h3&gt;

&lt;p&gt;You may have notice that the port number &lt;code&gt;8080&lt;/code&gt; was hardcoded and duplicated. It may be challenging to make changes without an error if there are numerous occurrences. A best practice is to follow the &lt;em&gt;Don't Repeat Yourself (DRY)&lt;/em&gt; principle. To male our code configurable we can define &lt;em&gt;input variables&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Let us define the port number as a variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;variable "server_port" {
  description = "The port the server will use for HTTP requests"
  type = number
  default = 8080
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;type&lt;/code&gt; constraint will ensure that only a number value is acceptable. the code block also specific that the &lt;code&gt;default&lt;/code&gt; port value as &lt;code&gt;8080&lt;/code&gt;. We can now refer to the variable in other places using &lt;code&gt;var.server_port&lt;/code&gt;.&lt;br&gt;
Let us now update the security group and the user data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "aws_security_group" "instance" {
    name = "tf-sg"

    ingress {
        from_port = var.server_port
        to_port = var.server_port
        protocol = "tcp"
        cidr_blocks = ["0.0.0.0/0"]
    }   
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating a highly available webserver
&lt;/h3&gt;

&lt;p&gt;To create a highly available, a launch configuration is needed and an auto scaling resource that will use this configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "aws_launch_configuration" "webserver" {
    image_id = "ami-0fb653ca2d3203ac1"
    instance_type = "t2.micro"
    security_groups = [aws_security_group.instance.id]

    user_data = &amp;lt;&amp;lt;-EOF
    #!/bin/bash
    echo "Hello, World. Welcome to the use of Terraform in deploying infrastructure" &amp;gt; index.html
    nohup busybox httpd -f -p ${var.server_port} &amp;amp;
    EOF

    lifecycle {
      create_before_destroy = true
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that the port in the &lt;code&gt;user data&lt;/code&gt; script has been updated. The &lt;code&gt;create_before_destroy&lt;/code&gt; would allow the autoscaling to be created first before destroying our single instance earlier launched.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "aws_autoscaling_group" "example" {
  launch_configuration = aws_launch_configuration.webserver.name
  vpc_zone_identifier = data.aws_subnets.default.ids

  target_group_arns = [aws_lb_target_group.webserver.arn]
  health_check_type = "ELB"

  min_size = 2
  max_size = 10

  tag {
    key = "Name"
    value = "tf-example"
    propagate_at_launch = true
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This block shows that a minimum number of servers that would run as &lt;code&gt;2&lt;/code&gt; and the maximum as &lt;code&gt;10&lt;/code&gt;. This will ensure that a single point of failure is avoided. &lt;/p&gt;

&lt;p&gt;In a future post, we will attach a load balancer to the autoscaling group and test traffic sent to it. Feel free to ask any questions and give feedback on how to improve. &lt;/p&gt;

</description>
      <category>terraform</category>
      <category>aws</category>
      <category>devops</category>
    </item>
    <item>
      <title>Deploying Your First Server with Terraform: A Beginner's Guide</title>
      <dc:creator>frankfolabi</dc:creator>
      <pubDate>Mon, 26 Aug 2024 03:54:31 +0000</pubDate>
      <link>https://dev.to/frankfolabi/deploying-your-first-server-with-terraform-a-beginners-guide-2jaa</link>
      <guid>https://dev.to/frankfolabi/deploying-your-first-server-with-terraform-a-beginners-guide-2jaa</guid>
      <description>&lt;p&gt;Now you have installed Terraform, configured your AWS account to use the CLI, and installed VS Code. What next? Let us get deploy our first webserver. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On VS Code, create a directory to store your files with &lt;code&gt;mkdir tf-files&lt;/code&gt; in the terminal&lt;/li&gt;
&lt;li&gt;Next create a main.tf file with &lt;code&gt;touch main.tf&lt;/code&gt;. You will write your configuration files here in Harshicorp Configuration Language.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx9d778p23ejupolcbgq7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx9d778p23ejupolcbgq7.png" alt="code to make create directory" width="413" height="33"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Here is the block of code that you can add in your &lt;code&gt;main.tf&lt;/code&gt; file &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Provider Block
&lt;/h4&gt;

&lt;p&gt;This shows that the provider is AWS and the region to be used is &lt;code&gt;us-east-2&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;provider "aws" {
    region = "us-east-2"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Resource block
&lt;/h4&gt;

&lt;p&gt;The resource block is used to define the resource Terraform would create. One interesting part is that Terraform would try to figure out which order to create these resources. In this resource block, we define the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Amazon Machine Image (AMI) &lt;/li&gt;
&lt;li&gt;Instance type &lt;/li&gt;
&lt;li&gt;Security group id &lt;/li&gt;
&lt;li&gt;User data script &lt;/li&gt;
&lt;li&gt;Tag
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "aws_instance" "webserver" {
    ami = "ami-0fb653ca2d3203ac1"
    instance_type = "t2.micro"
    vpc_security_group_ids = [aws_security_group.instance.id]
    user_data = &amp;lt;&amp;lt;-EOF
    #!/bin/bash
    echo "Hello, World. Welcome to the use of Terraform in deploying infrastructure" &amp;gt; index.html
    nohup busybox httpd -f -p 8080 &amp;amp;
    EOF
    user_data_replace_on_change = true
    tags = {
        Name = "tf-webserver"
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This other resource block declares the security group to allow traffic from port 8080 from any IPv4 address&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "aws_security_group" "instance" {
    name = "tf-sg"

    ingress {
        from_port = 8080
        to_port = 8080
        protocol = "tcp"
        cidr_blocks = ["0.0.0.0/0"]
    } 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can now save our &lt;code&gt;main.tf&lt;/code&gt; file. Next, let us now deploy the webserver. First, we need to download the required provider plugins. Run &lt;code&gt;terraform init&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6sv0o1mhysz4g9isnp2s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6sv0o1mhysz4g9isnp2s.png" alt="running terraform init" width="562" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may wonder, what are the provider plugin? These are executable binaries that the Terraform Core install on our laptop uses to communicate with the APIs of the cloud provider that has the resources we need. Notice that the screenshot uses the expression "Reusing previous version of . . ." This happens when you are running the &lt;code&gt;terraform init&lt;/code&gt; command after the first time. &lt;/p&gt;

&lt;p&gt;As a quick check to see if our file follows the right syntax, run &lt;code&gt;terraform validate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5236zoim5y425s6h0cxj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5236zoim5y425s6h0cxj.png" alt="Terraform validate" width="523" height="39"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What would our infrastructure look like? You can now run &lt;code&gt;terraform plan&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5aeu2fgt08t9yqt3z7rm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5aeu2fgt08t9yqt3z7rm.png" alt="terraform plan" width="800" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This information contains what resources would be created on the AWS. Now, let us proceed to deploy these resources. Run &lt;code&gt;terraform apply&lt;/code&gt;. A confirmation will pop-up to ensure you really want to deploy these resources. The only acceptable answer to proceed is &lt;code&gt;yes&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmb161m093zihb71ejr6q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmb161m093zihb71ejr6q.png" alt="terraform apply" width="389" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So quick! You now have a webserver online. Did you notice how long it took to get the EC2 instance ready? 14 seconds. That's amazing!&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9p08mhjmf6jdgvl2lo6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9p08mhjmf6jdgvl2lo6.png" alt="instance ready" width="594" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How do I know that my webserver is actually working? Let us check some information about the webserver. Run &lt;code&gt;terraform show&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2chmm8y0fx37zeqnb6u4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2chmm8y0fx37zeqnb6u4.png" alt="Information about your instance" width="486" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Did you notice the last entry displayed? That is the public IP address of the instance. Now, let us check the web content. Run &lt;code&gt;curl http://&amp;lt;public_ip&amp;gt;:8080&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fflhl8nhdn7t6h03an4db.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fflhl8nhdn7t6h03an4db.png" alt="webcontent" width="591" height="36"&gt;&lt;/a&gt;&lt;br&gt;
Isn't that beautiful? Why not let us check out our EC2 instance on the AWS Console. Here you go!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5clibfzf7ktvkss8uglk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5clibfzf7ktvkss8uglk.png" alt="EC2 page on console" width="800" height="36"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What about our webpage? Type in your browser &lt;code&gt;http://&amp;lt;public_ip&amp;gt;:8080&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frfen34607ud14r0j7ki9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frfen34607ud14r0j7ki9.png" alt="webpage on browser" width="544" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To clean up the resources and delete everything, run &lt;code&gt;terraform destroy&lt;/code&gt; and enter &lt;code&gt;yes&lt;/code&gt; as a confirmation to destroy the infrastructure. &lt;/p&gt;

&lt;p&gt;Here is the architecture of what we built&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fggrsm5qk05tum5usxybm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fggrsm5qk05tum5usxybm.png" alt="Architecture diagram" width="639" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations! We have deployed our first single web server, tested it and destroyed it. Can we improve on this? A future post will show us how. Feel free to ask questions regarding this post. &lt;/p&gt;

</description>
      <category>terraform</category>
      <category>aws</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Step-by-Step Guide to Setting Up Terraform, AWS CLI, and VS Code</title>
      <dc:creator>frankfolabi</dc:creator>
      <pubDate>Sat, 24 Aug 2024 03:42:51 +0000</pubDate>
      <link>https://dev.to/frankfolabi/step-by-step-guide-to-setting-up-terraform-aws-cli-and-vs-code-21e</link>
      <guid>https://dev.to/frankfolabi/step-by-step-guide-to-setting-up-terraform-aws-cli-and-vs-code-21e</guid>
      <description>&lt;p&gt;You have heard of the benefit of Infrastructure as Code (IaC). You have seen the power, speed, and other beautiful features as well as the benefits of automation in provisioning your resources. You may now wonder, how can I setup my local machine to use this newfound tool and start deploying servers, databases, networking components, storage and the likes. This step-by-step guide would assist you in setting up Terraform, AWS CLI - which is the Command Line Interface to access your Amazon Web Services resource and VS Code - Visual Studio Code, a popular code editor. These tools can be installed on various operating system such as Linux, Mac, and Windows. Let us start with Terraform installation on Windows.&lt;/p&gt;

&lt;h3&gt;
  
  
  Terraform
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to terraform.io&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhovr66w4umcclpesllz3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhovr66w4umcclpesllz3.png" alt="Address bar to show terraform.io" width="255" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on Download Terraform&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifqti8oi981a85d7jefn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifqti8oi981a85d7jefn.png" alt="IDownload Terraform" width="307" height="70"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the section for Windows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flgylkeu5rc1ttk7emw8d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flgylkeu5rc1ttk7emw8d.png" alt="Window section on Terraform page" width="800" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Click on the Download. Check if your computer is AMD64 or 386&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A terraform.exe file would be downloaded in a zip file format that you have to unzip.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqtus4rxchjnf685rw4w5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqtus4rxchjnf685rw4w5.png" alt="ZIpped Terraform" width="291" height="36"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to your downloaded unzipped file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8efkanbhooxcr4jazvn2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8efkanbhooxcr4jazvn2.png" alt="Unzipped Terraform" width="595" height="29"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copy the .exe file to the C drive and place it in a new folder named terraform. &lt;/li&gt;
&lt;li&gt;Search for the Advanced System Settings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1fg5g8as2eo5v3sijpw6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1fg5g8as2eo5v3sijpw6.png" alt="Advanced System Settings" width="324" height="95"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the Environment Variables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqf40fza7l4gnjn5072u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqf40fza7l4gnjn5072u.png" alt="Environment Variables" width="411" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the bottom section named System variables, scroll down to click on Path&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3sbldq7oi4x2xd1yhk24.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3sbldq7oi4x2xd1yhk24.png" alt="Path variable" width="596" height="255"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Click on Edit&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The click on New&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type in the path ex., C:\terraform &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on OK&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To check your installation, you can open your command line and type terraform version. You should see a version installed on the machine. &lt;/p&gt;

&lt;h3&gt;
  
  
  AWS CLI
&lt;/h3&gt;

&lt;p&gt;To efficiently use the AWS CLI to communicate with AWS resources, you will need to sign up for an AWS account.  You can sign up for a free account with your credit card on aws.amazon.com&lt;br&gt;
After registering the account, you will have access to all resources on the AWS console. Best practice requires that you create an IAM user with administrative permissions that can be used subsequently to create other users. &lt;br&gt;
Here are the steps to create an IAM admin user on the AWS Console. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Seach for IAM in the search bar of the console 
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3yu5bfiq8xlzkd36gq8b.png" alt="Search result for IAM" width="341" height="130"&gt;
&lt;/li&gt;
&lt;li&gt;Click on IAM&lt;/li&gt;
&lt;li&gt;In the left pane under Access management, click on Users&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs41aqeeibpob2pq0mead.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs41aqeeibpob2pq0mead.png" alt="Users icon under Access Management" width="158" height="112"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on Create user&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs984bnw746i9ybf00h3o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs984bnw746i9ybf00h3o.png" alt="Create user" width="214" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Type the user name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdion87w71cqgx1w9eq4a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdion87w71cqgx1w9eq4a.png" alt="user name details" width="679" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: Since we will be using the CLI, we left the box unchecked.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on next to set permissions. Best practice is to create a group and attach policies to that group. However, since we are dealing with a user, we will click Attach policies directly. Then click on AdministratorAccess&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1baxopfnsdzmj4i4n9y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1baxopfnsdzmj4i4n9y.png" alt="Admin access policy" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Review the details and click on Create user&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fze16iej8rf3uw12n7w6w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fze16iej8rf3uw12n7w6w.png" alt="Create user button" width="308" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To generate the Access Keys needed for CLI access, click on the newly created terraform-user&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz2na6givrmmemwoylpzb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz2na6givrmmemwoylpzb.png" alt="Newly created user" width="261" height="42"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the Security credentials tab&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F55xzchha67m2uwqywsme.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F55xzchha67m2uwqywsme.png" alt="Security credentials" width="634" height="62"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scroll down to the Access keys section and click on create access key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8sw7bagy5424j43p8v2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8sw7bagy5424j43p8v2.png" alt="create access key" width="800" height="185"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select Command Line Interface for your use case&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2l4lpnl8memrn3vfd64v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2l4lpnl8memrn3vfd64v.png" alt="CLI use case" width="537" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the confirmation then click Next&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fudx1ilpw7wwj03qv4yzb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fudx1ilpw7wwj03qv4yzb.png" alt="Confirmation" width="671" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You may wish to add tags, thereafter, click on Create access key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzl8ggit722twv0yhc9om.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzl8ggit722twv0yhc9om.png" alt="create access keys" width="694" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep your access key safe. You may choose to download the .csv file then click Done&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next let us install the AWS CLI version 2 on our machine.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Go to the AWS documentation page at &lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the installation guide for Windows and follow the installer wizard&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After installation, in your command prompt, you can run the aws --version&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmv9mmp0olr88h9pg2jwk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmv9mmp0olr88h9pg2jwk.png" alt="aws cli version" width="553" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can configure the CLI with the Access key credentials we generated. Run the command aws configure and enter the access key, secret access key,   region and the default output format&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flnags7moivefl4tz6i48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flnags7moivefl4tz6i48.png" alt="aws configure credentials" width="320" height="52"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  VS Code
&lt;/h3&gt;

&lt;p&gt;Now that we have configured our CLI, let us install VS Code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Download Visual Studio Code at &lt;a href="https://code.visualstudio.com/download" rel="noopener noreferrer"&gt;https://code.visualstudio.com/download&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Follow the installer wizard instructions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After installation and launching VS Code, click on Extensions in the left side pane and search for AWS Toolkit&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20rc05v78n30z4gyg6fp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20rc05v78n30z4gyg6fp.png" alt="Install AWS Toolkit" width="328" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the Install button under the AWS Toolkit&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff1mw74yu57k7bopw29va.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff1mw74yu57k7bopw29va.png" alt="Install Toolkit" width="413" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You are now ready to use all these tools in your learning of Terraform. In the next post, we will start deploying infrastructure with Terraform.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is Infrastructure as Code (IaC) and Why It's Transforming DevOps</title>
      <dc:creator>frankfolabi</dc:creator>
      <pubDate>Wed, 21 Aug 2024 18:18:04 +0000</pubDate>
      <link>https://dev.to/frankfolabi/what-is-infrastructure-as-code-iac-and-why-its-transforming-devops-1cbf</link>
      <guid>https://dev.to/frankfolabi/what-is-infrastructure-as-code-iac-and-why-its-transforming-devops-1cbf</guid>
      <description>&lt;p&gt;Infrastructure as Code (IaC) might look like a buzz word in the not so distant past but in today's DevOps world it is gradually becoming a standard. You may likely wonder, what is Infrastructure as Code and why is it transformational in DevOps? Let us take a quick look at DevOps. &lt;/p&gt;

&lt;p&gt;DevOps is a curled from the Development team (Dev) and Operations team (Ops) in software creation. However, DevOps is said to make software delivery more efficient because it is about the people, process, tools and culture. Many companies that have adopted DevOps have reported significant improvement in their software delivery. Four core values have been identified in DevOps: Culture, Automation, Measurement, and Sharing. Infrastructure as Code is one of the numerous automation aspects of DevOps and the idea behind IaC is that you write and execute code to define, deploy, update, and destroy your infrastructure. You can manage everything in code be it servers, databases, networks, documentation and all other essentials. &lt;/p&gt;

&lt;p&gt;Five broad categories of IaC tools are in the use mainly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ad Hoc Scripts&lt;/strong&gt;: You can use your favorite scripting language such as Bash, Ruby, Python to define each step in a code and execute the script. However, the challenge is that you can write the code anyhow you love it, and it may be challenging to maintain a large repository of scripts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Configuration Management Tools&lt;/strong&gt;: Chef, Puppet and Ansible at tools that are designed to install and manage software on existing servers, and they are very efficient with such tasks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Server Templating Tools&lt;/strong&gt;: Docker, Packer and Vagrant can be found in this category. They are useful in creating images of a fully self-container that has the operating system, software, files, dependencies and other relevant details needed. These images can be &lt;em&gt;virtual machine&lt;/em&gt; (VM) or &lt;em&gt;containers&lt;/em&gt; which are light weight and fast.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Orchestration Tools&lt;/strong&gt;: Kubernetes, Docker Swarm, Amazon Elastic Container Services (ECS) can be found in this category. These tools are useful in managing virtual machines and containers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Provisioning Tools&lt;/strong&gt;: Terraform, Pulumi, CloudFormation are typical examples. These tools are used to create servers, networking components, databases and all other aspects of your infrastructures.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Why is Infrastructure as Code Beneficial?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Speed and safety: It is faster than a human clicking all around and safer since the process is automated, consistent and repeatable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Version control: The code can be committed to Git which is easier to revert and debug.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reusable: Modules can be created that can be a basis for other deployments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ease: Clicking around the same thing over and over can be boring but having these as code is just easy.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is evident that infrastructure as code is here to stay. In future posts, we will dive deep into Terraform. Feel free you ask your questions, and I will be ready to give a response as soon as possible. &lt;/p&gt;

</description>
      <category>devops</category>
      <category>terraform</category>
      <category>beginners</category>
      <category>infrastructureascode</category>
    </item>
  </channel>
</rss>
