用于管理EC2密钥对的CDK构造
cdk-ec2-key-pair的Python项目详细描述
CDK EC2密钥对
用于管理EC2 Key Pairs的AWS CDKL3构造。在
CloudFormation不直接支持创建EC2密钥对。这个构造为通过custom CloudFormation resource创建密钥对提供了一个简单的接口。私钥存储在AWS Secrets Manager中。在
使用
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826importaws_cdk.coreascdkimportaws_cdk.aws_ec2asec2fromcdk_ec2_key_pairimportKeyPair# Create the Key Pairkey=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 userkey.grant_read(some_role)# Use Key Pair on an EC2 instanceec2.Instance(self,"An-Instance",{"key_name":key.name})
私钥将存储在AWS Secrets Manager中。默认情况下,秘密名称的前缀是ec2-private-key/
,因此在本例中,它将另存为ec2-private-key/a-key-pair
。在
要通过AWS cli下载私钥,您可以运行:
^{pr2}$路线图
- 名称应该是可选的
- 项目
标签: