Add SSH_PUBLIC_KEY variable
This commit is contained in:
parent
92d1af3fb7
commit
b3ab3e7c33
18
main.tf
18
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" {
|
resource "aws_vpc" "main_vpc" {
|
||||||
cidr_block = var.vpc_cidr
|
cidr_block = var.vpc_cidr
|
||||||
tags = {
|
|
||||||
Name = "main-vpc"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_internet_gateway" "igw" {
|
resource "aws_internet_gateway" "igw" {
|
||||||
vpc_id = aws_vpc.main_vpc.id
|
vpc_id = aws_vpc.main_vpc.id
|
||||||
tags = {
|
|
||||||
Name = "main-igw"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_subnet" "public_subnet" {
|
resource "aws_subnet" "public_subnet" {
|
||||||
vpc_id = aws_vpc.main_vpc.id
|
vpc_id = aws_vpc.main_vpc.id
|
||||||
cidr_block = var.public_cidr
|
cidr_block = var.public_cidr
|
||||||
availability_zone = "${var.aws_region}a"
|
|
||||||
map_public_ip_on_launch = true
|
map_public_ip_on_launch = true
|
||||||
tags = {
|
|
||||||
Name = "public-subnet"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a route table with a route to the internet through the Internet Gateway
|
# 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
|
route_table_id = aws_route_table.public_rt.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resource "tls_private_key" "ssh_key" {
|
resource "tls_private_key" "ssh_key" {
|
||||||
algorithm = "RSA"
|
algorithm = "RSA"
|
||||||
rsa_bits = 4096
|
rsa_bits = 4096
|
||||||
|
@ -97,6 +80,7 @@ resource "aws_security_group" "allow_ssh_http_https" {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data "aws_ami" "latest_ecs" {
|
data "aws_ami" "latest_ecs" {
|
||||||
most_recent = true
|
most_recent = true
|
||||||
owners = ["591542846629"] # AWS
|
owners = ["591542846629"] # AWS
|
||||||
|
|
|
@ -18,3 +18,6 @@ output "ubuntu_instance_public_ip" {
|
||||||
value = aws_instance.ubuntu_instance.public_ip
|
value = aws_instance.ubuntu_instance.public_ip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "ssh_public_key" {
|
||||||
|
value = var.SSH_PUBLIC_KEY
|
||||||
|
}
|
||||||
|
|
17
variables.tf
17
variables.tf
|
@ -30,22 +30,6 @@ variable "public_cidr" {
|
||||||
default = "10.0.1.0/24"
|
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" {
|
variable "name_prefix" {
|
||||||
description = "The prefix for all your resources"
|
description = "The prefix for all your resources"
|
||||||
default = "demostar"
|
default = "demostar"
|
||||||
|
@ -64,5 +48,6 @@ variable "disk_size" {
|
||||||
|
|
||||||
variable "SSH_PUBLIC_KEY" {
|
variable "SSH_PUBLIC_KEY" {
|
||||||
description = "SSH Public Key to add to .authorized_keys for the 'ubuntu' user"
|
description = "SSH Public Key to add to .authorized_keys for the 'ubuntu' user"
|
||||||
|
default = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue