Skip to main content

CDK Construct for managing EC2 key pairs

Project description

CDK EC2 Key Pair

Source Test GitHub Docs

npm package PyPI package NuGet package

Downloads npm PyPI NuGet

AWS CDK L3 construct for managing EC2 Key Pairs.

CloudFormation doesn't directly support creation of EC2 Key Pairs. This construct provides an easy interface for creating Key Pairs through a custom CloudFormation resource. The private key is stored in AWS Secrets Manager.

Usage

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.core as cdk
import aws_cdk.aws_ec2 as ec2
from cdk_ec2_key_pair import KeyPair

# Create the Key Pair
key = KeyPair(self, "A-Key-Pair",
    name="a-key-pair",
    description="This is a Key Pair"
)

# Grant read access to the private key to a role or user
key.grant_read(some_role)

# Use Key Pair on an EC2 instance
ec2.Instance(self, "An-Instance", {
    "key_name": key.name
})

The private key will be stored in AWS Secrets Manager. The secret name by default is prefixed with ec2-private-key/, so in this example it will be saved as ec2-private-key/a-key-pair.

To download the private key via AWS cli you can run:

aws secretsmanager get-secret-value \
  --secret-id ec2-private-key/a-key-pair \
  --query SecretString \
  --output text

Roadmap

  • Name should be optional

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk-ec2-key-pair-1.7.1.tar.gz (52.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdk_ec2_key_pair-1.7.1-py3-none-any.whl (51.6 kB view details)

Uploaded Python 3

File details

Details for the file cdk-ec2-key-pair-1.7.1.tar.gz.

File metadata

  • Download URL: cdk-ec2-key-pair-1.7.1.tar.gz
  • Upload date:
  • Size: 52.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

File hashes

Hashes for cdk-ec2-key-pair-1.7.1.tar.gz
Algorithm Hash digest
SHA256 37db818911bca6492d573b5c556749f301677546c1f4428d833b1aac8bf3ab75
MD5 37df04105b8e855edb6110afe281a1fd
BLAKE2b-256 e39399d551f6213b026284d29f8ef89aaaab7863e7cef77363fd1acf486468be

See more details on using hashes here.

File details

Details for the file cdk_ec2_key_pair-1.7.1-py3-none-any.whl.

File metadata

  • Download URL: cdk_ec2_key_pair-1.7.1-py3-none-any.whl
  • Upload date:
  • Size: 51.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

File hashes

Hashes for cdk_ec2_key_pair-1.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bdef6794950be5227491697efc64462377a69ba0f350bdb70a43b144ce697a20
MD5 f0527a5a46d39869f25c6b4fc8ed3cd4
BLAKE2b-256 128411ced9776ad11437876bf47459f1f3a845ffd68254a63ef8c1cb2a7c3b12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page