diff --git a/main.tf b/main.tf index 86b2e1a..1101154 100644 --- a/main.tf +++ b/main.tf @@ -1,31 +1,15 @@ -provider "aws" { - region = var.aws_region - access_key = var.aws_access_key - secret_key = var.aws_secret_key -} - resource "aws_vpc" "main_vpc" { cidr_block = var.vpc_cidr - tags = { - Name = "main-vpc" - } } resource "aws_internet_gateway" "igw" { vpc_id = aws_vpc.main_vpc.id - tags = { - Name = "main-igw" - } } resource "aws_subnet" "public_subnet" { vpc_id = aws_vpc.main_vpc.id cidr_block = var.public_cidr - availability_zone = "${var.aws_region}a" map_public_ip_on_launch = true - tags = { - Name = "public-subnet" - } } # Create a route table with a route to the internet through the Internet Gateway @@ -43,7 +27,6 @@ resource "aws_route_table_association" "public_rt_association" { route_table_id = aws_route_table.public_rt.id } - resource "tls_private_key" "ssh_key" { algorithm = "RSA" rsa_bits = 4096 @@ -97,6 +80,7 @@ resource "aws_security_group" "allow_ssh_http_https" { } } + data "aws_ami" "latest_ecs" { most_recent = true owners = ["591542846629"] # AWS diff --git a/output.tf b/output.tf index 3c89d36..260ba02 100644 --- a/output.tf +++ b/output.tf @@ -18,3 +18,6 @@ output "ubuntu_instance_public_ip" { value = aws_instance.ubuntu_instance.public_ip } +output "ssh_public_key" { + value = var.SSH_PUBLIC_KEY +} diff --git a/variables.tf b/variables.tf index 1b7d541..44286ed 100644 --- a/variables.tf +++ b/variables.tf @@ -30,22 +30,6 @@ variable "public_cidr" { default = "10.0.1.0/24" } -variable "aws_region" { - description = "Region Preference" - default = "us-west-2" -} - -variable "aws_access_key" { - description = "AWS Access Key" - type = string - sensitive = true -} - -variable "aws_secret_key" { - description = "AWS Secret Key" - type = string - sensitive = true -} variable "name_prefix" { description = "The prefix for all your resources" default = "demostar" @@ -64,5 +48,6 @@ variable "disk_size" { variable "SSH_PUBLIC_KEY" { description = "SSH Public Key to add to .authorized_keys for the 'ubuntu' user" + default = "" }