Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
014c776
04_04 solutions
samuelson Sep 7, 2022
c51a2ba
Update NOTICE
smoser-LiL Oct 4, 2022
86efb79
Update README.md
cmosier-LiL Oct 22, 2022
a7a48df
Update NOTICE
smoser-LiL Jul 19, 2023
7401493
Fix issue with 04_04 solution
samuelson Aug 11, 2023
59b4f9e
Initial Commit
bsdeol Sep 9, 2025
7910c1b
Update main.tf
bsdeol Sep 9, 2025
ed67728
changed web to blob in outputs.tf
bsdeol Sep 9, 2025
aaa50e6
Update outputs.tf
bsdeol Sep 9, 2025
00e16b7
created security grouip
bsdeol Sep 10, 2025
34e9c0a
fixed a typo
bsdeol Sep 10, 2025
19c6e5b
fixed a typo
bsdeol Sep 10, 2025
4f89472
output public ip
bsdeol Sep 10, 2025
a7762a0
used module for security group
bsdeol Sep 10, 2025
81304f0
fixed a typo
bsdeol Sep 10, 2025
c6d9e67
fixed a typo
bsdeol Sep 10, 2025
9ce91bc
commented out the smanually created security group and rules
bsdeol Sep 10, 2025
98b6d14
removed the commented block in main.tf
bsdeol Sep 10, 2025
1b02b7b
Create new dev VPC using module
bsdeol Sep 10, 2025
8dc7813
added LB
bsdeol Sep 10, 2025
7a979a7
fixed quotes around HTTP
bsdeol Sep 10, 2025
f85a85f
changed braces
bsdeol Sep 10, 2025
a15c270
fixed alb
bsdeol Sep 10, 2025
54b376f
added [] for security groups
bsdeol Sep 10, 2025
6b43257
fixed on 11:13
bsdeol Sep 10, 2025
2e75772
fixed 1117
bsdeol Sep 10, 2025
9b7df6a
added version
bsdeol Sep 10, 2025
98c4ad4
auto scalling group
bsdeol Sep 10, 2025
07f07ab
fixed module typo
bsdeol Sep 10, 2025
57a598b
version
bsdeol Sep 10, 2025
86f2048
removed alb target
bsdeol Sep 10, 2025
9f10057
security_groups
bsdeol Sep 10, 2025
e5725d9
removed outputs
bsdeol Sep 10, 2025
441ae04
update autoscaling version
bsdeol Sep 10, 2025
fbf4ad7
autoscaling_group_target_group_arns
bsdeol Sep 10, 2025
1965e84
version 8.0
bsdeol Sep 10, 2025
eb93736
6.0
bsdeol Sep 10, 2025
c6180e8
removed "autoscaling_group"
bsdeol Sep 10, 2025
6853ea0
version 6.5.2
bsdeol Sep 10, 2025
367c583
version = "~> 9.0"
bsdeol Sep 10, 2025
69ae0d0
commented line 46
bsdeol Sep 10, 2025
865eb9e
attaching asg to alb
bsdeol Sep 10, 2025
1d460d9
target groups
bsdeol Sep 10, 2025
53ad789
commented autoscaling group
bsdeol Sep 10, 2025
93264b9
commented asg
bsdeol Sep 10, 2025
5ee88c2
update blog_alb
bsdeol Sep 10, 2025
e2b674f
copied from 04_04
bsdeol Sep 10, 2025
51bc56d
added varirales to variables.tf from 04_04
bsdeol Sep 10, 2025
1842eb7
reverted 04_04
bsdeol Sep 10, 2025
4794962
deleted main, variable and output
bsdeol Sep 10, 2025
c419ef4
added main outputs and variables for 04_04
bsdeol Sep 10, 2025
c6c37c5
changed versions
bsdeol Sep 10, 2025
6105854
9.0.1
bsdeol Sep 10, 2025
bcb57e5
changed target_groups
bsdeol Sep 10, 2025
8a2e0cf
added traffic_source_attachement
bsdeol Sep 10, 2025
e2dc800
added url to outputs
bsdeol Sep 10, 2025
a026350
lb_dns_name
bsdeol Sep 10, 2025
3242658
used variables
bsdeol Sep 10, 2025
ee1fd37
typo
bsdeol Sep 10, 2025
177930e
quotes
bsdeol Sep 10, 2025
918a4bc
typo in environment
bsdeol Sep 10, 2025
4c7701f
modulerized
bsdeol Sep 10, 2025
13a5742
defined dev env.
bsdeol Sep 11, 2025
edfbb37
typo
bsdeol Sep 11, 2025
90147f3
defined qa environment
bsdeol Sep 11, 2025
ee08d44
commit
bsdeol Sep 11, 2025
21286c6
coomit
bsdeol Sep 11, 2025
df4d1bf
commit
bsdeol Sep 11, 2025
40c2c42
commit again
bsdeol Sep 11, 2025
7f30657
change environment_url in outputs
bsdeol Sep 11, 2025
bcce467
commit
bsdeol Sep 11, 2025
5ae14fc
added output to dev
bsdeol Sep 11, 2025
03079ea
added target_group_name
bsdeol Sep 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
Copyright 2022 LinkedIn Corporation
Copyright 2023 LinkedIn Corporation
All Rights Reserved.

