Google Cloud (GCP) Classic

v6.39.0 published on Wednesday, Sep 28, 2022 by Pulumi

getAccountKey

Get service account public key. For more information, see the official documentation and API.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var myaccount = new Gcp.ServiceAccount.Account("myaccount", new()
    {
        AccountId = "dev-foo-account",
    });

    var mykeyKey = new Gcp.ServiceAccount.Key("mykeyKey", new()
    {
        ServiceAccountId = myaccount.Name,
    });

    var mykeyAccountKey = Gcp.ServiceAccount.GetAccountKey.Invoke(new()
    {
        Name = mykeyKey.Name,
        PublicKeyType = "TYPE_X509_PEM_FILE",
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/serviceAccount"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myaccount, err := serviceAccount.NewAccount(ctx, "myaccount", &serviceAccount.AccountArgs{
			AccountId: pulumi.String("dev-foo-account"),
		})
		if err != nil {
			return err
		}
		mykeyKey, err := serviceAccount.NewKey(ctx, "mykeyKey", &serviceAccount.KeyArgs{
			ServiceAccountId: myaccount.Name,
		})
		if err != nil {
			return err
		}
		_ = serviceAccount.GetAccountKeyOutput(ctx, serviceaccount.GetAccountKeyOutputArgs{
			Name:          mykeyKey.Name,
			PublicKeyType: pulumi.String("TYPE_X509_PEM_FILE"),
		}, nil)
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.serviceAccount.Account;
import com.pulumi.gcp.serviceAccount.AccountArgs;
import com.pulumi.gcp.serviceAccount.Key;
import com.pulumi.gcp.serviceAccount.KeyArgs;
import com.pulumi.gcp.serviceAccount.ServiceAccountFunctions;
import com.pulumi.gcp.serviceAccount.inputs.GetAccountKeyArgs;
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 myaccount = new Account("myaccount", AccountArgs.builder()        
            .accountId("dev-foo-account")
            .build());

        var mykeyKey = new Key("mykeyKey", KeyArgs.builder()        
            .serviceAccountId(myaccount.name())
            .build());

        final var mykeyAccountKey = ServiceAccountFunctions.getAccountKey(GetAccountKeyArgs.builder()
            .name(mykeyKey.name())
            .publicKeyType("TYPE_X509_PEM_FILE")
            .build());

    }
}
import pulumi
import pulumi_gcp as gcp

myaccount = gcp.service_account.Account("myaccount", account_id="dev-foo-account")
mykey_key = gcp.service_account.Key("mykeyKey", service_account_id=myaccount.name)
mykey_account_key = gcp.serviceAccount.get_account_key_output(name=mykey_key.name,
    public_key_type="TYPE_X509_PEM_FILE")
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const myaccount = new gcp.serviceaccount.Account("myaccount", {accountId: "dev-foo-account"});
const mykeyKey = new gcp.serviceaccount.Key("mykeyKey", {serviceAccountId: myaccount.name});
const mykeyAccountKey = gcp.serviceAccount.getAccountKeyOutput({
    name: mykeyKey.name,
    publicKeyType: "TYPE_X509_PEM_FILE",
});
resources:
  myaccount:
    type: gcp:serviceAccount:Account
    properties:
      accountId: dev-foo-account
  mykeyKey:
    type: gcp:serviceAccount:Key
    properties:
      serviceAccountId: ${myaccount.name}
variables:
  mykeyAccountKey:
    Fn::Invoke:
      Function: gcp:serviceAccount:getAccountKey
      Arguments:
        name: ${mykeyKey.name}
        publicKeyType: TYPE_X509_PEM_FILE

