1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. oslogin
  5. SshPublicKey
Google Cloud Classic v7.19.0 published on Thursday, Apr 18, 2024 by Pulumi

gcp.oslogin.SshPublicKey

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.19.0 published on Thursday, Apr 18, 2024 by Pulumi

    The SSH public key information associated with a Google account.

    To get more information about SSHPublicKey, see:

    Example Usage

    Os Login Ssh Key Basic

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    import * as std from "@pulumi/std";
    
    const me = gcp.organizations.getClientOpenIdUserInfo({});
    const cache = new gcp.oslogin.SshPublicKey("cache", {
        user: me.then(me => me.email),
        key: std.file({
            input: "path/to/id_rsa.pub",
        }).then(invoke => invoke.result),
    });
    
    import pulumi
    import pulumi_gcp as gcp
    import pulumi_std as std
    
    me = gcp.organizations.get_client_open_id_user_info()
    cache = gcp.oslogin.SshPublicKey("cache",
        user=me.email,
        key=std.file(input="path/to/id_rsa.pub").result)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/oslogin"
    	"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 {
    		me, err := organizations.GetClientOpenIdUserInfo(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		invokeFile, err := std.File(ctx, &std.FileArgs{
    			Input: "path/to/id_rsa.pub",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = oslogin.NewSshPublicKey(ctx, "cache", &oslogin.SshPublicKeyArgs{
    			User: pulumi.String(me.Email),
    			Key:  invokeFile.Result,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    using Std = Pulumi.Std;
    
    return await Deployment.RunAsync(() => 
    {
        var me = Gcp.Organizations.GetClientOpenIdUserInfo.Invoke();
    
        var cache = new Gcp.OsLogin.SshPublicKey("cache", new()
        {
            User = me.Apply(getClientOpenIdUserInfoResult => getClientOpenIdUserInfoResult.Email),
            Key = Std.File.Invoke(new()
            {
                Input = "path/to/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.gcp.organizations.OrganizationsFunctions;
    import com.pulumi.gcp.oslogin.SshPublicKey;
    import com.pulumi.gcp.oslogin.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) {
            final var me = OrganizationsFunctions.getClientOpenIdUserInfo();
    
            var cache = new SshPublicKey("cache", SshPublicKeyArgs.builder()        
                .user(me.applyValue(getClientOpenIdUserInfoResult -> getClientOpenIdUserInfoResult.email()))
                .key(StdFunctions.file(FileArgs.builder()
                    .input("path/to/id_rsa.pub")
                    .build()).result())
                .build());
    
        }
    }
    
    resources:
      cache:
        type: gcp:oslogin:SshPublicKey
        properties:
          user: ${me.email}
          key:
            fn::invoke:
              Function: std:file
              Arguments:
                input: path/to/id_rsa.pub
              Return: result
    variables:
      me:
        fn::invoke:
          Function: gcp:organizations:getClientOpenIdUserInfo
          Arguments: {}
    

    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,
                     key: Optional[str] = None,
                     user: Optional[str] = None,
                     expiration_time_usec: Optional[str] = None,
                     project: Optional[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: gcp:oslogin: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 Gcp.OsLogin.SshPublicKey("sshPublicKeyResource", new()
    {
        Key = "string",
        User = "string",
        ExpirationTimeUsec = "string",
        Project = "string",
    });
    
    example, err := oslogin.NewSshPublicKey(ctx, "sshPublicKeyResource", &oslogin.SshPublicKeyArgs{
    	Key:                pulumi.String("string"),
    	User:               pulumi.String("string"),
    	ExpirationTimeUsec: pulumi.String("string"),
    	Project:            pulumi.String("string"),
    })
    
    var sshPublicKeyResource = new SshPublicKey("sshPublicKeyResource", SshPublicKeyArgs.builder()        
        .key("string")
        .user("string")
        .expirationTimeUsec("string")
        .project("string")
        .build());
    
    ssh_public_key_resource = gcp.oslogin.SshPublicKey("sshPublicKeyResource",
        key="string",
        user="string",
        expiration_time_usec="string",
        project="string")
    
    const sshPublicKeyResource = new gcp.oslogin.SshPublicKey("sshPublicKeyResource", {
        key: "string",
        user: "string",
        expirationTimeUsec: "string",
        project: "string",
    });
    
    type: gcp:oslogin:SshPublicKey
    properties:
        expirationTimeUsec: string
        key: string
        project: string
        user: 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:

    Key string
    Public key text in SSH format, defined by RFC4253 section 6.6.
    User string
    The user email.


    ExpirationTimeUsec string
    An expiration time in microseconds since epoch.
    Project string
    The project ID of the Google Cloud Platform project.
    Key string
    Public key text in SSH format, defined by RFC4253 section 6.6.
    User string
    The user email.


    ExpirationTimeUsec string
    An expiration time in microseconds since epoch.
    Project string
    The project ID of the Google Cloud Platform project.
    key String
    Public key text in SSH format, defined by RFC4253 section 6.6.
    user String
    The user email.


    expirationTimeUsec String
    An expiration time in microseconds since epoch.
    project String
    The project ID of the Google Cloud Platform project.
    key string
    Public key text in SSH format, defined by RFC4253 section 6.6.
    user string
    The user email.


    expirationTimeUsec string
    An expiration time in microseconds since epoch.
    project string
    The project ID of the Google Cloud Platform project.
    key str
    Public key text in SSH format, defined by RFC4253 section 6.6.
    user str
    The user email.


    expiration_time_usec str
    An expiration time in microseconds since epoch.
    project str
    The project ID of the Google Cloud Platform project.
    key String
    Public key text in SSH format, defined by RFC4253 section 6.6.
    user String
    The user email.


    expirationTimeUsec String
    An expiration time in microseconds since epoch.
    project String
    The project ID of the Google Cloud Platform project.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the SshPublicKey resource produces the following output properties:

    Fingerprint string
    The SHA-256 fingerprint of the SSH public key.
    Id string
    The provider-assigned unique ID for this managed resource.
    Fingerprint string
    The SHA-256 fingerprint of the SSH public key.
    Id string
    The provider-assigned unique ID for this managed resource.
    fingerprint String
    The SHA-256 fingerprint of the SSH public key.
    id String
    The provider-assigned unique ID for this managed resource.
    fingerprint string
    The SHA-256 fingerprint of the SSH public key.
    id string
    The provider-assigned unique ID for this managed resource.
    fingerprint str
    The SHA-256 fingerprint of the SSH public key.
    id str
    The provider-assigned unique ID for this managed resource.
    fingerprint String
    The SHA-256 fingerprint of the SSH public key.
    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,
            expiration_time_usec: Optional[str] = None,
            fingerprint: Optional[str] = None,
            key: Optional[str] = None,
            project: Optional[str] = None,
            user: Optional[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:
    ExpirationTimeUsec string
    An expiration time in microseconds since epoch.
    Fingerprint string
    The SHA-256 fingerprint of the SSH public key.
    Key string
    Public key text in SSH format, defined by RFC4253 section 6.6.
    Project string
    The project ID of the Google Cloud Platform project.
    User string
    The user email.


    ExpirationTimeUsec string
    An expiration time in microseconds since epoch.
    Fingerprint string
    The SHA-256 fingerprint of the SSH public key.
    Key string
    Public key text in SSH format, defined by RFC4253 section 6.6.
    Project string
    The project ID of the Google Cloud Platform project.
    User string
    The user email.


    expirationTimeUsec String
    An expiration time in microseconds since epoch.
    fingerprint String
    The SHA-256 fingerprint of the SSH public key.
    key String
    Public key text in SSH format, defined by RFC4253 section 6.6.
    project String
    The project ID of the Google Cloud Platform project.
    user String
    The user email.


    expirationTimeUsec string
    An expiration time in microseconds since epoch.
    fingerprint string
    The SHA-256 fingerprint of the SSH public key.
    key string
    Public key text in SSH format, defined by RFC4253 section 6.6.
    project string
    The project ID of the Google Cloud Platform project.
    user string
    The user email.


    expiration_time_usec str
    An expiration time in microseconds since epoch.
    fingerprint str
    The SHA-256 fingerprint of the SSH public key.
    key str
    Public key text in SSH format, defined by RFC4253 section 6.6.
    project str
    The project ID of the Google Cloud Platform project.
    user str
    The user email.


    expirationTimeUsec String
    An expiration time in microseconds since epoch.
    fingerprint String
    The SHA-256 fingerprint of the SSH public key.
    key String
    Public key text in SSH format, defined by RFC4253 section 6.6.
    project String
    The project ID of the Google Cloud Platform project.
    user String
    The user email.


    Import

    SSHPublicKey can be imported using any of these accepted formats:

    • users/{{user}}/sshPublicKeys/{{fingerprint}}

    • {{user}}/{{fingerprint}}

    When using the pulumi import command, SSHPublicKey can be imported using one of the formats above. For example:

    $ pulumi import gcp:oslogin/sshPublicKey:SshPublicKey default users/{{user}}/sshPublicKeys/{{fingerprint}}
    
    $ pulumi import gcp:oslogin/sshPublicKey:SshPublicKey default {{user}}/{{fingerprint}}
    

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

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the google-beta Terraform Provider.
    gcp logo
    Google Cloud Classic v7.19.0 published on Thursday, Apr 18, 2024 by Pulumi