Provisioning AWS Resources Using Terraform

Provisioning AWS Resources Using Terraform
Provisioning AWS Resources Using Terraform

CLOUD LABS



Provisioning AWS Resources Using Terraform

In this Cloud Lab, you’ll learn to provision AWS resources, including an S3 bucket, an EC2 instance, and a Lambda function, using Terraform.

8 Tasks

beginner

1hr 30m

Certificate of Completion

Desktop OnlyDevice is not compatible.
No Setup Required
Amazon Web Services

Learning Objectives

A solid understanding of Terraform fundamentals
Hands-on experience deploying web applications on Amazon EC2 instances using Terraform
Hands-on experience provisioning AWS infrastructure using Terraform
An understanding of Terraform blocks and its application to configure AWS resources

Technologies
Lambda logoLambda
Terraform logoTerraform
S3 logoS3
EC2 logoEC2
Cloud Lab Overview

Terraform is a tool for provisioning Infrastructure as Code (Iac). It can provision infrastructure on your machine or any cloud provider and automatically deploy the infrastructure from code without any manual intervention.

In this Cloud Lab, you’ll start by learning about Terraform. You’ll provision an infrastructure locally using Terraform and will learn about the Terraform code blocks. You’ll also create an S3 bucket on AWS, allowing public access to the bucket contents, and upload an object to the S3 bucket. Then, you’ll create a Lambda function to access the bucket’s contents using Terraform. You’ll create an IAM role for the Lambda function as well. Lastly, you’ll create a security group and set up a React application on the EC2 instance through Terraform.

By the end of this Cloud Lab, you’ll be able to provision infrastructure on AWS using Terraform. These skills are essential for mastering IaC and transforming manual processes into efficient, version-controlled infrastructures.

The following is the high-level architecture diagram of the infrastructure that you’ll create in this Cloud Lab:

Diagram illustrating the use of Terraform for automating AWS resource provisioning
Diagram illustrating the use of Terraform for automating AWS resource provisioning

Why infrastructure as code matters on AWS

Manually creating cloud resources through a console doesn’t scale. It’s slow, error-prone, and nearly impossible to reproduce reliably. Infrastructure as code (IaC) solves this by letting you define cloud resources in files that can be versioned, reviewed, and applied consistently.

Terraform is widely used for IaC because it’s declarative: you describe the desired end state, and Terraform figures out how to reach it. That shift from “clicks” to “code” is what enables teams to treat infrastructure with the same discipline as application development.

How Terraform works at a high level

A typical Terraform workflow has a few core concepts:

  • Providers: Providers (such as AWS) tell Terraform how to interact with a platform’s APIs and manage resources.

  • Resources: Resources define what you want to create, networks, compute, storage, permissions, and more.

  • State: State tracks what Terraform believes exists in the real world. It’s how Terraform knows what to create, update, or destroy when you apply changes.

  • Plan and apply: terraform plan shows you what will change before anything happens. terraform apply executes those changes. This two-step process is a major safety feature.

What Terraform is commonly used for on AWS

Terraform is often used to provision:

  • VPCs, subnets, and networking components

  • Compute resources (instances, autoscaling, managed services)

  • Storage and databases

  • IAM roles and policies

  • Supporting services for platforms and pipelines

As projects grow, teams typically add modules, remote state backends, and CI/CD pipelines to manage Terraform at scale.

Common Terraform design decisions to get right early

A few choices make a big difference in long-term maintainability:

  • State management: Remote state with locking is safer than local state.

  • Modularity: Reusable modules reduce duplication and errors.

  • Separation of concerns: Many teams separate foundational infrastructure from application-specific resources.

  • Variables and outputs: Make configurations flexible without hardcoding values.

  • Permissions: Run Terraform with least-privilege credentials whenever possible.

When Terraform is (and isn’t) the right tool

Terraform is a great fit when you need repeatable, auditable infrastructure across environments. It’s less ideal for one-off experiments or extremely dynamic resources that change outside Terraform’s control, unless you invest in robust state management and workflows.

The goal isn’t to automate everything immediately, it’s to make infrastructure predictable.

Cloud Lab Tasks
1.Introduction
Getting Started
2.Introduction to Terraform
Terraform Workflow
Terraform in Action
Blocks and Arguments
3.Provision an Infrastructure
Provision an S3 Bucket
Provision a Lambda Function
Provision an EC2 Instance
Conclusion
Labs Rules Apply
Stay within resource usage requirements.
Do not engage in cryptocurrency mining.
Do not engage in or encourage activity that is illegal.

Relevant Courses

Use the following content to review prerequisites or explore specific concepts in detail.

Frequently Asked Questions

What does the provisioner do in Terraform?

A provisioner in Terraform runs scripts or commands on a machine (both on local and remote machines) during resource creation or destruction. They typically perform tasks that cannot be achieved through Terraform’s declarative language, such as installing software or configuring services. Use provisioners sparingly, as they can add complexity and aren’t always repeatable.

Is Terraform a provisioning tool?

Terraform is an infrastructure-as-code (IaC) tool for defining and managing infrastructure. While it can run provisioners for configuration tasks, its main role is managing the infrastructure life cycle.

How many resources will Terraform provision concurrently during a Terraform apply?

By default, Terraform provisions up to 10 resources concurrently. You can adjust this using the -parallelism flag, but note that Terraform Enterprise allocates 512 MB of memory for each run by default.

What is Terraform?

Terraform is a tool that lets you define cloud infrastructure in code. You write configuration files that describe the resources you want, and Terraform creates and manages them for you.

Why use Terraform instead of AWS Management Console?

The console is fine for learning or quick experiments, but it doesn’t scale. Terraform gives you version control, repeatability, peer review, and safer changes through planning—all of which are critical for real teams.

What is Terraform state, and why is it important?

State is Terraform’s record of what resources exist. Without it, Terraform can’t safely determine what needs to change. Properly protecting and managing the state is one of the most important parts of using Terraform effectively.

Do I need to know programming to use Terraform?

Not really. Terraform uses a declarative configuration language, not a general-purpose programming language. You don’t write loops and logic the same way you would in code—you describe desired outcomes.

Can Terraform manage existing AWS resources?

Yes, but it requires importing those resources into Terraform state. This can be powerful, but it also requires care to avoid drifting configurations or unintended changes.

What are Terraform modules, and why use them?

Modules are reusable Terraform configurations. They help teams standardize infrastructure patterns and reduce duplication across environments.

Hear what others have to say
Join 1.4 million developers working at companies like