1. Packages
  2. Selectel Provider
  3. API Docs
  4. VpcKeypairV2
selectel 6.4.0 published on Monday, Apr 14, 2025 by selectel

selectel.VpcKeypairV2

Explore with Pulumi AI

selectel logo
selectel 6.4.0 published on Monday, Apr 14, 2025 by selectel

    Creates and manages a SSH key pair using public API v2. For more information about SSH key pairs, see the official Selectel documentation.

    Selectel products support Identity and Access Management (IAM). Only service users can use SSH key pairs. To create a service user, use the selectel.IamServiceuserV1 resource. For more information about service users, see the official Selectel documentation.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as fs from "fs";
    import * as selectel from "@pulumi/selectel";
    
    const keypair1 = new selectel.VpcKeypairV2("keypair1", {
        publicKey: fs.readFileSync("~/.ssh/id_rsa.pub", "utf8"),
        userId: selectel_iam_serviceuser_v1.user_1.id,
    });
    
    import pulumi
    import pulumi_selectel as selectel
    
    keypair1 = selectel.VpcKeypairV2("keypair1",
        public_key=(lambda path: open(path).read())("~/.ssh/id_rsa.pub"),
        user_id=selectel_iam_serviceuser_v1["user_1"]["id"])
    
    package main
    
    import (
    	"os"
    
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/selectel/v6/selectel"
    	"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 := selectel.NewVpcKeypairV2(ctx, "keypair1", &selectel.VpcKeypairV2Args{
    			PublicKey: pulumi.String(readFileOrPanic("~/.ssh/id_rsa.pub")),
    			UserId:    pulumi.Any(selectel_iam_serviceuser_v1.User_1.Id),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using Pulumi;
    using Selectel = Pulumi.Selectel;
    
    return await Deployment.RunAsync(() => 
    {
        var keypair1 = new Selectel.VpcKeypairV2("keypair1", new()
        {
            PublicKey = File.ReadAllText("~/.ssh/id_rsa.pub"),
            UserId = selectel_iam_serviceuser_v1.User_1.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.selectel.VpcKeypairV2;
    import com.pulumi.selectel.VpcKeypairV2Args;
    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 keypair1 = new VpcKeypairV2("keypair1", VpcKeypairV2Args.builder()
                .publicKey(Files.readString(Paths.get("~/.ssh/id_rsa.pub")))
                .userId(selectel_iam_serviceuser_v1.user_1().id())
                .build());
    
        }
    }
    
    resources:
      keypair1:
        type: selectel:VpcKeypairV2
        properties:
          publicKey:
            fn::readFile: ~/.ssh/id_rsa.pub
          userId: ${selectel_iam_serviceuser_v1.user_1.id}
    

    Create VpcKeypairV2 Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new VpcKeypairV2(name: string, args: VpcKeypairV2Args, opts?: CustomResourceOptions);
    @overload
    def VpcKeypairV2(resource_name: str,
                     args: VpcKeypairV2Args,
                     opts: Optional[ResourceOptions] = None)
    
    @overload
    def VpcKeypairV2(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     public_key: Optional[str] = None,
                     user_id: Optional[str] = None,
                     name: Optional[str] = None,
                     regions: Optional[Sequence[str]] = None,
                     vpc_keypair_v2_id: Optional[str] = None)
    func NewVpcKeypairV2(ctx *Context, name string, args VpcKeypairV2Args, opts ...ResourceOption) (*VpcKeypairV2, error)
    public VpcKeypairV2(string name, VpcKeypairV2Args args, CustomResourceOptions? opts = null)
    public VpcKeypairV2(String name, VpcKeypairV2Args args)
    public VpcKeypairV2(String name, VpcKeypairV2Args args, CustomResourceOptions options)
    
    type: selectel:VpcKeypairV2
    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 VpcKeypairV2Args
    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 VpcKeypairV2Args
    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 VpcKeypairV2Args
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args VpcKeypairV2Args
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args VpcKeypairV2Args
    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 vpcKeypairV2Resource = new Selectel.VpcKeypairV2("vpcKeypairV2Resource", new()
    {
        PublicKey = "string",
        UserId = "string",
        Name = "string",
        Regions = new[]
        {
            "string",
        },
        VpcKeypairV2Id = "string",
    });
    
    example, err := selectel.NewVpcKeypairV2(ctx, "vpcKeypairV2Resource", &selectel.VpcKeypairV2Args{
    	PublicKey: pulumi.String("string"),
    	UserId:    pulumi.String("string"),
    	Name:      pulumi.String("string"),
    	Regions: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	VpcKeypairV2Id: pulumi.String("string"),
    })
    
    var vpcKeypairV2Resource = new VpcKeypairV2("vpcKeypairV2Resource", VpcKeypairV2Args.builder()
        .publicKey("string")
        .userId("string")
        .name("string")
        .regions("string")
        .vpcKeypairV2Id("string")
        .build());
    
    vpc_keypair_v2_resource = selectel.VpcKeypairV2("vpcKeypairV2Resource",
        public_key="string",
        user_id="string",
        name="string",
        regions=["string"],
        vpc_keypair_v2_id="string")
    
    const vpcKeypairV2Resource = new selectel.VpcKeypairV2("vpcKeypairV2Resource", {
        publicKey: "string",
        userId: "string",
        name: "string",
        regions: ["string"],
        vpcKeypairV2Id: "string",
    });
    
    type: selectel:VpcKeypairV2
    properties:
        name: string
        publicKey: string
        regions:
            - string
        userId: string
        vpcKeypairV2Id: string
    

    VpcKeypairV2 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 VpcKeypairV2 resource accepts the following input properties:

    PublicKey string
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    UserId string
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    Name string
    Name of the SSH key pair. Changing this creates a new key pair.
    Regions List<string>
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    VpcKeypairV2Id string
    PublicKey string
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    UserId string
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    Name string
    Name of the SSH key pair. Changing this creates a new key pair.
    Regions []string
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    VpcKeypairV2Id string
    publicKey String
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    userId String
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    name String
    Name of the SSH key pair. Changing this creates a new key pair.
    regions List<String>
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    vpcKeypairV2Id String
    publicKey string
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    userId string
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    name string
    Name of the SSH key pair. Changing this creates a new key pair.
    regions string[]
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    vpcKeypairV2Id string
    public_key str
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    user_id str
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    name str
    Name of the SSH key pair. Changing this creates a new key pair.
    regions Sequence[str]
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    vpc_keypair_v2_id str
    publicKey String
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    userId String
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    name String
    Name of the SSH key pair. Changing this creates a new key pair.
    regions List<String>
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    vpcKeypairV2Id String

    Outputs

    All input properties are implicitly available as output properties. Additionally, the VpcKeypairV2 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 VpcKeypairV2 Resource

    Get an existing VpcKeypairV2 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?: VpcKeypairV2State, opts?: CustomResourceOptions): VpcKeypairV2
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            name: Optional[str] = None,
            public_key: Optional[str] = None,
            regions: Optional[Sequence[str]] = None,
            user_id: Optional[str] = None,
            vpc_keypair_v2_id: Optional[str] = None) -> VpcKeypairV2
    func GetVpcKeypairV2(ctx *Context, name string, id IDInput, state *VpcKeypairV2State, opts ...ResourceOption) (*VpcKeypairV2, error)
    public static VpcKeypairV2 Get(string name, Input<string> id, VpcKeypairV2State? state, CustomResourceOptions? opts = null)
    public static VpcKeypairV2 get(String name, Output<String> id, VpcKeypairV2State state, CustomResourceOptions options)
    resources:  _:    type: selectel:VpcKeypairV2    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.
    The following state arguments are supported:
    Name string
    Name of the SSH key pair. Changing this creates a new key pair.
    PublicKey string
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    Regions List<string>
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    UserId string
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    VpcKeypairV2Id string
    Name string
    Name of the SSH key pair. Changing this creates a new key pair.
    PublicKey string
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    Regions []string
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    UserId string
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    VpcKeypairV2Id string
    name String
    Name of the SSH key pair. Changing this creates a new key pair.
    publicKey String
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    regions List<String>
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    userId String
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    vpcKeypairV2Id String
    name string
    Name of the SSH key pair. Changing this creates a new key pair.
    publicKey string
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    regions string[]
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    userId string
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    vpcKeypairV2Id string
    name str
    Name of the SSH key pair. Changing this creates a new key pair.
    public_key str
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    regions Sequence[str]
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    user_id str
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    vpc_keypair_v2_id str
    name String
    Name of the SSH key pair. Changing this creates a new key pair.
    publicKey String
    Pregenerated OpenSSH-formatted public key. Changing this creates a new key pair. Learn more how to create SSH key pair.
    regions List<String>
    List of pools where the key pair is located, for example, ru-3. Changing this creates a new key pair. Learn more about available pools in the Availability matrix.
    userId String
    Unique identifier of the associated service user. Changing this creates a new key pair. Retrieved from the selectel.IamServiceuserV1 resource.
    vpcKeypairV2Id String

    Import

    You can import a SSH key pair:

    export OS_DOMAIN_NAME=<account_id>

    export OS_USERNAME=

    export OS_PASSWORD=

    $ pulumi import selectel:index/vpcKeypairV2:VpcKeypairV2 keypair_1 <user_id>/<keypair_name>
    

    where:

    • <account_id> — Selectel account ID. The account ID is in the top right corner of the Control panel. Learn more about Registration.

    • <username> — Name of the service user. To get the name, in the Control panel, go to Identity & Access ManagementUser management ⟶ the Service users tab ⟶ copy the name of the required user. Learn more about Service users.

    • <password> — Password of the service user.

    • <user_id> — Unique identifier of the associated service user, for example, abc1bb378ac84e1234b869b77aadd2ab. To get the ID, in the Control panel, go to Identity & Access ManagementUser management ⟶ the Service users tab ⟶ copy the name of the required user.

    • <keypair_name> — Name of the key pair, for example, Key. To get the name, in the Control panel, go to Identity & Access ManagementUser management ⟶ the Service users tab ⟶ the user page. The SSH key pair name is in the SSH keys section.

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    selectel selectel/terraform-provider-selectel
    License
    Notes
    This Pulumi package is based on the selectel Terraform Provider.
    selectel logo
    selectel 6.4.0 published on Monday, Apr 14, 2025 by selectel