Skip to content

SSH login without private key. Use aws-ec2-ssh (https://github.com/widdix/aws-ec2-ssh) to auto auth through IAM user public key

License

Notifications You must be signed in to change notification settings

matrix0415/terraform-aws-ec2-ssh-auth-iam

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-kks-ec2-ssh-iamauth

Use aws-ec2-ssh (https://github.com/widdix/aws-ec2-ssh) to auto auth through IAM user public key.

Overview

Architecture

  1. Crontab will execute command to sync users from groups every 30 seconds.
  2. When user SSH login, will trigger to get the user public key to authorize.

Pre-requirements

  1. EC2 needs to open egress 80 & 443 port for package installation and AWS IAM access.
  2. This module will disable AWS ec2-instance-connect feature.

Usage

module "ec2_auth" {
  source                      = "git::https://github.com/kkstream/terraform-aws-ec2-ssh-auth-iam"
  ec2_role_id                 = "ec2-role"
  allow_login_iam_group_names = ["Developers"]
}

resource "aws_instance" "instance" {
  ami                         = "ami-0eeb679d57500a06c"
  instance_type               = "m5.large"
  vpc_security_group_ids      = var.security_group_ids
  subnet_id                   = var.subnet_id
  iam_instance_profile        = var.iam_instance_profile_name
  user_data_base64            = module.ec2_auth.ec2_user_data_base64
}

Requirements

Name Version
terraform >= 0.13
aws provider >= 3.20

Inputs

Name Description Type Default Required
ec2_role_id Give the EC2 role ID (role name) for attaching the additional permissions. string no yes
allow_login_iam_group_names Give the IAM group names for allowing group users login list(string) no yes

Outputs

Name Description Type
ec2_user_data (Deprecated) User data for EC2 string
ec2_user_data_base64 (Recommend) User data for EC2 in base64 string

About

SSH login without private key. Use aws-ec2-ssh (https://github.com/widdix/aws-ec2-ssh) to auto auth through IAM user public key

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 62.5%
  • HCL 37.5%