Skip to content

Instantly share code, notes, and snippets.

@joshghent
Last active December 16, 2025 14:34
Show Gist options
  • Select an option

  • Save joshghent/fa4c701938e7618bd51f89efe602b9d6 to your computer and use it in GitHub Desktop.

Select an option

Save joshghent/fa4c701938e7618bd51f89efe602b9d6 to your computer and use it in GitHub Desktop.
test.tf
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "app" {
ami = "ami-0c55b159cbfafe1f0",
instance_type = "t2.medium"
subnet_id = data.aws_subnet.default.id
vpc_security_group_ids = [
aws_security_group.sg.id,
"sg-12345678"
]
user_data = <<EOF
#!/bin/bash
yum update -y
node app.js &
EOF
tags = {
Name = "production-app"
Env = "prod"
}
}
data "aws_subnet" "default" {
filter {
name = "tag:Name"
values = ["default"]
}
}
resource "aws_security_group" "sg" {
name = "app-sg"
vpc_id = data.aws_vpc.default.id
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
data "aws_vpc" "default" {
default = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment