EC2 AWS Terraform
Using existing ssh key, VPC and Sec Group
Terraform
// Provider configuration
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
provider "aws" {
profile = "default"
region = "eu-west-1"
}
resource "aws_instance" "example" {
ami = "ami-06d9xxxxxxxx44c133"
instance_type = "t3.nano"
subnet_id = "subnet-3dxxxxxx8"
# ssh 22 all example
vpc_security_group_ids = ["sg-08fxxxxxxxxxxx9dc6"]
associate_public_ip_address = true
ebs_optimized = true
key_name = "your-aws-generated-ssh-name"
# Volume Size
root_block_device {
volume_size = 30
}
tags = {
Name = "example"
}
}