1. Packages
  2. Azure Classic
  3. API Docs
  4. compute
  5. SshPublicKey

We recommend using Azure Native.

Azure Classic v5.80.0 published on Monday, Jun 10, 2024 by Pulumi

azure.compute.SshPublicKey

Explore with Pulumi AI

azure logo

We recommend using Azure Native.

Azure Classic v5.80.0 published on Monday, Jun 10, 2024 by Pulumi

    Manages a SSH Public Key.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    import * as std from "@pulumi/std";
    
    const example = new azure.compute.SshPublicKey("example", {
        name: "example",
        resourceGroupName: "example",
        location: "West Europe",
        publicKey: std.file({
            input: "~/.ssh/id_rsa.pub",
        }).then(invoke => invoke.result),
    });
    
    import pulumi
    import pulumi_azure as azure
    import pulumi_std as std
    
    example = azure.compute.SshPublicKey("example",
        name="example",
        resource_group_name="example",
        location="West Europe",
        public_key=std.file(input="~/.ssh/id_rsa.pub").result)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/compute"
    	"github.com/pulumi/pulumi-std/sdk/go/std"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		invokeFile, err := std.File(ctx, &std.FileArgs{
    			Input: "~/.ssh/id_rsa.pub",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewSshPublicKey(ctx, "example", &compute.SshPublicKeyArgs{
    			Name:              pulumi.String("example"),
    			ResourceGroupName: pulumi.String("example"),
    			Location:          pulumi.String("West Europe"),
    			PublicKey:         invokeFile.Result,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Azure = Pulumi.Azure;
    using Std = Pulumi.Std;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Azure.Compute.SshPublicKey("example", new()
        {
            Name = "example",
            ResourceGroupName = "example",
            Location = "West Europe",
            PublicKey = Std.File.Invoke(new()
            {
                Input = "~/.ssh/id_rsa.pub",
            }).Apply(invoke => invoke.Result),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azure.compute.SshPublicKey;
    import com.pulumi.azure.compute.SshPublicKeyArgs;
    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 example = new SshPublicKey("example", SshPublicKeyArgs.builder()
                .name("example")
                .resourceGroupName("example")
                .location("West Europe")
                .publicKey(StdFunctions.file(FileArgs.builder()
                    .input("~/.ssh/id_rsa.pub")
                    .build()).result())
                .build());
    
        }
    }
    
    resources:
      example:
        type: azure:compute:SshPublicKey
        properties:
          name: example
          resourceGroupName: example
          location: West Europe
          publicKey:
            fn::invoke:
              Function: std:file
              Arguments:
                input: ~/.ssh/id_rsa.pub
              Return: result
    

    Create SshPublicKey Resource

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

    Constructor syntax

    new SshPublicKey(name: string, args: SshPublicKeyArgs, opts?: CustomResourceOptions);
    @overload
    def SshPublicKey(resource_name: str,
                     args: SshPublicKeyArgs,
                     opts: Optional[ResourceOptions] = None)
    
    @overload
    def SshPublicKey(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     public_key: Optional[str] = None,
                     resource_group_name: Optional[str] = None,
                     location: Optional[str] = None,
                     name: Optional[str] = None,
                     tags: Optional[Mapping[str, str]] = None)
    func NewSshPublicKey(ctx *Context, name string, args SshPublicKeyArgs, opts ...ResourceOption) (*SshPublicKey, error)
    public SshPublicKey(string name, SshPublicKeyArgs args, CustomResourceOptions? opts = null)
    public SshPublicKey(String name, SshPublicKeyArgs args)
    public SshPublicKey(String name, SshPublicKeyArgs args, CustomResourceOptions options)
    
    type: azure:compute:SshPublicKey
    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 SshPublicKeyArgs
    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 SshPublicKeyArgs
    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 SshPublicKeyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SshPublicKeyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SshPublicKeyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var sshPublicKeyResource = new Azure.Compute.SshPublicKey("sshPublicKeyResource", new()
    {
        PublicKey = "string",
        ResourceGroupName = "string",
        Location = "string",
        Name = "string",
        Tags = 
        {
            { "string", "string" },
        },
    });
    
    example, err := compute.NewSshPublicKey(ctx, "sshPublicKeyResource", &compute.SshPublicKeyArgs{
    	PublicKey:         pulumi.String("string"),
    	ResourceGroupName: pulumi.String("string"),
    	Location:          pulumi.String("string"),
    	Name:              pulumi.String("string"),
    	Tags: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    })
    
    var sshPublicKeyResource = new SshPublicKey("sshPublicKeyResource", SshPublicKeyArgs.builder()
        .publicKey("string")
        .resourceGroupName("string")
        .location("string")
        .name("string")
        .tags(Map.of("string", "string"))
        .build());
    
    ssh_public_key_resource = azure.compute.SshPublicKey("sshPublicKeyResource",
        public_key="string",
        resource_group_name="string",
        location="string",
        name="string",
        tags={
            "string": "string",
        })
    
    const sshPublicKeyResource = new azure.compute.SshPublicKey("sshPublicKeyResource", {
        publicKey: "string",
        resourceGroupName: "string",
        location: "string",
        name: "string",
        tags: {
            string: "string",
        },
    });
    
    type: azure:compute:SshPublicKey
    properties:
        location: string
        name: string
        publicKey: string
        resourceGroupName: string
        tags:
            string: string
    

    SshPublicKey Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The SshPublicKey resource accepts the following input properties:

    PublicKey string
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    ResourceGroupName string
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    Location string
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    Name string
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    Tags Dictionary<string, string>
    A mapping of tags which should be assigned to the SSH Public Key.
    PublicKey string
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    ResourceGroupName string
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    Location string
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    Name string
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    Tags map[string]string
    A mapping of tags which should be assigned to the SSH Public Key.
    publicKey String
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    resourceGroupName String
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    location String
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    name String
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    tags Map<String,String>
    A mapping of tags which should be assigned to the SSH Public Key.
    publicKey string
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    resourceGroupName string
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    location string
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    name string
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    tags {[key: string]: string}
    A mapping of tags which should be assigned to the SSH Public Key.
    public_key str
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    resource_group_name str
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    location str
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    name str
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    tags Mapping[str, str]
    A mapping of tags which should be assigned to the SSH Public Key.
    publicKey String
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    resourceGroupName String
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    location String
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    name String
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    tags Map<String>
    A mapping of tags which should be assigned to the SSH Public Key.

    Outputs

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

    Get an existing SshPublicKey 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?: SshPublicKeyState, opts?: CustomResourceOptions): SshPublicKey
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            location: Optional[str] = None,
            name: Optional[str] = None,
            public_key: Optional[str] = None,
            resource_group_name: Optional[str] = None,
            tags: Optional[Mapping[str, str]] = None) -> SshPublicKey
    func GetSshPublicKey(ctx *Context, name string, id IDInput, state *SshPublicKeyState, opts ...ResourceOption) (*SshPublicKey, error)
    public static SshPublicKey Get(string name, Input<string> id, SshPublicKeyState? state, CustomResourceOptions? opts = null)
    public static SshPublicKey get(String name, Output<String> id, SshPublicKeyState 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.
    The following state arguments are supported:
    Location string
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    Name string
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    PublicKey string
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    ResourceGroupName string
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    Tags Dictionary<string, string>
    A mapping of tags which should be assigned to the SSH Public Key.
    Location string
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    Name string
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    PublicKey string
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    ResourceGroupName string
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    Tags map[string]string
    A mapping of tags which should be assigned to the SSH Public Key.
    location String
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    name String
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    publicKey String
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    resourceGroupName String
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    tags Map<String,String>
    A mapping of tags which should be assigned to the SSH Public Key.
    location string
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    name string
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    publicKey string
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    resourceGroupName string
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    tags {[key: string]: string}
    A mapping of tags which should be assigned to the SSH Public Key.
    location str
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    name str
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    public_key str
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    resource_group_name str
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    tags Mapping[str, str]
    A mapping of tags which should be assigned to the SSH Public Key.
    location String
    The Azure Region where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    name String
    The name which should be used for this SSH Public Key. Changing this forces a new SSH Public Key to be created.
    publicKey String
    SSH public key used to authenticate to a virtual machine through ssh. the provided public key needs to be at least 2048-bit and in ssh-rsa format.
    resourceGroupName String
    The name of the Resource Group where the SSH Public Key should exist. Changing this forces a new SSH Public Key to be created.
    tags Map<String>
    A mapping of tags which should be assigned to the SSH Public Key.

    Import

    SSH Public Keys can be imported using the resource id, e.g.

    $ pulumi import azure:compute/sshPublicKey:SshPublicKey example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Compute/sshPublicKeys/mySshPublicKeyName1
    

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

    Package Details

    Repository
    Azure Classic pulumi/pulumi-azure
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azurerm Terraform Provider.
    azure logo

    We recommend using Azure Native.

    Azure Classic v5.80.0 published on Monday, Jun 10, 2024 by Pulumi