vkcs.ComputeKeypair
Explore with Pulumi AI
Example Usage
Import an Existing Public Key
import * as pulumi from "@pulumi/pulumi";
import * as fs from "fs";
import * as vkcs from "@pulumi/vkcs";
const existingKey = new vkcs.ComputeKeypair("existingKey", {publicKey: fs.readFileSync(`${path.module}/public_key.key`, "utf8")});
import pulumi
import pulumi_vkcs as vkcs
existing_key = vkcs.ComputeKeypair("existingKey", public_key=(lambda path: open(path).read())(f"{path['module']}/public_key.key"))
package main
import (
"fmt"
"os"
"github.com/pulumi/pulumi-terraform-provider/sdks/go/vkcs/vkcs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func readFileOrPanic(path string) pulumi.StringPtrInput {
data, err := os.ReadFile(path)
if err != nil {
panic(err.Error())
}
return pulumi.String(string(data))
}
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := vkcs.NewComputeKeypair(ctx, "existingKey", &vkcs.ComputeKeypairArgs{
PublicKey: pulumi.String(readFileOrPanic(fmt.Sprintf("%v/public_key.key", path.Module))),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Pulumi;
using Vkcs = Pulumi.Vkcs;
return await Deployment.RunAsync(() =>
{
var existingKey = new Vkcs.ComputeKeypair("existingKey", new()
{
PublicKey = File.ReadAllText($"{path.Module}/public_key.key"),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vkcs.ComputeKeypair;
import com.pulumi.vkcs.ComputeKeypairArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var existingKey = new ComputeKeypair("existingKey", ComputeKeypairArgs.builder()
.publicKey(Files.readString(Paths.get(String.format("%s/public_key.key", path.module()))))
.build());
}
}
resources:
existingKey:
type: vkcs:ComputeKeypair
properties:
publicKey:
fn::readFile: ${path.module}/public_key.key
Generate a Public/Private Key Pair
import * as pulumi from "@pulumi/pulumi";
import * as vkcs from "@pulumi/vkcs";
const generatedKey = new vkcs.ComputeKeypair("generatedKey", {});
export const publicKey = generatedKey.publicKey;
export const privateKey = generatedKey.privateKey;
import pulumi
import pulumi_vkcs as vkcs
generated_key = vkcs.ComputeKeypair("generatedKey")
pulumi.export("publicKey", generated_key.public_key)
pulumi.export("privateKey", generated_key.private_key)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/vkcs/vkcs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
generatedKey, err := vkcs.NewComputeKeypair(ctx, "generatedKey", nil)
if err != nil {
return err
}
ctx.Export("publicKey", generatedKey.PublicKey)
ctx.Export("privateKey", generatedKey.PrivateKey)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Vkcs = Pulumi.Vkcs;
return await Deployment.RunAsync(() =>
{
var generatedKey = new Vkcs.ComputeKeypair("generatedKey");
return new Dictionary<string, object?>
{
["publicKey"] = generatedKey.PublicKey,
["privateKey"] = generatedKey.PrivateKey,
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vkcs.ComputeKeypair;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var generatedKey = new ComputeKeypair("generatedKey");
ctx.export("publicKey", generatedKey.publicKey());
ctx.export("privateKey", generatedKey.privateKey());
}
}
resources:
generatedKey:
type: vkcs:ComputeKeypair
outputs:
publicKey: ${generatedKey.publicKey}
privateKey: ${generatedKey.privateKey}
Create ComputeKeypair Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ComputeKeypair(name: string, args?: ComputeKeypairArgs, opts?: CustomResourceOptions);
@overload
def ComputeKeypair(resource_name: str,
args: Optional[ComputeKeypairArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def ComputeKeypair(resource_name: str,
opts: Optional[ResourceOptions] = None,
compute_keypair_id: Optional[str] = None,
name: Optional[str] = None,
public_key: Optional[str] = None,
region: Optional[str] = None,
value_specs: Optional[Mapping[str, str]] = None)
func NewComputeKeypair(ctx *Context, name string, args *ComputeKeypairArgs, opts ...ResourceOption) (*ComputeKeypair, error)
public ComputeKeypair(string name, ComputeKeypairArgs? args = null, CustomResourceOptions? opts = null)
public ComputeKeypair(String name, ComputeKeypairArgs args)
public ComputeKeypair(String name, ComputeKeypairArgs args, CustomResourceOptions options)
type: vkcs:ComputeKeypair
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args ComputeKeypairArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args ComputeKeypairArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args ComputeKeypairArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ComputeKeypairArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ComputeKeypairArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var computeKeypairResource = new Vkcs.ComputeKeypair("computeKeypairResource", new()
{
ComputeKeypairId = "string",
Name = "string",
PublicKey = "string",
Region = "string",
ValueSpecs =
{
{ "string", "string" },
},
});
example, err := vkcs.NewComputeKeypair(ctx, "computeKeypairResource", &vkcs.ComputeKeypairArgs{
ComputeKeypairId: pulumi.String("string"),
Name: pulumi.String("string"),
PublicKey: pulumi.String("string"),
Region: pulumi.String("string"),
ValueSpecs: pulumi.StringMap{
"string": pulumi.String("string"),
},
})
var computeKeypairResource = new ComputeKeypair("computeKeypairResource", ComputeKeypairArgs.builder()
.computeKeypairId("string")
.name("string")
.publicKey("string")
.region("string")
.valueSpecs(Map.of("string", "string"))
.build());
compute_keypair_resource = vkcs.ComputeKeypair("computeKeypairResource",
compute_keypair_id="string",
name="string",
public_key="string",
region="string",
value_specs={
"string": "string",
})
const computeKeypairResource = new vkcs.ComputeKeypair("computeKeypairResource", {
computeKeypairId: "string",
name: "string",
publicKey: "string",
region: "string",
valueSpecs: {
string: "string",
},
});
type: vkcs:ComputeKeypair
properties:
computeKeypairId: string
name: string
publicKey: string
region: string
valueSpecs:
string: string
ComputeKeypair Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The ComputeKeypair resource accepts the following input properties:
- Compute
Keypair stringId - string → ID of the resource.
- Name string
- required string → A unique name for the keypair. Changing this creates a new keypair.
- Public
Key string - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- Region string
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - Value
Specs Dictionary<string, string> - optional map of string → Map of additional options.
- Compute
Keypair stringId - string → ID of the resource.
- Name string
- required string → A unique name for the keypair. Changing this creates a new keypair.
- Public
Key string - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- Region string
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - Value
Specs map[string]string - optional map of string → Map of additional options.
- compute
Keypair StringId - string → ID of the resource.
- name String
- required string → A unique name for the keypair. Changing this creates a new keypair.
- public
Key String - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- region String
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - value
Specs Map<String,String> - optional map of string → Map of additional options.
- compute
Keypair stringId - string → ID of the resource.
- name string
- required string → A unique name for the keypair. Changing this creates a new keypair.
- public
Key string - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- region string
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - value
Specs {[key: string]: string} - optional map of string → Map of additional options.
- compute_
keypair_ strid - string → ID of the resource.
- name str
- required string → A unique name for the keypair. Changing this creates a new keypair.
- public_
key str - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- region str
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - value_
specs Mapping[str, str] - optional map of string → Map of additional options.
- compute
Keypair StringId - string → ID of the resource.
- name String
- required string → A unique name for the keypair. Changing this creates a new keypair.
- public
Key String - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- region String
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - value
Specs Map<String> - optional map of string → Map of additional options.
Outputs
All input properties are implicitly available as output properties. Additionally, the ComputeKeypair resource produces the following output properties:
- Fingerprint string
- string → The fingerprint of the public key.
- Id string
- The provider-assigned unique ID for this managed resource.
- Private
Key string - string → The generated private key when no public key is specified.
- Fingerprint string
- string → The fingerprint of the public key.
- Id string
- The provider-assigned unique ID for this managed resource.
- Private
Key string - string → The generated private key when no public key is specified.
- fingerprint String
- string → The fingerprint of the public key.
- id String
- The provider-assigned unique ID for this managed resource.
- private
Key String - string → The generated private key when no public key is specified.
- fingerprint string
- string → The fingerprint of the public key.
- id string
- The provider-assigned unique ID for this managed resource.
- private
Key string - string → The generated private key when no public key is specified.
- fingerprint str
- string → The fingerprint of the public key.
- id str
- The provider-assigned unique ID for this managed resource.
- private_
key str - string → The generated private key when no public key is specified.
- fingerprint String
- string → The fingerprint of the public key.
- id String
- The provider-assigned unique ID for this managed resource.
- private
Key String - string → The generated private key when no public key is specified.
Look up Existing ComputeKeypair Resource
Get an existing ComputeKeypair 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?: ComputeKeypairState, opts?: CustomResourceOptions): ComputeKeypair
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
compute_keypair_id: Optional[str] = None,
fingerprint: Optional[str] = None,
name: Optional[str] = None,
private_key: Optional[str] = None,
public_key: Optional[str] = None,
region: Optional[str] = None,
value_specs: Optional[Mapping[str, str]] = None) -> ComputeKeypair
func GetComputeKeypair(ctx *Context, name string, id IDInput, state *ComputeKeypairState, opts ...ResourceOption) (*ComputeKeypair, error)
public static ComputeKeypair Get(string name, Input<string> id, ComputeKeypairState? state, CustomResourceOptions? opts = null)
public static ComputeKeypair get(String name, Output<String> id, ComputeKeypairState state, CustomResourceOptions options)
resources: _: type: vkcs:ComputeKeypair get: id: ${id}
- 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.
- 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.
- Compute
Keypair stringId - string → ID of the resource.
- Fingerprint string
- string → The fingerprint of the public key.
- Name string
- required string → A unique name for the keypair. Changing this creates a new keypair.
- Private
Key string - string → The generated private key when no public key is specified.
- Public
Key string - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- Region string
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - Value
Specs Dictionary<string, string> - optional map of string → Map of additional options.
- Compute
Keypair stringId - string → ID of the resource.
- Fingerprint string
- string → The fingerprint of the public key.
- Name string
- required string → A unique name for the keypair. Changing this creates a new keypair.
- Private
Key string - string → The generated private key when no public key is specified.
- Public
Key string - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- Region string
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - Value
Specs map[string]string - optional map of string → Map of additional options.
- compute
Keypair StringId - string → ID of the resource.
- fingerprint String
- string → The fingerprint of the public key.
- name String
- required string → A unique name for the keypair. Changing this creates a new keypair.
- private
Key String - string → The generated private key when no public key is specified.
- public
Key String - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- region String
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - value
Specs Map<String,String> - optional map of string → Map of additional options.
- compute
Keypair stringId - string → ID of the resource.
- fingerprint string
- string → The fingerprint of the public key.
- name string
- required string → A unique name for the keypair. Changing this creates a new keypair.
- private
Key string - string → The generated private key when no public key is specified.
- public
Key string - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- region string
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - value
Specs {[key: string]: string} - optional map of string → Map of additional options.
- compute_
keypair_ strid - string → ID of the resource.
- fingerprint str
- string → The fingerprint of the public key.
- name str
- required string → A unique name for the keypair. Changing this creates a new keypair.
- private_
key str - string → The generated private key when no public key is specified.
- public_
key str - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- region str
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - value_
specs Mapping[str, str] - optional map of string → Map of additional options.
- compute
Keypair StringId - string → ID of the resource.
- fingerprint String
- string → The fingerprint of the public key.
- name String
- required string → A unique name for the keypair. Changing this creates a new keypair.
- private
Key String - string → The generated private key when no public key is specified.
- public
Key String - optional string → A pregenerated OpenSSH-formatted public key. Changing this creates a new keypair. If a public key is not specified, then a public/private key pair will be automatically generated. If a pair is created, then destroying this resource means you will lose access to that keypair forever.
- region String
- optional string → The region in which to obtain the Compute client. Keypairs are associated with accounts, but a Compute client is needed to create one. If omitted, the
region
argument of the provider is used. Changing this creates a new keypair. - value
Specs Map<String> - optional map of string → Map of additional options.
Import
Keypairs can be imported using the name
, e.g.
$ pulumi import vkcs:index/computeKeypair:ComputeKeypair my-keypair test-keypair
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- vkcs vk-cs/terraform-provider-vkcs
- License
- Notes
- This Pulumi package is based on the
vkcs
Terraform Provider.