Skip to content

Commit

Permalink
feat: add ssh key pair module
Browse files Browse the repository at this point in the history
Fixes issue #12
  • Loading branch information
sydrawat01 committed Oct 21, 2023
1 parent 04413f4 commit 5ac8eab
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/ssh/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "aws_key_pair" "jenkins_key" {
key_name = "ec2_key"
public_key = file("~/.ssh/${var.ssh_key_file}")
}
1 change: 1 addition & 0 deletions modules/ssh/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
variable "ssh_key_file" {}
1 change: 1 addition & 0 deletions root/example.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ root_account_ids = []
ami_prefix = ""
instance_type = ""
domain_name = ""
ssh_key_file = ""
5 changes: 5 additions & 0 deletions root/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ module "ec2" {
igw_id = module.vpc.igw_id
vpc_id = module.vpc.vpc_id
}

module "ssh" {
source = "../modules/ssh"
ssh_key_file = var.ssh_key_file
}
5 changes: 5 additions & 0 deletions root/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ variable "domain_name" {
default = "domain.tld"
}

variable "ssh_key_file" {
description = "ssh-keygen generated public RSA key to SSH into an EC2 instance"
type = string
default = "ec2_ssh_key.pub"
}

# variable "profile" {
# description = "AWS profile"
Expand Down

0 comments on commit 5ac8eab

Please sign in to comment.