Terraform Course – Automate your AWS cloud infrastructure

    14
    49



    Learn Terraform in this complete course for beginners. Terraform is an open-source infrastructure as code software tool. Learn how it can be utilized to manage and automate your AWS cloud infrastructure. We’ll start off by setting up a free AWS account to play around with and move on to setting up and installing Terraform on a Windows/MAC/Linux machine.

    From there we’ll move on to deploying our first resource through terraform and learning other core concepts. You’ll even get a chance to setup a simple web server in AWS.

    šŸ’» GitHub Repo: https://github.com/Sanjeev-Thiyagarajan/Terraform-Crash-Course

    šŸ”— Download Terraform: https://www.terraform.io/downloads.html

    šŸŽ„ This course was developed by Sanjeev Thiyagarajan. Check out his YouTube channel: https://www.youtube.com/channel/UC2sYgV-NV6S5_-pqLGChoNQ

    ā­ļø Course Contents ā­ļø
    āŒØļø (0:00:00) Intro
    āŒØļø (0:01:54) AWS Setup
    āŒØļø (0:05:59) Windows Setup
    āŒØļø (0:10:04) Mac Setup
    āŒØļø (0:13:11) Linux Install
    āŒØļø (0:17:39) VSCode
    āŒØļø (0:20:51) Terraform Overview
    āŒØļø (0:43:31) Modifying Resources
    āŒØļø (0:50:30) Deleting Resources
    āŒØļø (0:54:55) Referencing Resources
    āŒØļø (1:04:47) Terraform Files
    āŒØļø (1:09:45) Practice Project
    āŒØļø (1:50:32) Terraform State Commands
    āŒØļø (1:54:05) Terraform Output
    āŒØļø (2:00:39) Target Resources
    āŒØļø (2:03:46) Terraform Variables

    Learn to code for free and get a developer job: https://www.freecodecamp.org

    Read hundreds of articles on programming: https://freecodecamp.org/news

    And subscribe for new videos on technology every day: https://youtube.com/subscription_center?add_user=freecodecamp

    source

    Previous articlePipeline-Scripts – Create a parameterized Jenkins job using Pipeline Scripts
    Next articleSap course best module

    49 COMMENTS

    1. Thanks for the instructive video! I know this setup was from 2 years ago but for practice purposes, I went ahead and terraform-applied the same infrastructure resources on my AWS environment. For some reason, the "user_data" did not get run by terraform so I had to re-run the commands later by ssh'ing into the ec2 instance and properly started the apache2 server.

    2. i started getting this error on the subsequent attempts to apply all the config" Error: creating EC2 Instance: UnauthorizedOperation: You are not authorized to perform this operation." Basically it fails creating the EC2 instance, although it worked the first time. Does anyone have any idea?

    3. Q1: Do we have to create separate network interface for each ec2 instance?
      Q2: I thought Security Group and IP addresses are directly assigned to an instance, but it seems you have to assigne private and public IP address to network interface? Can we assign directly these properties to an instance?
      Q3: Why multiple ip address can be assigned to a Network Interface (is it not per ec2-instance). I read in documentation you can assign multiple public ip addresses based on multiple private up address? Does this mean same network interface can be assignened to multiple instances?
      Q4: If above is true how can then we separate Security Group for each instance?

    4. user_data part from 'Practice Project' didn't work for me. I think EC2 don't have apt anymore. Using yum worked tho:
      user_data = <<EOF
      #!/bin/bash
      yum update -y
      yum install -y httpd.x86_64
      systemctl start httpd.service
      systemctl enable httpd.service
      echo "Hello from Terraform deployed website!" > /var/www/html/index.html
      EOF

    5. Great video! Perfect pace too. I followed along and had almost no issues. Since it's a year later, I used Ubuntu 20.04. Seems by default apache2 doesn't listen on 443, so clicking the web link in the AWS console for the EC2 instance doesn't work. Just change https to http and it will show your message.
      Couple notes:
      EOF is End Of File. That <<- syntax is called a "Here File" or "Here Document" which you can search for more info.
      The user_data section already runs as root so you don't need sudo.
      If you use an IntelliJ IDE it provides a lot of convenient auto completion for Terraform files. It helped me avoid the error you got with depends_on by automatically making the value an array.

    6. Starting my Terraform journey. This is a good tutorial, though my SSH via Putty doesn't seem to work. It doesn't accept the key that I made and I can't access the web server in AWS either as I get a connection refused error. I can connect to it via EC2 instance connect though.

      EDIT: Disregard, it worked. Didn't change a thing. PuTTY didn't open the first time, but the second time it did after EC2 instance connect. Still can't access via web browser but I can get on SSH at least.

    7. FYI for anyone who struggled with the user_data not executing… Under `key_name = "main-key"` I added another variable, `user_data = file("userdata.tpl")` then I made a new file called userdata.tpl and pasted all the commands to install apache server.

    8. Finally, a tutorial that actually explains to beginners. Some other videos claim to be for beginners and then 5mins into the video, they start pulling steps put of thin air!
      Thank you so much for this. This is so simplified that I found this very very helpful!