Using getAccountKey

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getAccountKey(args: GetAccountKeyArgs, opts?: InvokeOptions): Promise<GetAccountKeyResult>
function getAccountKeyOutput(args: GetAccountKeyOutputArgs, opts?: InvokeOptions): Output<GetAccountKeyResult>
def get_account_key(name: Optional[str] = None,
                    project: Optional[str] = None,
                    public_key_type: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetAccountKeyResult
def get_account_key_output(name: Optional[pulumi.Input[str]] = None,
                    project: Optional[pulumi.Input[str]] = None,
                    public_key_type: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetAccountKeyResult]
func GetAccountKey(ctx *Context, args *GetAccountKeyArgs, opts ...InvokeOption) (*GetAccountKeyResult, error)
func GetAccountKeyOutput(ctx *Context, args *GetAccountKeyOutputArgs, opts ...InvokeOption) GetAccountKeyResultOutput

> Note: This function is named GetAccountKey in the Go SDK.

public static class GetAccountKey 
{
    public static Task<GetAccountKeyResult> InvokeAsync(GetAccountKeyArgs args, InvokeOptions? opts = null)
    public static Output<GetAccountKeyResult> Invoke(GetAccountKeyInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetAccountKeyResult> getAccountKey(GetAccountKeyArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: gcp:serviceAccount/getAccountKey:getAccountKey
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Name string

The name of the service account key. This must have format projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{KEYID}, where {ACCOUNT} is the email address or unique id of the service account.

Project string

The ID of the project that the service account will be created in. Defaults to the provider project configuration.

PublicKeyType string

The output format of the public key requested. TYPE_X509_PEM_FILE is the default output format.

Name string

The name of the service account key. This must have format projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{KEYID}, where {ACCOUNT} is the email address or unique id of the service account.

Project string

The ID of the project that the service account will be created in. Defaults to the provider project configuration.

PublicKeyType string

The output format of the public key requested. TYPE_X509_PEM_FILE is the default output format.

name String

The name of the service account key. This must have format projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{KEYID}, where {ACCOUNT} is the email address or unique id of the service account.

project String

The ID of the project that the service account will be created in. Defaults to the provider project configuration.

publicKeyType String

The output format of the public key requested. TYPE_X509_PEM_FILE is the default output format.

name string

The name of the service account key. This must have format projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{KEYID}, where {ACCOUNT} is the email address or unique id of the service account.

project string

The ID of the project that the service account will be created in. Defaults to the provider project configuration.

publicKeyType string

The output format of the public key requested. TYPE_X509_PEM_FILE is the default output format.

name str

The name of the service account key. This must have format projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{KEYID}, where {ACCOUNT} is the email address or unique id of the service account.

project str

The ID of the project that the service account will be created in. Defaults to the provider project configuration.

public_key_type str

The output format of the public key requested. TYPE_X509_PEM_FILE is the default output format.

name String

The name of the service account key. This must have format projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}/keys/{KEYID}, where {ACCOUNT} is the email address or unique id of the service account.

project String

The ID of the project that the service account will be created in. Defaults to the provider project configuration.

publicKeyType String

The output format of the public key requested. TYPE_X509_PEM_FILE is the default output format.

getAccountKey Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

KeyAlgorithm string
Name string
PublicKey string

The public key, base64 encoded

Project string
PublicKeyType string
Id string

The provider-assigned unique ID for this managed resource.

KeyAlgorithm string
Name string
PublicKey string

The public key, base64 encoded

Project string
PublicKeyType string
id String

The provider-assigned unique ID for this managed resource.

keyAlgorithm String
name String
publicKey String

The public key, base64 encoded

project String
publicKeyType String
id string

The provider-assigned unique ID for this managed resource.

keyAlgorithm string
name string
publicKey string

The public key, base64 encoded

project string
publicKeyType string
id str

The provider-assigned unique ID for this managed resource.

key_algorithm str
name str
public_key str

The public key, base64 encoded

project str
public_key_type str
id String

The provider-assigned unique ID for this managed resource.

keyAlgorithm String
name String
publicKey String

The public key, base64 encoded

project String
publicKeyType String

Package Details

Repository
https://github.com/pulumi/pulumi-gcp
License
Apache-2.0
Notes

This Pulumi package is based on the google-beta Terraform Provider.