@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
102 lines • 4.95 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyPair = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides an [EC2 key pair](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html) resource. A key pair is used to control login access to EC2 instances.
*
* Currently this resource requires an existing user-supplied key pair. This key pair's public key will be registered with AWS to allow logging-in to EC2 instances.
*
* When importing an existing key pair the public key material may be in any format supported by AWS. Supported formats (per the [AWS documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#how-to-generate-your-own-key-and-import-it-to-aws)) are:
*
* * OpenSSH public key format (the format in ~/.ssh/authorized_keys)
* * Base64 encoded DER format
* * SSH public key file format as specified in RFC4716
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const deployer = new aws.ec2.KeyPair("deployer", {
* keyName: "deployer-key",
* publicKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 email@example.com",
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import Key Pairs using the `key_name`. For example:
*
* ```sh
* $ pulumi import aws:ec2/keyPair:KeyPair deployer deployer-key
* ```
* ~> __NOTE:__ The AWS API does not include the public key in the response, so `pulumi up` will attempt to replace the key pair. There is currently no supported workaround for this limitation.
*/
class KeyPair extends pulumi.CustomResource {
/**
* Get an existing KeyPair resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new KeyPair(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of KeyPair. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === KeyPair.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["arn"] = state?.arn;
resourceInputs["fingerprint"] = state?.fingerprint;
resourceInputs["keyName"] = state?.keyName;
resourceInputs["keyNamePrefix"] = state?.keyNamePrefix;
resourceInputs["keyPairId"] = state?.keyPairId;
resourceInputs["keyType"] = state?.keyType;
resourceInputs["publicKey"] = state?.publicKey;
resourceInputs["region"] = state?.region;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
}
else {
const args = argsOrState;
if (args?.publicKey === undefined && !opts.urn) {
throw new Error("Missing required property 'publicKey'");
}
resourceInputs["keyName"] = args?.keyName;
resourceInputs["keyNamePrefix"] = args?.keyNamePrefix;
resourceInputs["publicKey"] = args?.publicKey;
resourceInputs["region"] = args?.region;
resourceInputs["tags"] = args?.tags;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["fingerprint"] = undefined /*out*/;
resourceInputs["keyPairId"] = undefined /*out*/;
resourceInputs["keyType"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(KeyPair.__pulumiType, name, resourceInputs, opts);
}
}
exports.KeyPair = KeyPair;
/** @internal */
KeyPair.__pulumiType = 'aws:ec2/keyPair:KeyPair';
//# sourceMappingURL=keyPair.js.map