Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

Terraform - AWS: EC2

Back


EC2 instance with Public IP


Nginx Web Server

user_data = templatefile("${path.module}/templates/script.tpl", {
    "bucketname" = var.bucket_name
})
apt update
apt install -y nginx aws-cli

rm /var/www/html/index # remove default file
aws s3 sync s3://${bucket_name} /var/www/html/

Legacy: Can use provisioner

https://developer.hashicorp.com/terraform/language/resources/provisioners/syntax


EC2 Template