SecretCiphertext class
Encrypts secret data with Google Cloud KMS and provides access to the ciphertext.
> NOTE: Using this resource will allow you to conceal secret data within your resource definitions, but it does not take care of protecting that data in the logging output, plan output, or state output. Please take care to secure your secret data outside of resource definitions.
To get more information about SecretCiphertext, see:
Example Usage
Kms Secret Ciphertext Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const keyring = new gcp.kms.KeyRing("keyring", {
name: "keyring-example",
location: "global",
});
const cryptokey = new gcp.kms.CryptoKey("cryptokey", {
name: "crypto-key-example",
keyRing: keyring.id,
rotationPeriod: "7776000s",
});
const myPassword = new gcp.kms.SecretCiphertext("my_password", {
cryptoKey: cryptokey.id,
plaintext: "my-secret-password",
});
const instance = new gcp.compute.Instance("instance", {
networkInterfaces: [{
accessConfigs: [{}],
network: "default",
}],
name: "my-instance",
machineType: "e2-medium",
zone: "us-central1-a",
bootDisk: {
initializeParams: {
image: "debian-cloud/debian-11",
},
},
metadata: {
password: myPassword.ciphertext,
},
});
import pulumi
import pulumi_gcp as gcp
keyring = gcp.kms.KeyRing("keyring",
name="keyring-example",
location="global")
cryptokey = gcp.kms.CryptoKey("cryptokey",
name="crypto-key-example",
key_ring=keyring.id,
rotation_period="7776000s")
my_password = gcp.kms.SecretCiphertext("my_password",
crypto_key=cryptokey.id,
plaintext="my-secret-password")
instance = gcp.compute.Instance("instance",
network_interfaces=[{
"access_configs": [{}],
"network": "default",
}],
name="my-instance",
machine_type="e2-medium",
zone="us-central1-a",
boot_disk={
"initialize_params": {
"image": "debian-cloud/debian-11",
},
},
metadata={
"password": my_password.ciphertext,
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var keyring = new Gcp.Kms.KeyRing("keyring", new()
{
Name = "keyring-example",
Location = "global",
});
var cryptokey = new Gcp.Kms.CryptoKey("cryptokey", new()
{
Name = "crypto-key-example",
KeyRing = keyring.Id,
RotationPeriod = "7776000s",
});
var myPassword = new Gcp.Kms.SecretCiphertext("my_password", new()
{
CryptoKey = cryptokey.Id,
Plaintext = "my-secret-password",
});
var instance = new Gcp.Compute.Instance("instance", new()
{
NetworkInterfaces = new[]
{
new Gcp.Compute.Inputs.InstanceNetworkInterfaceArgs
{
AccessConfigs = new[]
{
null,
},
Network = "default",
},
},
Name = "my-instance",
MachineType = "e2-medium",
Zone = "us-central1-a",
BootDisk = new Gcp.Compute.Inputs.InstanceBootDiskArgs
{
InitializeParams = new Gcp.Compute.Inputs.InstanceBootDiskInitializeParamsArgs
{
Image = "debian-cloud/debian-11",
},
},
Metadata =
{
{ "password", myPassword.Ciphertext },
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/kms"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
keyring, err := kms.NewKeyRing(ctx, "keyring", &kms.KeyRingArgs{
Name: pulumi.String("keyring-example"),
Location: pulumi.String("global"),
})
if err != nil {
return err
}
cryptokey, err := kms.NewCryptoKey(ctx, "cryptokey", &kms.CryptoKeyArgs{
Name: pulumi.String("crypto-key-example"),
KeyRing: keyring.ID().ToIDOutput().ToStringOutput(),
RotationPeriod: pulumi.String("7776000s"),
})
if err != nil {
return err
}
myPassword, err := kms.NewSecretCiphertext(ctx, "my_password", &kms.SecretCiphertextArgs{
CryptoKey: cryptokey.ID().ToIDOutput().ToStringOutput(),
Plaintext: pulumi.String("my-secret-password"),
})
if err != nil {
return err
}
_, err = compute.NewInstance(ctx, "instance", &compute.InstanceArgs{
NetworkInterfaces: compute.InstanceNetworkInterfaceArray{
&compute.InstanceNetworkInterfaceArgs{
AccessConfigs: compute.InstanceNetworkInterfaceAccessConfigArray{
&compute.InstanceNetworkInterfaceAccessConfigArgs{},
},
Network: pulumi.String("default"),
},
},
Name: pulumi.String("my-instance"),
MachineType: pulumi.String("e2-medium"),
Zone: pulumi.String("us-central1-a"),
BootDisk: &compute.InstanceBootDiskArgs{
InitializeParams: &compute.InstanceBootDiskInitializeParamsArgs{
Image: pulumi.String("debian-cloud/debian-11"),
},
},
Metadata: pulumi.StringMap{
"password": myPassword.Ciphertext,
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_kms_keyring" "keyring" {
name = "keyring-example"
location = "global"
}
resource "gcp_kms_cryptokey" "cryptokey" {
name = "crypto-key-example"
key_ring = gcp_kms_keyring.keyring.id
rotation_period = "7776000s"
}
resource "gcp_kms_secretciphertext" "my_password" {
crypto_key = gcp_kms_cryptokey.cryptokey.id
plaintext = "my-secret-password"
}
resource "gcp_compute_instance" "instance" {
network_interfaces {
access_configs {
}
network = "default"
}
name = "my-instance"
machine_type = "e2-medium"
zone = "us-central1-a"
boot_disk = {
initialize_params = {
image = "debian-cloud/debian-11"
}
}
metadata = {
"password" = gcp_kms_secretciphertext.my_password.ciphertext
}
}
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 com.pulumi.gcp.kms.CryptoKey;
import com.pulumi.gcp.kms.CryptoKeyArgs;
import com.pulumi.gcp.kms.SecretCiphertext;
import com.pulumi.gcp.kms.SecretCiphertextArgs;
import com.pulumi.gcp.compute.Instance;
import com.pulumi.gcp.compute.InstanceArgs;
import com.pulumi.gcp.compute.inputs.InstanceNetworkInterfaceArgs;
import com.pulumi.gcp.compute.inputs.InstanceNetworkInterfaceAccessConfigArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskInitializeParamsArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 keyring = new KeyRing("keyring", KeyRingArgs.builder()
.name("keyring-example")
.location("global")
.build());
var cryptokey = new CryptoKey("cryptokey", CryptoKeyArgs.builder()
.name("crypto-key-example")
.keyRing(keyring.id())
.rotationPeriod("7776000s")
.build());
var myPassword = new SecretCiphertext("myPassword", SecretCiphertextArgs.builder()
.cryptoKey(cryptokey.id())
.plaintext("my-secret-password")
.build());
var instance = new Instance("instance", InstanceArgs.builder()
.networkInterfaces(InstanceNetworkInterfaceArgs.builder()
.accessConfigs(InstanceNetworkInterfaceAccessConfigArgs.builder()
.build())
.network("default")
.build())
.name("my-instance")
.machineType("e2-medium")
.zone("us-central1-a")
.bootDisk(InstanceBootDiskArgs.builder()
.initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
.image("debian-cloud/debian-11")
.build())
.build())
.metadata(Map.of("password", myPassword.ciphertext()))
.build());
}
}
resources:
keyring:
type: gcp:kms:KeyRing
properties:
name: keyring-example
location: global
cryptokey:
type: gcp:kms:CryptoKey
properties:
name: crypto-key-example
keyRing: ${keyring.id}
rotationPeriod: 7776000s
myPassword:
type: gcp:kms:SecretCiphertext
name: my_password
properties:
cryptoKey: ${cryptokey.id}
plaintext: my-secret-password
instance:
type: gcp:compute:Instance
properties:
networkInterfaces:
- accessConfigs:
- {}
network: default
name: my-instance
machineType: e2-medium
zone: us-central1-a
bootDisk:
initializeParams:
image: debian-cloud/debian-11
metadata:
password: ${myPassword.ciphertext}
Import
This resource does not support import.
Constructors
- SecretCiphertext(String name, {SecretCiphertextArgs? args, CustomResourceOptions? options})
-
Creates a new SecretCiphertext.
nameThe Pulumi resource name.argsArguments used to configure this SecretCiphertext. The set of arguments for SecretCiphertext.optionsResource options controlling this resource's behavior. - SecretCiphertext.reference(String urn)
- Creates a typed reference to an existing SecretCiphertext resource.
Properties
-
additionalAuthenticatedData
↔ Output<
String?> -
The additional authenticated data used for integrity checks during encryption and decryption.
Note: This property is sensitive and will not be displayed in the plan.
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
ciphertext
↔ Output<
String> -
Contains the result of encrypting the provided plaintext, encoded in base64.
latefinal
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
cryptoKey
↔ Output<
String> -
The full name of the CryptoKey that will be used to encrypt the provided plaintext.
Format:
'projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}/cryptoKeys/{{cryptoKey}}'latefinal - hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
plaintext
↔ Output<
String> -
The plaintext to be encrypted.
Note: This property is sensitive and will not be displayed in the plan.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {SecretCiphertextState? state, CustomResourceOptions? options}) → SecretCiphertext -
Gets an existing SecretCiphertext resource's state with the given
nameandid.