alicloud_kms_ciphertext

Updated at:
Copy as MD

Encrypt a given plaintext with KMS. The produced ciphertext stays stable across applies. If the plaintext should be re-encrypted on each apply use the alicloud_kms_ciphertext data source.

-> NOTE: Available since v1.63.0.

-> NOTE: The plaintext_wo and plaintext_wo_version arguments require Terraform v1.11.0 or later. When plaintext_wo is in use, plaintext is empty in the state and plan.

-> NOTE: Using this data provider will allow you to conceal secret data within your resource definitions but does not take care of protecting that data in all Terraform logging and state output. Please take care to secure your secret data beyond just the Terraform configuration.

Example Usage


resource "alicloud_kms_key" "key" {
  description            = "example key"
  status                 = "Enabled"
  pending_window_in_days = 7
}

resource "alicloud_kms_ciphertext" "encrypted" {
  key_id    = alicloud_kms_key.key.id
  plaintext = "example"
}

Need more examples? VIEW MORE EXAMPLES

Argument Reference

The following arguments are supported:

  • plaintext - (Optional, ForceNew) The plaintext to be encrypted which must be encoded in Base64. Exactly one of plaintext and plaintext_wo can be set.
  • plaintext_wo - (Optional, Available since v2.0.0-beta5) The write-only plaintext to be encrypted which must be encoded in Base64. It is only sent to the server when the resource is created and is never stored in the state or plan. It requires Terraform v1.11.0 or later and must be used together with plaintext_wo_version. Exactly one of plaintext and plaintext_wo can be set.
  • plaintext_wo_version - (Optional, ForceNew, Available since v2.0.0-beta5) The version of the write-only plaintext. The write-only plaintext is re-sent to the server only when this argument changes, so changing it recreates the resource with the new plaintext_wo value.
  • key_id - (Required, ForceNew) The globally unique ID of the CMK.
  • encryption_context - (Optional, ForceNew) The Encryption context. If you specify this parameter here, it is also required when you call the Decrypt API operation. For more information, see Encryption Context.

Attributes Reference

The following attributes are exported in addition to the arguments listed above:

  • ciphertext_blob - The ciphertext of the data key encrypted with the primary CMK version.