- Objective: to setup new vpc in aws
What is terraform?
- If you have to set up same infrastructure for like 50 times, Terraform provides an easy way to get all your things done in one go!. All you have to do is code once and reuse it according to the requirements.
What is VPC..
- a virtual private cloud where you can run your workloads in isolated format.
- We create isolation based on IP addresses. We're using 172.31.0.0/16 range.
What does the code do..
- creates vpc in frankfurt.
- creates 3 public, 3 private subnets.
- public: services in this subnet can talk to internet by default.
- private: services can't talk to internet by default and internet isn't aware of their existence. like a LAN setup.
- For private to talk to internet we use NAT gateway. NAT allows private subnet services to talk to internet via itself, but interent can't talk to private services.
- Internet gateway,It is like Translator between two different networks.
- Route tables..It has rules telling which subnet can talk to whom.
How to use code?