Licensed under the LinkedIn Learning Exercise File License (the "License").
See LICENSE in the project root for license information.

ATTRIBUTIONS:
[PLEASE PROVIDE ATTRIBUTIONS OR DELETE THIS AND THE ABOVE LINE “ATTRIBUTIONS”]

Please note, this project may automatically load third party code from external
repositories (for example, NPM modules, Composer packages, or other dependencies).
If so, such third party code may be subject to other license terms than as set
Expand Down
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Learning Terraform
This is the repository for the LinkedIn Learning course `Learning Terraform`. The full course is available from [LinkedIn Learning][lil-course-url].
This is the repository for the LinkedIn Learning course Learning Terraform. The full course is available from [LinkedIn Learning][lil-course-url].

![Learning Terraform][lil-thumbnail-url]

Terraform is a DevOps tool for declarative infrastructure—infrastructure as code. It simplifies and accelerates the configuration of cloud-based environments. In this course, instructor Josh Samuelson shows how to use Terraform to configure infrastructure and manage resources with Amazon Web Services (AWS). After demonstrating how to set up AWS for Terraform, Josh covers how Terraform manages your infrastructure, as well as how to use core Terraform commands. He also delves into more advanced topics, including how to leverage code modules from the Terraform registry and how to create your own modules. Upon wrapping up this course, you'll have the knowledge you need to efficiently define and manage infrastructure with this powerful tool.

_See the readme file in the main branch for updated instructions and information._
## Instructions
Expand All @@ -10,8 +14,15 @@ The branches are structured to correspond to the videos in the course. The namin

The `main` branch contains the starting code for the course and the `final` branch contains the completed code.

[0]: # (Replace these placeholder URLs with actual course URLs)
### Instructor

Josh Samuelson

DevOps Engineer



[lil-course-url]: https://www.linkedin.com/learning/
[lil-thumbnail-url]: http://
Check out my other courses on [LinkedIn Learning](https://www.linkedin.com/learning/instructors/josh-samuelson).

[lil-course-url]: https://www.linkedin.com/learning/learning-terraform-15575129?dApp=59033956
[lil-thumbnail-url]: https://cdn.lynda.com/course/3087701/3087701-1666200696363-16x9.jpg
3 changes: 3 additions & 0 deletions dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module "dev" {
source = "../modules/blog"
}
7 changes: 7 additions & 0 deletions dev/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "env_url" {
value = module.dev.environment_url
}

output "target_grp_name" {
value = module.dev.target_group_name
}
1 change: 1 addition & 0 deletions providers.tf → dev/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.0"
}
}
}
Expand Down
24 changes: 0 additions & 24 deletions main.tf

This file was deleted.

