@huaweicloudos/pulumi
Version:
A Pulumi package for creating and managing Huaweicloud cloud resources.
160 lines • 6.75 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** 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");
/**
* Manages a keypair resource within HuaweiCloud.
*
* By default, keypair use the SSH-2 (RSA, 2048) algorithm for encryption and decryption.
*
* Keys imported support the following cryptographic algorithms:
*
* * RSA-1024
* * RSA-2048
* * RSA-4096
*
* ## Example Usage
* ### Create a new KPS keypair
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const kmsKeyId = config.requireObject("kmsKeyId");
* const kmsKeyName = config.requireObject("kmsKeyName");
* const keyFile = config.requireObject("keyFile");
* const test = new huaweicloud.dew.Keypair("test", {
* scope: "user",
* encryptionType: "kms",
* kmsKeyId: kmsKeyId,
* kmsKeyName: kmsKeyName,
* description: "test description",
* keyFile: keyFile,
* });
* ```
* ### Import an existing KPS keypair
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const publicKey = config.requireObject("publicKey");
* const privateKey = config.requireObject("privateKey");
* const test = new huaweicloud.dew.Keypair("test", {
* scope: "account",
* encryptionType: "default",
* description: "test description",
* publicKey: publicKey,
* privateKey: privateKey,
* });
* ```
* ### Import an existing KPS keypair without private key
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const publicKey = config.requireObject("publicKey");
* const test = new huaweicloud.dew.Keypair("test", {
* scope: "account",
* description: "test description",
* publicKey: publicKey,
* });
* ```
*
* ## Import
*
* Keypair can be imported using the `name`, e.g. bash
*
* ```sh
* $ pulumi import huaweicloud:Dew/keypair:Keypair test <name>
* ```
*
* Note that the imported state may not be identical to your resource definition, due to some attributes missing from the API response, security or some other reason. The missing attributes include`encryption_type`, `kms_key_id`, `kms_key_name`, `key_file` and `private_key`. It is generally recommended running `terraform plan` after importing a keypair. You can then decide if changes should be applied to the keypair, or the resource definition should be updated to align with the keypair. Also, you can ignore changes as below. hcl resource "huaweicloud_kps_keypair" "test" {
*
* ...
*
* lifecycle {
*
* ignore_changes = [
*
* encryption_type, kms_key_id, kms_key_name, key_file, private_key
*
* ]
*
* } }
*/
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, Object.assign(Object.assign({}, 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["createdAt"] = state ? state.createdAt : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["encryptionType"] = state ? state.encryptionType : undefined;
resourceInputs["fingerprint"] = state ? state.fingerprint : undefined;
resourceInputs["isManaged"] = state ? state.isManaged : undefined;
resourceInputs["keyFile"] = state ? state.keyFile : undefined;
resourceInputs["kmsKeyId"] = state ? state.kmsKeyId : undefined;
resourceInputs["kmsKeyName"] = state ? state.kmsKeyName : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["privateKey"] = state ? state.privateKey : undefined;
resourceInputs["publicKey"] = state ? state.publicKey : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["scope"] = state ? state.scope : undefined;
resourceInputs["userId"] = state ? state.userId : undefined;
}
else {
const args = argsOrState;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["encryptionType"] = args ? args.encryptionType : undefined;
resourceInputs["keyFile"] = args ? args.keyFile : undefined;
resourceInputs["kmsKeyId"] = args ? args.kmsKeyId : undefined;
resourceInputs["kmsKeyName"] = args ? args.kmsKeyName : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["privateKey"] = args ? args.privateKey : undefined;
resourceInputs["publicKey"] = args ? args.publicKey : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["scope"] = args ? args.scope : undefined;
resourceInputs["userId"] = args ? args.userId : undefined;
resourceInputs["createdAt"] = undefined /*out*/;
resourceInputs["fingerprint"] = undefined /*out*/;
resourceInputs["isManaged"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Keypair.__pulumiType, name, resourceInputs, opts);
}
}
exports.Keypair = Keypair;
/** @internal */
Keypair.__pulumiType = 'huaweicloud:Dew/keypair:Keypair';
//# sourceMappingURL=keypair.js.map