LAB: Terraform EC2 with `user_data`
๐ฏ Goal Provision an EC2 instance that: Installs Nginx automatically Starts the service Serves a custom web page ๐ All using user_data (bootstrapping) ๐ Project Structure terraform-userdata-lab/ ...

Source: DEV Community
๐ฏ Goal Provision an EC2 instance that: Installs Nginx automatically Starts the service Serves a custom web page ๐ All using user_data (bootstrapping) ๐ Project Structure terraform-userdata-lab/ โโโ main.tf โโโ variables.tf โโโ terraform.tfvars โโโ providers.tf โโโ versions.tf โโโ outputs.tf โโโ user_data.sh.tpl ๐ versions.tf terraform { required_version = ">= 1.5.0" required_providers { aws = { source = "hashicorp/aws" version = "~> 5.0" } } } ๐ providers.tf provider "aws" { region = var.aws_region } ๐ variables.tf variable "aws_region" { type = string description = "AWS region" } variable "instance_type" { type = string description = "EC2 type" } variable "instance_name" { type = string description = "Name of instance" } variable "web_message" { type = string description = "Message shown on web page" } variable "common_tags" { type = map(string) description = "Common tags" } ๐ terraform.tfvars aws_region = "us-east-2" instance_type = "t2.micro" instance_name = "userdata-l