KeyPair
Provides a Lightsail Key Pair, for use with Lightsail Instances. These key pairs are separate from EC2 Key Pairs, and must be created or imported for use with Lightsail.
Note: Lightsail is currently only supported in a limited number of AWS Regions, please see “Regions and Availability Zones in Amazon Lightsail” for more details
Create new Key Pair, encrypting the private key with a PGP Key
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const lgKeyPair = new aws.lightsail.KeyPair("lg_key_pair", {
pgpKey: "keybase:keybaseusername",
});import pulumi
import pulumi_aws as aws
lg_key_pair = aws.lightsail.KeyPair("lgKeyPair", pgp_key="keybase:keybaseusername")using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var lgKeyPair = new Aws.LightSail.KeyPair("lgKeyPair", new Aws.LightSail.KeyPairArgs
{
PgpKey = "keybase:keybaseusername",
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/lightsail"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := lightsail.NewKeyPair(ctx, "lgKeyPair", &lightsail.KeyPairArgs{
PgpKey: pulumi.String("keybase:keybaseusername"),
})
if err != nil {
return err
}
return nil
})
}Import an existing public key
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as fs from "fs";
const lgKeyPair = new aws.lightsail.KeyPair("lg_key_pair", {
publicKey: fs.readFileSync("~/.ssh/id_rsa.pub", "utf-8"),
});import pulumi
import pulumi_aws as aws
lg_key_pair = aws.lightsail.KeyPair("lgKeyPair", public_key=(lambda path: open(path).read())("~/.ssh/id_rsa.pub"))using System.IO;
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var lgKeyPair = new Aws.LightSail.KeyPair("lgKeyPair", new Aws.LightSail.KeyPairArgs
{
PublicKey = File.ReadAllText("~/.ssh/id_rsa.pub"),
});
}
}
Example Usage
Creating A New Key Pair
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
// Create a new Lightsail Key Pair
var lgKeyPair = new Aws.LightSail.KeyPair("lgKeyPair", new Aws.LightSail.KeyPairArgs
{
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/lightsail"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := lightsail.NewKeyPair(ctx, "lgKeyPair", nil)
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
# Create a new Lightsail Key Pair
lg_key_pair = aws.lightsail.KeyPair("lgKeyPair")import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// Create a new Lightsail Key Pair
const lgKeyPair = new aws.lightsail.KeyPair("lg_key_pair", {});Create a KeyPair Resource
new KeyPair(name: string, args?: KeyPairArgs, opts?: CustomResourceOptions);def KeyPair(resource_name, opts=None, name=None, name_prefix=None, pgp_key=None, public_key=None, __props__=None);func NewKeyPair(ctx *Context, name string, args *KeyPairArgs, opts ...ResourceOption) (*KeyPair, error)public KeyPair(string name, KeyPairArgs? args = null, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args KeyPairArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args KeyPairArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args KeyPairArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
KeyPair Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The KeyPair resource accepts the following input properties:
- Name string
The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
- Name
Prefix string - Pgp
Key string An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
- Public
Key string The public key material. This public key will be imported into Lightsail
- Name string
The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
- Name
Prefix string - Pgp
Key string An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
- Public
Key string The public key material. This public key will be imported into Lightsail
- name string
The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
- name
Prefix string - pgp
Key string An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
- public
Key string The public key material. This public key will be imported into Lightsail
- name str
The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
- name_
prefix str - pgp_
key str An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
- public_
key str The public key material. This public key will be imported into Lightsail
Outputs
All input properties are implicitly available as output properties. Additionally, the KeyPair resource produces the following output properties:
- Arn string
The ARN of the Lightsail key pair
- Encrypted
Fingerprint string The MD5 public key fingerprint for the encrypted private key
- Encrypted
Private stringKey the private key material, base 64 encoded and encrypted with the given
pgp_key. This is only populated when creating a new key andpgp_keyis supplied- Fingerprint string
The MD5 public key fingerprint as specified in section 4 of RFC 4716.
- Id string
- The provider-assigned unique ID for this managed resource.
- Private
Key string the private key, base64 encoded. This is only populated when creating a new key, and when no
pgp_keyis provided
- Arn string
The ARN of the Lightsail key pair
- Encrypted
Fingerprint string The MD5 public key fingerprint for the encrypted private key
- Encrypted
Private stringKey the private key material, base 64 encoded and encrypted with the given
pgp_key. This is only populated when creating a new key andpgp_keyis supplied- Fingerprint string
The MD5 public key fingerprint as specified in section 4 of RFC 4716.
- Id string
- The provider-assigned unique ID for this managed resource.
- Private
Key string the private key, base64 encoded. This is only populated when creating a new key, and when no
pgp_keyis provided
- arn string
The ARN of the Lightsail key pair
- encrypted
Fingerprint string The MD5 public key fingerprint for the encrypted private key
- encrypted
Private stringKey the private key material, base 64 encoded and encrypted with the given
pgp_key. This is only populated when creating a new key andpgp_keyis supplied- fingerprint string
The MD5 public key fingerprint as specified in section 4 of RFC 4716.
- id string
- The provider-assigned unique ID for this managed resource.
- private
Key string the private key, base64 encoded. This is only populated when creating a new key, and when no
pgp_keyis provided
- arn str
The ARN of the Lightsail key pair
- encrypted_
fingerprint str The MD5 public key fingerprint for the encrypted private key
- encrypted_
private_ strkey the private key material, base 64 encoded and encrypted with the given
pgp_key. This is only populated when creating a new key andpgp_keyis supplied- fingerprint str
The MD5 public key fingerprint as specified in section 4 of RFC 4716.
- id str
- The provider-assigned unique ID for this managed resource.
- private_
key str the private key, base64 encoded. This is only populated when creating a new key, and when no
pgp_keyis provided
Look up an Existing KeyPair Resource
Get an existing KeyPair resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: KeyPairState, opts?: CustomResourceOptions): KeyPairstatic get(resource_name, id, opts=None, arn=None, encrypted_fingerprint=None, encrypted_private_key=None, fingerprint=None, name=None, name_prefix=None, pgp_key=None, private_key=None, public_key=None, __props__=None);func GetKeyPair(ctx *Context, name string, id IDInput, state *KeyPairState, opts ...ResourceOption) (*KeyPair, error)public static KeyPair Get(string name, Input<string> id, KeyPairState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
- Arn string
The ARN of the Lightsail key pair
- Encrypted
Fingerprint string The MD5 public key fingerprint for the encrypted private key
- Encrypted
Private stringKey the private key material, base 64 encoded and encrypted with the given
pgp_key. This is only populated when creating a new key andpgp_keyis supplied- Fingerprint string
The MD5 public key fingerprint as specified in section 4 of RFC 4716.
- Name string
The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
- Name
Prefix string - Pgp
Key string An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
- Private
Key string the private key, base64 encoded. This is only populated when creating a new key, and when no
pgp_keyis provided- Public
Key string The public key material. This public key will be imported into Lightsail
- Arn string
The ARN of the Lightsail key pair
- Encrypted
Fingerprint string The MD5 public key fingerprint for the encrypted private key
- Encrypted
Private stringKey the private key material, base 64 encoded and encrypted with the given
pgp_key. This is only populated when creating a new key andpgp_keyis supplied- Fingerprint string
The MD5 public key fingerprint as specified in section 4 of RFC 4716.
- Name string
The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
- Name
Prefix string - Pgp
Key string An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
- Private
Key string the private key, base64 encoded. This is only populated when creating a new key, and when no
pgp_keyis provided- Public
Key string The public key material. This public key will be imported into Lightsail
- arn string
The ARN of the Lightsail key pair
- encrypted
Fingerprint string The MD5 public key fingerprint for the encrypted private key
- encrypted
Private stringKey the private key material, base 64 encoded and encrypted with the given
pgp_key. This is only populated when creating a new key andpgp_keyis supplied- fingerprint string
The MD5 public key fingerprint as specified in section 4 of RFC 4716.
- name string
The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
- name
Prefix string - pgp
Key string An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
- private
Key string the private key, base64 encoded. This is only populated when creating a new key, and when no
pgp_keyis provided- public
Key string The public key material. This public key will be imported into Lightsail
- arn str
The ARN of the Lightsail key pair
- encrypted_
fingerprint str The MD5 public key fingerprint for the encrypted private key
- encrypted_
private_ strkey the private key material, base 64 encoded and encrypted with the given
pgp_key. This is only populated when creating a new key andpgp_keyis supplied- fingerprint str
The MD5 public key fingerprint as specified in section 4 of RFC 4716.
- name str
The name of the Lightsail Key Pair. If omitted, a unique name will be generated by this provider
- name_
prefix str - pgp_
key str An optional PGP key to encrypt the resulting private key material. Only used when creating a new key pair
- private_
key str the private key, base64 encoded. This is only populated when creating a new key, and when no
pgp_keyis provided- public_
key str The public key material. This public key will be imported into Lightsail
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.