Using Terraform to set up ec2 instances for data science projects.
By Anak Wannaphaschaiyong
Take Away
- you will learn how to automate ec2 setup using terraform that is suited for data science project.
Tools
- EC2
- Terraform
Requirements
Knowledge Requirements
- understand basic of how to create terraform project
- understand basic of how to set up ec2 instances
System Requirements
-
WSL/Ubuntu
- I have only tested this in WSL
-
install all dependencies of cuda
- for list of software requirements, see
-
optional
- Docker # References
-
Terraform AWS documentation
-
pytorch docker image
Code
AWS
- export the following environment variables including
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_DEFAULT_REGION
Terraform
- create terraform project
- In the project, create main.tf and copy&paste the following code
resource "aws_instance" "web" {
ami = "ami-08962a4068733a2b6"
instance_type = "p3.8xlarge"
cpu_core_count = 16
cpu_threads_per_core = 2
tags = {
Name = "HelloWorld"
}
}
- now you have ec2 running with