1. Packages
  2. AWS
  3. API Docs
  4. kms
  5. Ciphertext
AWS v6.75.0 published on Wednesday, Apr 2, 2025 by Pulumi

aws.kms.Ciphertext

Explore with Pulumi AI

The KMS ciphertext resource allows you to encrypt plaintext into ciphertext by using an AWS KMS customer master key. The value returned by this resource is stable across every apply. For a changing ciphertext value each apply, see the aws.kms.Ciphertext data source.

Example Usage

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

const oauthConfig = new aws.kms.Key("oauth_config", {
    description: "oauth config",
    isEnabled: true,
});
const oauth = new aws.kms.Ciphertext("oauth", {
    keyId: oauthConfig.keyId,
    plaintext: `{
  "client_id": "e587dbae22222f55da22",
  "client_secret": "8289575d00000ace55e1815ec13673955721b8a5"
}
`,
});
Copy
import pulumi
import pulumi_aws as aws

oauth_config = aws.kms.Key("oauth_config",
    description="oauth config",
    is_enabled=True)
oauth = aws.kms.Ciphertext("oauth",
    key_id=oauth_config.key_id,
    plaintext="""{
  "client_id": "e587dbae22222f55da22",
  "client_secret": "8289575d00000ace55e1815ec13673955721b8a5"
}
""")
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		oauthConfig, err := kms.NewKey(ctx, "oauth_config", &kms.KeyArgs{
			Description: pulumi.String("oauth config"),
			IsEnabled:   pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		_, err = kms.NewCiphertext(ctx, "oauth", &kms.CiphertextArgs{
			KeyId:     oauthConfig.KeyId,
			Plaintext: pulumi.String("{\n  \"client_id\": \"e587dbae22222f55da22\",\n  \"client_secret\": \"8289575d00000ace55e1815ec13673955721b8a5\"\n}\n"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var oauthConfig = new Aws.Kms.Key("oauth_config", new()
    {
        Description = "oauth config",
        IsEnabled = true,
    });

    var oauth = new Aws.Kms.Ciphertext("oauth", new()
    {
        KeyId = oauthConfig.KeyId,
        Plaintext = @"{
  ""client_id"": ""e587dbae22222f55da22"",
  ""client_secret"": ""8289575d00000ace55e1815ec13673955721b8a5""
}
",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.kms.Key;
import com.pulumi.aws.kms.KeyArgs;
import com.pulumi.aws.kms.Ciphertext;
import com.pulumi.aws.kms.CiphertextArgs;
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 oauthConfig = new Key("oauthConfig", KeyArgs.builder()
            .description("oauth config")
            .isEnabled(true)
            .build());

        var oauth = new Ciphertext("oauth", CiphertextArgs.builder()
            .keyId(oauthConfig.keyId())
            .plaintext("""
{
  "client_id": "e587dbae22222f55da22",
  "client_secret": "8289575d00000ace55e1815ec13673955721b8a5"
}
            """)
            .build());

    }
}
Copy
resources:
  oauthConfig:
    type: aws:kms:Key
    name: oauth_config
    properties:
      description: oauth config
      isEnabled: true
  oauth:
    type: aws:kms:Ciphertext
    properties:
      keyId: ${oauthConfig.keyId}
      plaintext: |
        {
          "client_id": "e587dbae22222f55da22",
          "client_secret": "8289575d00000ace55e1815ec13673955721b8a5"
        }        
Copy

Create Ciphertext Resource

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

Constructor syntax

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

@overload
def Ciphertext(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               key_id: Optional[str] = None,
               plaintext: Optional[str] = None,
               context: Optional[Mapping[str, str]] = None)
func NewCiphertext(ctx *Context, name string, args CiphertextArgs, opts ...ResourceOption) (*Ciphertext, error)
public Ciphertext(string name, CiphertextArgs args, CustomResourceOptions? opts = null)
public Ciphertext(String name, CiphertextArgs args)
public Ciphertext(String name, CiphertextArgs args, CustomResourceOptions options)
type: aws:kms:Ciphertext
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. CiphertextArgs
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. CiphertextArgs
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. CiphertextArgs
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. CiphertextArgs
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. CiphertextArgs
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 ciphertextResource = new Aws.Kms.Ciphertext("ciphertextResource", new()
{
    KeyId = "string",
    Plaintext = "string",
    Context = 
    {
        { "string", "string" },
    },
});
Copy
example, err := kms.NewCiphertext(ctx, "ciphertextResource", &kms.CiphertextArgs{
	KeyId:     pulumi.String("string"),
	Plaintext: pulumi.String("string"),
	Context: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
})
Copy
var ciphertextResource = new Ciphertext("ciphertextResource", CiphertextArgs.builder()
    .keyId("string")
    .plaintext("string")
    .context(Map.of("string", "string"))
    .build());
Copy
ciphertext_resource = aws.kms.Ciphertext("ciphertextResource",
    key_id="string",
    plaintext="string",
    context={
        "string": "string",
    })
Copy
const ciphertextResource = new aws.kms.Ciphertext("ciphertextResource", {
    keyId: "string",
    plaintext: "string",
    context: {
        string: "string",
    },
});
Copy
type: aws:kms:Ciphertext
properties:
    context:
        string: string
    keyId: string
    plaintext: string
Copy

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

KeyId
This property is required.
Changes to this property will trigger replacement.
string
Globally unique key ID for the customer master key.
Plaintext
This property is required.
Changes to this property will trigger replacement.
string
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
Context Changes to this property will trigger replacement. Dictionary<string, string>
An optional mapping that makes up the encryption context.
KeyId
This property is required.
Changes to this property will trigger replacement.
string
Globally unique key ID for the customer master key.
Plaintext
This property is required.
Changes to this property will trigger replacement.
string
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
Context Changes to this property will trigger replacement. map[string]string
An optional mapping that makes up the encryption context.
keyId
This property is required.
Changes to this property will trigger replacement.
String
Globally unique key ID for the customer master key.
plaintext
This property is required.
Changes to this property will trigger replacement.
String
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
context Changes to this property will trigger replacement. Map<String,String>
An optional mapping that makes up the encryption context.
keyId
This property is required.
Changes to this property will trigger replacement.
string
Globally unique key ID for the customer master key.
plaintext
This property is required.
Changes to this property will trigger replacement.
string
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
context Changes to this property will trigger replacement. {[key: string]: string}
An optional mapping that makes up the encryption context.
key_id
This property is required.
Changes to this property will trigger replacement.
str
Globally unique key ID for the customer master key.
plaintext
This property is required.
Changes to this property will trigger replacement.
str
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
context Changes to this property will trigger replacement. Mapping[str, str]
An optional mapping that makes up the encryption context.
keyId
This property is required.
Changes to this property will trigger replacement.
String
Globally unique key ID for the customer master key.
plaintext
This property is required.
Changes to this property will trigger replacement.
String
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
context Changes to this property will trigger replacement. Map<String>
An optional mapping that makes up the encryption context.

Outputs

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

CiphertextBlob string
Base64 encoded ciphertext
Id string
The provider-assigned unique ID for this managed resource.
CiphertextBlob string
Base64 encoded ciphertext
Id string
The provider-assigned unique ID for this managed resource.
ciphertextBlob String
Base64 encoded ciphertext
id String
The provider-assigned unique ID for this managed resource.
ciphertextBlob string
Base64 encoded ciphertext
id string
The provider-assigned unique ID for this managed resource.
ciphertext_blob str
Base64 encoded ciphertext
id str
The provider-assigned unique ID for this managed resource.
ciphertextBlob String
Base64 encoded ciphertext
id String
The provider-assigned unique ID for this managed resource.

Look up Existing Ciphertext Resource

Get an existing Ciphertext 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?: CiphertextState, opts?: CustomResourceOptions): Ciphertext
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        ciphertext_blob: Optional[str] = None,
        context: Optional[Mapping[str, str]] = None,
        key_id: Optional[str] = None,
        plaintext: Optional[str] = None) -> Ciphertext
func GetCiphertext(ctx *Context, name string, id IDInput, state *CiphertextState, opts ...ResourceOption) (*Ciphertext, error)
public static Ciphertext Get(string name, Input<string> id, CiphertextState? state, CustomResourceOptions? opts = null)
public static Ciphertext get(String name, Output<String> id, CiphertextState state, CustomResourceOptions options)
resources:  _:    type: aws:kms:Ciphertext    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:
CiphertextBlob string
Base64 encoded ciphertext
Context Changes to this property will trigger replacement. Dictionary<string, string>
An optional mapping that makes up the encryption context.
KeyId Changes to this property will trigger replacement. string
Globally unique key ID for the customer master key.
Plaintext Changes to this property will trigger replacement. string
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
CiphertextBlob string
Base64 encoded ciphertext
Context Changes to this property will trigger replacement. map[string]string
An optional mapping that makes up the encryption context.
KeyId Changes to this property will trigger replacement. string
Globally unique key ID for the customer master key.
Plaintext Changes to this property will trigger replacement. string
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
ciphertextBlob String
Base64 encoded ciphertext
context Changes to this property will trigger replacement. Map<String,String>
An optional mapping that makes up the encryption context.
keyId Changes to this property will trigger replacement. String
Globally unique key ID for the customer master key.
plaintext Changes to this property will trigger replacement. String
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
ciphertextBlob string
Base64 encoded ciphertext
context Changes to this property will trigger replacement. {[key: string]: string}
An optional mapping that makes up the encryption context.
keyId Changes to this property will trigger replacement. string
Globally unique key ID for the customer master key.
plaintext Changes to this property will trigger replacement. string
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
ciphertext_blob str
Base64 encoded ciphertext
context Changes to this property will trigger replacement. Mapping[str, str]
An optional mapping that makes up the encryption context.
key_id Changes to this property will trigger replacement. str
Globally unique key ID for the customer master key.
plaintext Changes to this property will trigger replacement. str
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
ciphertextBlob String
Base64 encoded ciphertext
context Changes to this property will trigger replacement. Map<String>
An optional mapping that makes up the encryption context.
keyId Changes to this property will trigger replacement. String
Globally unique key ID for the customer master key.
plaintext Changes to this property will trigger replacement. String
Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.