## Infrastructure as Code
---
## Tony Lomax
FAC 17 (Nov 2019)➡️
Freelance until Sep 2020 ➡️
Heka until March 2022 ➡️
Unmind June 2023 ➡️
TravelPerk Oct 2023 ⭐️
(AWS Certified Developer 2023 🤓)
---
## Recap

---
Why am I doing this?
🤔 💡 🏗
---
## What is IAC?
"The practice of managing and provisioning computing infrastructure through machine-readable definition files, rather than through physical hardware configuration or interactive configuration tools.
It uses code to automate the setup and maintenance of infrastructure, ensuring consistency, repeatability, and scalability in IT environments." - ChatGPT
---
## What is Terraform?

(HCL - Hashicorp Configuration Language)
---
What is AWS CDK
```
import * as cdk from 'aws-cdk-lib';
import { aws_s3 as s3 } from 'aws-cdk-lib';
export class S3Stack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
new s3.Bucket(this, 'todo_aws_s3_bucket', {
versioned: true
});
}
}
```
---
## Which one should you use?
---
## You're going to decide
---
Terraform Cons
1. HCL Syntax (Declarative syntax not imperative)
2. State Management
3. Limited Abstraction
---
Terraform Pros
1. Multi-Cloud Support
2. Large Community and Ecosystem
3. Immutable Infrastructure
---
AWS CDK Pros
1. Familiar Programming Languages
2. Higher-Level Abstraction
3. Tight Integration with AWS
---
AWS CDK Cons:
1. Tight Integration with AWS
2. Limited Language Support
3. Learning Curve
---
## The Plan

---
## ToDo
- Create a docker image
- Upload it to Elastic Container Repository
- Create a new task in ECS
- Create a loadbalancer
- Point the loadbalencer to the ECS
- Create some target groups and security groups
- Celebrate 🎊
---
That's a lot...
---
Some gimmes
1. I'm going to give you the code that you're going to use for your server (your docker image)
3. I'm going to explain more about how the different resources work.
---
## Things you'll learn
- Hosting a docker image in ECR
- Setting up a task in ECS
- Setting up a load balancer to handle our requests
- How to do all of that - in IAC
---
## Timetable
9:30 - 10:00(ish) - Intro
10:00 - 10:30(ish) - Groups
10:30 - 11:15 - Run through of the different resources
11:15 - 12:00 - Decide on approach/plan/pick tools/build
12:00 - 12:45 - Lunch
12:45 - 15:30 - Build
15:30 - 16:00 - Show and tell/Wrap up/Questions
---
## Resources you'll need
1. Application Load Balancer
2. Target Group/s
3. Security Group/s
4. Elastic Container Repository (docker image lives)
5. Elastic Container Service (code actually runs)
5a. Cluster x 1
5b. Service x 1
5c. Task x 1
5c. Task Definition x 1
NB: Delete everything at the end of the day!
{"title":"Infrastructure as Code","description":"FAC 17 (Nov 2019)➡️Freelance until Sep 2020 ➡️Heka until March 2022 ➡️Unmind June 2023 ➡️TravelPerk Oct 2023 ⭐️","contributors":"[{\"id\":\"5da6f9cf-649f-4aef-9a8d-c3c402e0a647\",\"add\":4724,\"del\":1615}]"}