provider "aws" { profile = "default" region = "us-west-1" } resource "aws_key_pair" "freebsd" { key_name = "freebsd" public_key = file("key.pub") } resource "aws_security_group" "freebsd" { name = "freebsd-security-group" description = "Allow SSH traffic" ingress { description = "SSH" 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"] } tags = { Name = "terraform" } } resource "aws_instance" "freebsd" { key_name = aws_key_pair.freebsd.key_name ami = "ami-060887cf54a9f55f0" instance_type = "t3.micro" credit_specification { cpu_credits = "standard" } tags = { Name = "freebsd" } vpc_security_group_ids = [ aws_security_group.freebsd.id ] connection { type = "ssh" user = "freebsd" private_key = file("key") host = self.public_ip } ebs_block_device { device_name = "/dev/sda1" volume_type = "gp2" volume_size = 30 } } resource "aws_eip" "freebsd" { vpc = true instance = aws_instance.freebsd.id }