From 48ae811e21bd8f210f1f625756accd014ceeff3d Mon Sep 17 00:00:00 2001 From: Brian Manifold Date: Tue, 30 Jan 2024 11:59:54 -0500 Subject: [PATCH] Add SSH public key to AWS Terraform (#3439) Why: * The SSH key used for the EC2 hosts in AWS was created outside of the terraform in the mono repo. Now that the previous AWS infra has been torn down, the SSH key needed to be recreated. --- terraform/environments/staging/aws.tf | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/terraform/environments/staging/aws.tf b/terraform/environments/staging/aws.tf index 0ac229934..75943aab4 100644 --- a/terraform/environments/staging/aws.tf +++ b/terraform/environments/staging/aws.tf @@ -68,7 +68,7 @@ module "aws_bastion" { associate_public_ip_address = true instance_type = "t3.micro" - key_name = local.ssh_keypair_name + key_name = aws_key_pair.staging.id vpc_security_group_ids = [ module.sg_allow_all_egress.security_group_id, module.sg_allow_ssh_ingress.security_group_id @@ -86,7 +86,7 @@ module "aws_nat" { associate_public_ip_address = true instance_type = "t3.micro" - key_name = local.ssh_keypair_name + key_name = aws_key_pair.staging.id subnet_id = element(module.vpc.public_subnets, 0) vpc_security_group_ids = [ @@ -105,7 +105,7 @@ module "aws_httpbin" { associate_public_ip_address = false instance_type = "t3.micro" - key_name = local.ssh_keypair_name + key_name = aws_key_pair.staging.id subnet_id = element(module.vpc.private_subnets, 0) private_ip = cidrhost(element(module.vpc.private_subnets_cidr_blocks, 0), 100) @@ -125,7 +125,7 @@ module "aws_iperf" { associate_public_ip_address = false instance_type = "t3.micro" - key_name = local.ssh_keypair_name + key_name = aws_key_pair.staging.id subnet_id = element(module.vpc.private_subnets, 0) private_ip = cidrhost(element(module.vpc.private_subnets_cidr_blocks, 0), 101) @@ -145,7 +145,7 @@ module "aws_gateway" { associate_public_ip_address = false instance_type = "t3.micro" - key_name = local.ssh_keypair_name + key_name = aws_key_pair.staging.id subnet_id = element(module.vpc.private_subnets, 0) private_ip = cidrhost(element(module.vpc.private_subnets_cidr_blocks, 0), 50) @@ -176,7 +176,7 @@ module "aws_coredns" { associate_public_ip_address = false instance_type = "t3.micro" - key_name = local.ssh_keypair_name + key_name = aws_key_pair.staging.id subnet_id = element(module.vpc.private_subnets, 0) private_ip = cidrhost(element(module.vpc.private_subnets_cidr_blocks, 0), 10) @@ -267,3 +267,14 @@ module "sg_allow_ssh_ingress" { } ] } + +################################################################################ +# SSH Keys +################################################################################ + +resource "aws_key_pair" "staging" { + key_name = "fz-staging" + public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBI0vUtLcJqkqIK7xRgfu68fLnP+x7r+W4Bs2bCUxq8F fz-staging-aws" + + tags = local.tags +}