From 2ccd58cbb2f94e2cb9e4f8d47db695a307b13ff2 Mon Sep 17 00:00:00 2001 From: Anton Livaja Date: Thu, 21 Nov 2024 13:30:57 -0500 Subject: [PATCH] initial draft for workshop --- terraform-workshop/index.md | 92 +++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 terraform-workshop/index.md diff --git a/terraform-workshop/index.md b/terraform-workshop/index.md new file mode 100644 index 0000000..ef577c4 --- /dev/null +++ b/terraform-workshop/index.md @@ -0,0 +1,92 @@ +# Terraform Workshop + + +--- + +## What is Terraform + +IaC (Infrastructure as Code) framework which enables programatic definition, +deployment and management of infrastructure resources for cloud and on-premises +in a declarative manner. It targets all major cloud platforms (GCP, AWS, Azure, DO etc.) + +--- + +## Why do We Need it + +* Standardization of deployment to ensure a consistent state + * Version control + * Deploying an additional clone env for testing + +* Easier auditability to improve quality and security + * Modular - reuse & ease of understanding + * Resource Graph (dependency graph + parallel execution when possible) + * Version control + +* Enables use of hardened deployment pipelines + +* Enables immutable infrastructure + +--- + +## Human-Readible Configuration Language + +* HashiCorp Configuration Language (HCL) or JSON + +``` +provider "aws" { + region = "us-west-2" +} + +resource "aws_instance" "example" { + ami = "ami-0c55b159cbfafe1f0" # Amazon Linux 2 AMI ID + instance_type = "t2.micro" + + tags = { + Name = "HelloWorldEC2Instance" + } +} + +output "instance_public_ip" { + value = aws_instance.example.public_ip +} + +``` + +--- + +## Workflow + +* Write your configuration file + +* Use the the `terraform plan` action to simulate deployment of resources and assess the outcome + +* Use `terraform apply` to actually deploy resources + +--- + +# Exercise + +* Set up local credentials for your cloud platform of choice + +* Write a file that deploys an EC2 instance + +* Use `terraform plan` and `terraform apply` in order to deploy the resource + +* Remove the resource by updating your configuration file and using `terraform plan` and `terraform apply` + +--- + +# Extend Configuration + +* Add a VPC + +* Define security group that limits ingress and egress to port 22 + +* Add SSH key(s) which may connect to the instance + +--- + +# Next Steps + +* ... +