gcp.kms.SecretCiphertext
Explore with Pulumi AI
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:
Warning: All arguments including
plaintext
andadditional_authenticated_data
will be stored in the raw state as plain-text.
Example Usage
Kms Secret Ciphertext Basic
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()
{
Location = "global",
});
var cryptokey = new Gcp.Kms.CryptoKey("cryptokey", new()
{
KeyRing = keyring.Id,
RotationPeriod = "100000s",
});
var myPassword = new Gcp.Kms.SecretCiphertext("myPassword", new()
{
CryptoKey = cryptokey.Id,
Plaintext = "my-secret-password",
});
var instance = new Gcp.Compute.Instance("instance", new()
{
MachineType = "e2-medium",
Zone = "us-central1-a",
BootDisk = new Gcp.Compute.Inputs.InstanceBootDiskArgs
{
InitializeParams = new Gcp.Compute.Inputs.InstanceBootDiskInitializeParamsArgs
{
Image = "debian-cloud/debian-11",
},
},
NetworkInterfaces = new[]
{
new Gcp.Compute.Inputs.InstanceNetworkInterfaceArgs
{
Network = "default",
AccessConfigs = new[]
{
null,
},
},
},
Metadata =
{
{ "password", myPassword.Ciphertext },
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/compute"
"github.com/pulumi/pulumi-gcp/sdk/v6/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{
Location: pulumi.String("global"),
})
if err != nil {
return err
}
cryptokey, err := kms.NewCryptoKey(ctx, "cryptokey", &kms.CryptoKeyArgs{
KeyRing: keyring.ID(),
RotationPeriod: pulumi.String("100000s"),
})
if err != nil {
return err
}
myPassword, err := kms.NewSecretCiphertext(ctx, "myPassword", &kms.SecretCiphertextArgs{
CryptoKey: cryptokey.ID(),
Plaintext: pulumi.String("my-secret-password"),
})
if err != nil {
return err
}
_, err = compute.NewInstance(ctx, "instance", &compute.InstanceArgs{
MachineType: pulumi.String("e2-medium"),
Zone: pulumi.String("us-central1-a"),
BootDisk: &compute.InstanceBootDiskArgs{
InitializeParams: &compute.InstanceBootDiskInitializeParamsArgs{
Image: pulumi.String("debian-cloud/debian-11"),
},
},
NetworkInterfaces: compute.InstanceNetworkInterfaceArray{
&compute.InstanceNetworkInterfaceArgs{
Network: pulumi.String("default"),
AccessConfigs: compute.InstanceNetworkInterfaceAccessConfigArray{
nil,
},
},
},
Metadata: pulumi.StringMap{
"password": myPassword.Ciphertext,
},
})
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.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.InstanceBootDiskArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskInitializeParamsArgs;
import com.pulumi.gcp.compute.inputs.InstanceNetworkInterfaceArgs;
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 keyring = new KeyRing("keyring", KeyRingArgs.builder()
.location("global")
.build());
var cryptokey = new CryptoKey("cryptokey", CryptoKeyArgs.builder()
.keyRing(keyring.id())
.rotationPeriod("100000s")
.build());
var myPassword = new SecretCiphertext("myPassword", SecretCiphertextArgs.builder()
.cryptoKey(cryptokey.id())
.plaintext("my-secret-password")
.build());
var instance = new Instance("instance", InstanceArgs.builder()
.machineType("e2-medium")
.zone("us-central1-a")
.bootDisk(InstanceBootDiskArgs.builder()
.initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
.image("debian-cloud/debian-11")
.build())
.build())
.networkInterfaces(InstanceNetworkInterfaceArgs.builder()
.network("default")
.accessConfigs()
.build())
.metadata(Map.of("password", myPassword.ciphertext()))
.build());
}
}
import pulumi
import pulumi_gcp as gcp
keyring = gcp.kms.KeyRing("keyring", location="global")
cryptokey = gcp.kms.CryptoKey("cryptokey",
key_ring=keyring.id,
rotation_period="100000s")
my_password = gcp.kms.SecretCiphertext("myPassword",
crypto_key=cryptokey.id,
plaintext="my-secret-password")
instance = gcp.compute.Instance("instance",
machine_type="e2-medium",
zone="us-central1-a",
boot_disk=gcp.compute.InstanceBootDiskArgs(
initialize_params=gcp.compute.InstanceBootDiskInitializeParamsArgs(
image="debian-cloud/debian-11",
),
),
network_interfaces=[gcp.compute.InstanceNetworkInterfaceArgs(
network="default",
access_configs=[gcp.compute.InstanceNetworkInterfaceAccessConfigArgs()],
)],
metadata={
"password": my_password.ciphertext,
})
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const keyring = new gcp.kms.KeyRing("keyring", {location: "global"});
const cryptokey = new gcp.kms.CryptoKey("cryptokey", {
keyRing: keyring.id,
rotationPeriod: "100000s",
});
const myPassword = new gcp.kms.SecretCiphertext("myPassword", {
cryptoKey: cryptokey.id,
plaintext: "my-secret-password",
});
const instance = new gcp.compute.Instance("instance", {
machineType: "e2-medium",
zone: "us-central1-a",
bootDisk: {
initializeParams: {
image: "debian-cloud/debian-11",
},
},
networkInterfaces: [{
network: "default",
accessConfigs: [{}],
}],
metadata: {
password: myPassword.ciphertext,
},
});
resources:
keyring:
type: gcp:kms:KeyRing
properties:
location: global
cryptokey:
type: gcp:kms:CryptoKey
properties:
keyRing: ${keyring.id}
rotationPeriod: 100000s
myPassword:
type: gcp:kms:SecretCiphertext
properties:
cryptoKey: ${cryptokey.id}
plaintext: my-secret-password
instance:
type: gcp:compute:Instance
properties:
machineType: e2-medium
zone: us-central1-a
bootDisk:
initializeParams:
image: debian-cloud/debian-11
networkInterfaces:
- network: default
accessConfigs:
- {}
metadata:
password: ${myPassword.ciphertext}
Create SecretCiphertext Resource
new SecretCiphertext(name: string, args: SecretCiphertextArgs, opts?: CustomResourceOptions);
@overload
def SecretCiphertext(resource_name: str,
opts: Optional[ResourceOptions] = None,
additional_authenticated_data: Optional[str] = None,
crypto_key: Optional[str] = None,
plaintext: Optional[str] = None)
@overload
def SecretCiphertext(resource_name: str,
args: SecretCiphertextArgs,
opts: Optional[ResourceOptions] = None)
func NewSecretCiphertext(ctx *Context, name string, args SecretCiphertextArgs, opts ...ResourceOption) (*SecretCiphertext, error)
public SecretCiphertext(string name, SecretCiphertextArgs args, CustomResourceOptions? opts = null)
public SecretCiphertext(String name, SecretCiphertextArgs args)
public SecretCiphertext(String name, SecretCiphertextArgs args, CustomResourceOptions options)
type: gcp:kms:SecretCiphertext
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SecretCiphertextArgs
- 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 SecretCiphertextArgs
- 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 SecretCiphertextArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SecretCiphertextArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SecretCiphertextArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
SecretCiphertext 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 SecretCiphertext resource accepts the following input properties:
- Crypto
Key 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}}'
- Plaintext string
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
- Additional
Authenticated stringData 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.
- Crypto
Key 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}}'
- Plaintext string
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
- Additional
Authenticated stringData 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.
- crypto
Key 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}}'
- plaintext String
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
- additional
Authenticated StringData 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.
- crypto
Key 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}}'
- plaintext string
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
- additional
Authenticated stringData 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.
- crypto_
key str The full name of the CryptoKey that will be used to encrypt the provided plaintext. Format:
'projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}/cryptoKeys/{{cryptoKey}}'
- plaintext str
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
- additional_
authenticated_ strdata 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.
- crypto
Key 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}}'
- plaintext String
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
- additional
Authenticated StringData 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.
Outputs
All input properties are implicitly available as output properties. Additionally, the SecretCiphertext resource produces the following output properties:
- Ciphertext string
Contains the result of encrypting the provided plaintext, encoded in base64.
- Id string
The provider-assigned unique ID for this managed resource.
- Ciphertext string
Contains the result of encrypting the provided plaintext, encoded in base64.
- Id string
The provider-assigned unique ID for this managed resource.
- ciphertext String
Contains the result of encrypting the provided plaintext, encoded in base64.
- id String
The provider-assigned unique ID for this managed resource.
- ciphertext string
Contains the result of encrypting the provided plaintext, encoded in base64.
- id string
The provider-assigned unique ID for this managed resource.
- ciphertext str
Contains the result of encrypting the provided plaintext, encoded in base64.
- id str
The provider-assigned unique ID for this managed resource.
- ciphertext String
Contains the result of encrypting the provided plaintext, encoded in base64.
- id String
The provider-assigned unique ID for this managed resource.
Look up Existing SecretCiphertext Resource
Get an existing SecretCiphertext 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?: SecretCiphertextState, opts?: CustomResourceOptions): SecretCiphertext
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
additional_authenticated_data: Optional[str] = None,
ciphertext: Optional[str] = None,
crypto_key: Optional[str] = None,
plaintext: Optional[str] = None) -> SecretCiphertext
func GetSecretCiphertext(ctx *Context, name string, id IDInput, state *SecretCiphertextState, opts ...ResourceOption) (*SecretCiphertext, error)
public static SecretCiphertext Get(string name, Input<string> id, SecretCiphertextState? state, CustomResourceOptions? opts = null)
public static SecretCiphertext get(String name, Output<String> id, SecretCiphertextState 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.
- Additional
Authenticated stringData 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.
- Ciphertext string
Contains the result of encrypting the provided plaintext, encoded in base64.
- Crypto
Key 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}}'
- Plaintext string
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
- Additional
Authenticated stringData 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.
- Ciphertext string
Contains the result of encrypting the provided plaintext, encoded in base64.
- Crypto
Key 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}}'
- Plaintext string
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
- additional
Authenticated StringData 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.
- ciphertext String
Contains the result of encrypting the provided plaintext, encoded in base64.
- crypto
Key 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}}'
- plaintext String
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
- additional
Authenticated stringData 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.
- ciphertext string
Contains the result of encrypting the provided plaintext, encoded in base64.
- crypto
Key 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}}'
- plaintext string
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
- additional_
authenticated_ strdata 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.
- ciphertext str
Contains the result of encrypting the provided plaintext, encoded in base64.
- crypto_
key str The full name of the CryptoKey that will be used to encrypt the provided plaintext. Format:
'projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}/cryptoKeys/{{cryptoKey}}'
- plaintext str
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
- additional
Authenticated StringData 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.
- ciphertext String
Contains the result of encrypting the provided plaintext, encoded in base64.
- crypto
Key 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}}'
- plaintext String
The plaintext to be encrypted. Note: This property is sensitive and will not be displayed in the plan.
Import
This resource does not support import.
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.