1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. kms
  5. KeyRing
Google Cloud v8.23.0 published on Monday, Mar 24, 2025 by Pulumi

gcp.kms.KeyRing

Explore with Pulumi AI

A KeyRing is a toplevel logical grouping of CryptoKeys.

Note: KeyRings cannot be deleted from Google Cloud Platform. Destroying a provider-managed KeyRing will remove it from state but will not delete the resource from the project.

To get more information about KeyRing, see:

Example Usage

Kms Key Ring Basic

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const example_keyring = new gcp.kms.KeyRing("example-keyring", {
    name: "keyring-example",
    location: "global",
});
Copy
import pulumi
import pulumi_gcp as gcp

example_keyring = gcp.kms.KeyRing("example-keyring",
    name="keyring-example",
    location="global")
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/kms"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := kms.NewKeyRing(ctx, "example-keyring", &kms.KeyRingArgs{
			Name:     pulumi.String("keyring-example"),
			Location: pulumi.String("global"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var example_keyring = new Gcp.Kms.KeyRing("example-keyring", new()
    {
        Name = "keyring-example",
        Location = "global",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.kms.KeyRing;
import com.pulumi.gcp.kms.KeyRingArgs;
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_keyring = new KeyRing("example-keyring", KeyRingArgs.builder()
            .name("keyring-example")
            .location("global")
            .build());

    }
}
Copy
resources:
  example-keyring:
    type: gcp:kms:KeyRing
    properties:
      name: keyring-example
      location: global
Copy

Create KeyRing Resource

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

Constructor syntax

new KeyRing(name: string, args: KeyRingArgs, opts?: CustomResourceOptions);
@overload
def KeyRing(resource_name: str,
            args: KeyRingArgs,
            opts: Optional[ResourceOptions] = None)

@overload
def KeyRing(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            location: Optional[str] = None,
            name: Optional[str] = None,
            project: Optional[str] = None)
func NewKeyRing(ctx *Context, name string, args KeyRingArgs, opts ...ResourceOption) (*KeyRing, error)
public KeyRing(string name, KeyRingArgs args, CustomResourceOptions? opts = null)
public KeyRing(String name, KeyRingArgs args)
public KeyRing(String name, KeyRingArgs args, CustomResourceOptions options)
type: gcp:kms:KeyRing
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. KeyRingArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. KeyRingArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. KeyRingArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. KeyRingArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. KeyRingArgs
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 keyRingResource = new Gcp.Kms.KeyRing("keyRingResource", new()
{
    Location = "string",
    Name = "string",
    Project = "string",
});
Copy
example, err := kms.NewKeyRing(ctx, "keyRingResource", &kms.KeyRingArgs{
	Location: pulumi.String("string"),
	Name:     pulumi.String("string"),
	Project:  pulumi.String("string"),
})
Copy
var keyRingResource = new KeyRing("keyRingResource", KeyRingArgs.builder()
    .location("string")
    .name("string")
    .project("string")
    .build());
Copy
key_ring_resource = gcp.kms.KeyRing("keyRingResource",
    location="string",
    name="string",
    project="string")
Copy
const keyRingResource = new gcp.kms.KeyRing("keyRingResource", {
    location: "string",
    name: "string",
    project: "string",
});
Copy
type: gcp:kms:KeyRing
properties:
    location: string
    name: string
    project: string
Copy

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

Location
This property is required.
Changes to this property will trigger replacement.
string
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


Name Changes to this property will trigger replacement. string
The resource name for the KeyRing.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Location
This property is required.
Changes to this property will trigger replacement.
string
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


Name Changes to this property will trigger replacement. string
The resource name for the KeyRing.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location
This property is required.
Changes to this property will trigger replacement.
String
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


name Changes to this property will trigger replacement. String
The resource name for the KeyRing.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location
This property is required.
Changes to this property will trigger replacement.
string
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


name Changes to this property will trigger replacement. string
The resource name for the KeyRing.
project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location
This property is required.
Changes to this property will trigger replacement.
str
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


name Changes to this property will trigger replacement. str
The resource name for the KeyRing.
project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location
This property is required.
Changes to this property will trigger replacement.
String
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


name Changes to this property will trigger replacement. String
The resource name for the KeyRing.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Outputs

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

Get an existing KeyRing 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?: KeyRingState, opts?: CustomResourceOptions): KeyRing
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        location: Optional[str] = None,
        name: Optional[str] = None,
        project: Optional[str] = None) -> KeyRing
func GetKeyRing(ctx *Context, name string, id IDInput, state *KeyRingState, opts ...ResourceOption) (*KeyRing, error)
public static KeyRing Get(string name, Input<string> id, KeyRingState? state, CustomResourceOptions? opts = null)
public static KeyRing get(String name, Output<String> id, KeyRingState state, CustomResourceOptions options)
resources:  _:    type: gcp:kms:KeyRing    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 Changes to this property will trigger replacement. string
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


Name Changes to this property will trigger replacement. string
The resource name for the KeyRing.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Location Changes to this property will trigger replacement. string
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


Name Changes to this property will trigger replacement. string
The resource name for the KeyRing.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location Changes to this property will trigger replacement. String
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


name Changes to this property will trigger replacement. String
The resource name for the KeyRing.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location Changes to this property will trigger replacement. string
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


name Changes to this property will trigger replacement. string
The resource name for the KeyRing.
project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location Changes to this property will trigger replacement. str
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


name Changes to this property will trigger replacement. str
The resource name for the KeyRing.
project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
location Changes to this property will trigger replacement. String
The location for the KeyRing. A full list of valid locations can be found by running gcloud kms locations list.


name Changes to this property will trigger replacement. String
The resource name for the KeyRing.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Import

KeyRing can be imported using any of these accepted formats:

  • projects/{{project}}/locations/{{location}}/keyRings/{{name}}

  • {{project}}/{{location}}/{{name}}

  • {{location}}/{{name}}

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

$ pulumi import gcp:kms/keyRing:KeyRing default projects/{{project}}/locations/{{location}}/keyRings/{{name}}
Copy
$ pulumi import gcp:kms/keyRing:KeyRing default {{project}}/{{location}}/{{name}}
Copy
$ pulumi import gcp:kms/keyRing:KeyRing default {{location}}/{{name}}
Copy

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.