Skip to content

squareops/terraform-aws-keypair

Repository files navigation

AWS EC2 Keypair

squareops_avatar

SquareOps Technologies Your DevOps Partner for Accelerating cloud journey.


This module is a reusable Terraform module that simplifies the creation and management of an EC2 key pair on AWS. This module creates an EC2 key pair and securely stores the private key in the AWS Systems Manager Parameter Store (SSM). The module also returns the key pair name and the SSM parameter ARN for later use in other resources, making it easy to reference the key pair in other parts of your infrastructure. Using this module can help you save time and effort in managing your key pairs while ensuring security and compliance in your AWS environment.

Usage Example

module "key_pair" {
  source = "squareops/keypair/aws"
  key_name           = "example-key"
  environment        = "production"
  ssm_parameter_path = "production-example-key"
}

Refer this for more examples.

Retrieve Private Key

To Retrieve the Private key from SSM:

aws ssm get-parameter --name "<ssm_parameter_path>" --region "<region>" --query Parameter.Value --output text

Additionally, to save the private key to a file:

aws ssm get-parameter --name "<ssm_parameter_path>" --region "<region>" --with-decryption --query Parameter.Value --output text > keypair.pem

IAM Permission

The required IAM permissions to create resources from this module can be found here

Requirements

Name Version
terraform >= 1.0
aws >= 4.21
tls >= 3.4

Providers

Name Version
aws >= 4.21

Modules

Name Source Version
key_pair terraform-aws-modules/key-pair/aws 2.0.0

Resources

Name Type
aws_ssm_parameter.ssm_ec2_keypair resource

Inputs

Name Description Type Default Required
environment Specifies the identifier for the environment where the key pair will be used. string "" no
key_name Specifies the name to be assigned to the key pair that will be generated. string "" no
ssm_parameter_path Specifies the SSM parameter name that will be used to store the generated key pair. string "/example/ssm" no

Outputs

Name Description
key_pair_name The name of the key pair generated for the EC2 instance.
ssm_parameter_arn The Amazon Resource Name (ARN) of the SSM parameter used to store the EC2 instance key pair.

Contribution & Issue Reporting

To report an issue with a project:

  1. Check the repository's issue tracker on GitHub
  2. Search to see if the issue has already been reported
  3. If you can't find an answer to your question in the documentation or issue tracker, you can ask a question by creating a new issue. Make sure to provide enough context and details .

License

Apache License, Version 2.0, January 2004 (http://www.apache.org/licenses/).

Support Us

To support a GitHub project by liking it, you can follow these steps:

  1. Visit the repository: Navigate to the GitHub repository

  2. Click the "Star" button: On the repository page, you'll see a "Star" button in the upper right corner. Clicking on it will star the repository, indicating your support for the project.

  3. Optionally, you can also leave a comment on the repository or open an issue to give feedback or suggest changes.

Starring a repository on GitHub is a simple way to show your support and appreciation for the project. It also helps to increase the visibility of the project and make it more discoverable to others.

Who we are

We believe that the key to success in the digital age is the ability to deliver value quickly and reliably. That’s why we offer a comprehensive range of DevOps & Cloud services designed to help your organization optimize its systems & Processes for speed and agility.

  1. We are an AWS Advanced consulting partner which reflects our deep expertise in AWS Cloud and helping 100+ clients over the last 5 years.
  2. Expertise in Kubernetes and overall container solution helps companies expedite their journey by 10X.
  3. Infrastructure Automation is a key component to the success of our Clients and our Expertise helps deliver the same in the shortest time.
  4. DevSecOps as a service to implement security within the overall DevOps process and helping companies deploy securely and at speed.
  5. Platform engineering which supports scalable,Cost efficient infrastructure that supports rapid development, testing, and deployment.
  6. 24*7 SRE service to help you Monitor the state of your infrastructure and eradicate any issue within the SLA.

We provide support on all of our projects, no matter how small or large they may be.

To find more information about our company, visit squareops.com, follow us on Linkedin, or fill out a job application. If you have any questions or would like assistance with your cloud strategy and implementation, please don't hesitate to contact us.