alicloud.ens.KeyPair
Explore with Pulumi AI
Provides a ENS Key Pair resource.
For information about ENS Key Pair and how to use it, see What is Key Pair.
NOTE: Available since v1.133.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "terraform-example";
const example = new alicloud.ens.KeyPair("example", {
keyPairName: name,
version: "2017-11-10",
});
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
example = alicloud.ens.KeyPair("example",
key_pair_name=name,
version="2017-11-10")
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ens"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "terraform-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_, err := ens.NewKeyPair(ctx, "example", &ens.KeyPairArgs{
KeyPairName: pulumi.String(name),
Version: pulumi.String("2017-11-10"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "terraform-example";
var example = new AliCloud.Ens.KeyPair("example", new()
{
KeyPairName = name,
Version = "2017-11-10",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ens.KeyPair;
import com.pulumi.alicloud.ens.KeyPairArgs;
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) {
final var config = ctx.config();
final var name = config.get("name").orElse("terraform-example");
var example = new KeyPair("example", KeyPairArgs.builder()
.keyPairName(name)
.version("2017-11-10")
.build());
}
}
configuration:
name:
type: string
default: terraform-example
resources:
example:
type: alicloud:ens:KeyPair
properties:
keyPairName: ${name}
version: 2017-11-10
Create KeyPair Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new KeyPair(name: string, args: KeyPairArgs, opts?: CustomResourceOptions);
@overload
def KeyPair(resource_name: str,
args: KeyPairArgs,
opts: Optional[ResourceOptions] = None)
@overload
def KeyPair(resource_name: str,
opts: Optional[ResourceOptions] = None,
key_pair_name: Optional[str] = None,
version: Optional[str] = None)
func NewKeyPair(ctx *Context, name string, args KeyPairArgs, opts ...ResourceOption) (*KeyPair, error)
public KeyPair(string name, KeyPairArgs args, CustomResourceOptions? opts = null)
public KeyPair(String name, KeyPairArgs args)
public KeyPair(String name, KeyPairArgs args, CustomResourceOptions options)
type: alicloud:ens:KeyPair
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 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.
- args KeyPairArgs
- 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 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.
- name String
- The unique name of the resource.
- args KeyPairArgs
- 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 examplekeyPairResourceResourceFromEnskeyPair = new AliCloud.Ens.KeyPair("examplekeyPairResourceResourceFromEnskeyPair", new()
{
KeyPairName = "string",
Version = "string",
});
example, err := ens.NewKeyPair(ctx, "examplekeyPairResourceResourceFromEnskeyPair", &ens.KeyPairArgs{
KeyPairName: pulumi.String("string"),
Version: pulumi.String("string"),
})
var examplekeyPairResourceResourceFromEnskeyPair = new KeyPair("examplekeyPairResourceResourceFromEnskeyPair", KeyPairArgs.builder()
.keyPairName("string")
.version("string")
.build());
examplekey_pair_resource_resource_from_enskey_pair = alicloud.ens.KeyPair("examplekeyPairResourceResourceFromEnskeyPair",
key_pair_name="string",
version="string")
const examplekeyPairResourceResourceFromEnskeyPair = new alicloud.ens.KeyPair("examplekeyPairResourceResourceFromEnskeyPair", {
keyPairName: "string",
version: "string",
});
type: alicloud:ens:KeyPair
properties:
keyPairName: string
version: string
KeyPair 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 KeyPair resource accepts the following input properties:
- Key
Pair stringName - The name of the key pair.
- Version string
- The version number.
- Key
Pair stringName - The name of the key pair.
- Version string
- The version number.
- key
Pair StringName - The name of the key pair.
- version String
- The version number.
- key
Pair stringName - The name of the key pair.
- version string
- The version number.
- key_
pair_ strname - The name of the key pair.
- version str
- The version number.
- key
Pair StringName - The name of the key pair.
- version String
- The version number.
Outputs
All input properties are implicitly available as output properties. Additionally, the KeyPair resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up 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): KeyPair
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
key_pair_name: Optional[str] = None,
version: Optional[str] = None) -> KeyPair
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)
public static KeyPair get(String name, Output<String> id, KeyPairState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
- Key
Pair stringName - The name of the key pair.
- Version string
- The version number.
- Key
Pair stringName - The name of the key pair.
- Version string
- The version number.
- key
Pair StringName - The name of the key pair.
- version String
- The version number.
- key
Pair stringName - The name of the key pair.
- version string
- The version number.
- key_
pair_ strname - The name of the key pair.
- version str
- The version number.
- key
Pair StringName - The name of the key pair.
- version String
- The version number.
Import
ENS Key Pair can be imported using the id, e.g.
$ pulumi import alicloud:ens/keyPair:KeyPair example <key_pair_name>:<version>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.