100 changes: 100 additions & 0 deletions modules/blog/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
data "aws_ami" "app_ami" {
most_recent = true

filter {
name = "name"
values = [var.ami_filter.name]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}

owners = [var.ami_filter.owner] # Bitnami
}


module "blog_vpc" {
source = "terraform-aws-modules/vpc/aws"

name = "${var.environment.name}-blog-vpc"
cidr = "${var.environment.network_prefix}.0.0/16"

azs = ["us-west-2a","us-west-2b","us-west-2c"]
public_subnets = ["${var.environment.network_prefix}.101.0/24", "${var.environment.network_prefix}.102.0/24", "${var.environment.network_prefix}.103.0/24"]


tags = {
Terraform = "true"
Environment = var.environment.name
}
}


module "blog_autoscaling" {
source = "terraform-aws-modules/autoscaling/aws"
version = "9.0.1"

name = "${var.environment.name}-blog-asg"

min_size = var.asg_min
max_size = var.asg_max
vpc_zone_identifier = module.blog_vpc.public_subnets

traffic_source_attachments = {
alb = {
traffic_source_identifier = module.blog_alb.target_group_arns[0]
}
}

security_groups = [module.blog_sg.security_group_id]
instance_type = var.instance_type
image_id = data.aws_ami.app_ami.id
}

module "blog_alb" {
source = "terraform-aws-modules/alb/aws"
version = "~> 6.0"

name = "${var.environment.name}-blog-alb"

load_balancer_type = "application"

vpc_id = module.blog_vpc.vpc_id
subnets = module.blog_vpc.public_subnets
security_groups = [module.blog_sg.security_group_id]

target_groups = [
{
name_prefix = "blog-"
backend_protocol = "HTTP"
backend_port = 80
target_type = "instance"
}
]

http_tcp_listeners = [
{
port = 80
protocol = "HTTP"
target_group_index = 0
}
]

tags = {
Environment = var.environment.name
}
}

module "blog_sg" {
source = "terraform-aws-modules/security-group/aws"
version = "4.13.0"

vpc_id = module.blog_vpc.vpc_id
name = "${var.environment.name}-blog-sg"
ingress_rules = ["https-443-tcp","http-80-tcp"]
ingress_cidr_blocks = ["0.0.0.0/0"]
egress_rules = ["all-all"]
egress_cidr_blocks = ["0.0.0.0/0"]
}
7 changes: 7 additions & 0 deletions modules/blog/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "environment_url" {
value = module.blog_alb.lb_dns_name
}

output "target_group_name" {
value = module.blog_alb.target_group_names
}
41 changes: 41 additions & 0 deletions modules/blog/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
variable "instance_type" {
description = "Type of EC2 instance to provision"
default = "t3.nano"
}

variable "ami_filter" {
description = "Name filter and owner for AMI"

type = object ({
name = string
owner = string
})

default = {
name = "bitnami-tomcat-*-x86_64-hvm-ebs-nami"
owner = "979382823631" # Bitnami
}
}

variable "environment" {
description = "Deployment environment"

type = object ({
name = string
network_prefix = string
})
default = {
name = "dev"
network_prefix = "10.0"
}
}

variable "asg_min" {
description = "Minimum instance count for the ASG"
default = 1
}

variable "asg_max" {
description = "Maximum instance count for the ASG"
default = 2
}
7 changes: 0 additions & 7 deletions outputs.tf

This file was deleted.

12 changes: 12 additions & 0 deletions qa/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module "qa" {
source = "../modules/blog"

environment = {
name = "qa"
network_prefix = "10.1"
}

asg_min = 1
asg_max = 1

}
7 changes: 7 additions & 0 deletions qa/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "environment_url" {
value = module.qa.environment_url
}

output "env_url" {
value = module.qa.environment_url
}
12 changes: 12 additions & 0 deletions qa/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.0"
}
}
}

provider "aws" {
region = "us-west-2"
}
4 changes: 0 additions & 4 deletions variables.tf

This file was deleted.