azure logo
Azure Classic v5.43.0, May 6 23

azure.compute.SshPublicKey

Explore with Pulumi AI

Manages a SSH Public Key.

Example Usage

using System.Collections.Generic;
using System.IO;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var example = new Azure.Compute.SshPublicKey("example", new()
    {
        ResourceGroupName = "example",
        Location = "West Europe",
        PublicKey = File.ReadAllText("~/.ssh/id_rsa.pub"),
    });

});
package main

import (
	"os"

	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/compute"
	"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 := compute.NewSshPublicKey(ctx, "example", &compute.SshPublicKeyArgs{
			ResourceGroupName: pulumi.String("example"),
			Location:          pulumi.String("West Europe"),
			PublicKey:         readFileOrPanic("~/.ssh/id_rsa.pub"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
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()        
            .resourceGroupName("example")
            .location("West Europe")
            .publicKey(Files.readString(Paths.get("~/.ssh/id_rsa.pub")))
            .build());

    }
}
import pulumi
import pulumi_azure as azure

example = azure.compute.SshPublicKey("example",
    resource_group_name="example",
    location="West Europe",
    public_key=(lambda path: open(path).read())("~/.ssh/id_rsa.pub"))
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
import * as fs from "fs";

const example = new azure.compute.SshPublicKey("example", {
    resourceGroupName: "example",
    location: "West Europe",
    publicKey: fs.readFileSync("~/.ssh/id_rsa.pub"),
});
resources:
  example:
    type: azure:compute:SshPublicKey
    properties:
      resourceGroupName: example
      location: West Europe
      publicKey:
        fn::readFile: ~/.ssh/id_rsa.pub

Create SshPublicKey Resource

new SshPublicKey(name: string, args: SshPublicKeyArgs, opts?: CustomResourceOptions);
@overload
def SshPublicKey(resource_name: 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)
@overload
def SshPublicKey(resource_name: str,
                 args: SshPublicKeyArgs,
                 opts: Optional[ResourceOptions] = 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.

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.

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

Package Details

Repository
Azure Classic pulumi/pulumi-azure
License
Apache-2.0
Notes

This Pulumi package is based on the azurerm Terraform Provider.