First steps in terraform - AWS Setup

Lecture description
First steps in terraform: learn how to spin up your first instance. First: AWS account setup.
Learn more from the full course
AWS Infrastructure as Code With Terraform [2024 Updates]
Terraform, a popular infrastructure automation tool for DevOps. Terraform with AWS, Packer, Docker, ECS, EKS, Jenkins
12:38:55 of on-demand video • Updated April 2025
Understand, use and apply terraform, including advanced terraform features
Use terraform to provision AWS resources
Prepare for the HashiCorp Terraform Certification with lectures aligned with the exam objectives
Use terraform with Packer to create custom images
Use terraform with AWS ECS, Fargate, and CodePipelines
Be able to apply DevOps techniques using terraform
English [CC]
Narrator: Let's do our first steps in Terraform. Let's start with spinning up an instance on AWS. To do this, you also need an AWS account. So the first step will be to open an AWS account. You can open one for free, and Amazon also has a free tier. So some of the usage, especially when you use the small instances, will be for free. You can actually run a T2 Micro, which is an instance type, for one full month for free within the first year. Then, once you open your account you then can create an IAM admin user. This is the user that we're then going to use in Terraform. Then we are going to create a Terraform file to spin up a T2 Micro instance. So if you open a new account, and you're always going to shut down your instances after you use it, you should not be paying for it. Once this Terraform file is created, we are going to use Terraform apply the command, which is then going to send the instructions to AWS to launch T2 Micro instance. So let's start with opening an AWS account. If you go to aws.amazon.com, then there's a button here. Create a free account, and here if you fill out the details you can create an account, and you see on the right if you open AWS account, it includes 12 month of free tier access, including the use of Amazon EC2, S3, and RDS. You can visit aws.amazon.com/free to see what is included. So here you see Amazon EC2, 750 hours per month of a Linux T2 micro instance. That's the one we are going to use. Make sure that after every lamp, you shut down the instances so that you don't have to pay for them. Once you create your AWS account, you will see a screen like this. First thing we do is to create a new user. So if you type in searches "IAM," manage access to AWS resources, then at the identity and access management page, we can create new users. So if you click on users and then add user you can create a Terraform user. This Terraform user is not going to access the AWS management console. It's only going to access using the API. So the access type is going to be programmatic access and this enables an access key ID and a secret access key, which we will then have to configure within Terraform. Next, we can add the user to a group. So we can create a group. If you don't have an administrative group yet, the group name can be Administrators, or I'm gonna call it Terraform Administrators, because I already have an admin group. And then go and give it administrator access, which is full access to all AWS resources. Then you're gonna click next. You don't need to give it any tags, you're going to review it, everything looks good. And now we can create the user. Now that the user is created, we have an access key ID and a secret access key. We can click on the show, which will show you the secret access key, and this one you'll be able to configure in the next lecture. Let's have another look at EC2. So if you go to compute EC2, then this is the EC2 dashboard. Once you start doing the demos, you will find your EC2 instances here, you launch. You just have to make sure that you are in the correct region. So my labs will launch in Europe, Ireland, EU-west-1. If you're going to launch in a different region, you have to make sure that you change it in the Terraform files before you do Terraform apply, and that you also pick the correct region here. A lot of the first labs will use a default security group, so have a look at your security groups and if you filter on default then you'll see you have three default security groups here because I have three VPCs. One of them will be the default VPC. If this is a new account, you'll only have one security group. You just wanna make sure that you enable inbound rules. For example, in this one that there's an inbound rule for your IP address. So if you go to inbound rules, edit inbound rules, then you can add a rule to allow all the traffic to my IP address. And when choosing my IP address, you'll allow all the access to your IP address. You might have to repeat this if you have a dynamic IP address. In the first demos we are not using security groups yet, so the demos will use the default security group. Once we start talking about VPCs, then we will also use security groups, and then you can define everything in Terraform. So that's it for account setup. In the next lecture, we'll try to launch our first EC2 instance.