// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;

namespace Pulumi.AliCloud.Kms
{
    /// <summary>
    /// A kms key can help user to protect data security in the transmission process. For information about Alikms Key and how to use it, see [What is Resource Alikms Key](https://www.alibabacloud.com/help/doc-detail/28947.htm).
    /// 
    /// &gt; **NOTE:** Available in v1.85.0+.
    /// 
    /// ## Example Usage
    /// 
    /// Basic Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using Pulumi;
    /// using AliCloud = Pulumi.AliCloud;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     var key = new AliCloud.Kms.Key("key", new()
    ///     {
    ///         Description = "Hello KMS",
    ///         PendingWindowInDays = 7,
    ///         Status = "Enabled",
    ///     });
    /// 
    /// });
    /// ```
    /// 
    /// ## Import
    /// 
    /// Alikms key can be imported using the id, e.g.
    /// 
    /// ```sh
    ///  $ pulumi import alicloud:kms/key:Key example abc123456
    /// ```
    /// </summary>
    [AliCloudResourceType("alicloud:kms/key:Key")]
    public partial class Key : global::Pulumi.CustomResource
    {
        /// <summary>
        /// The Alicloud Resource Name (ARN) of the key.
        /// * `creation_date` -The date and time when the CMK was created. The time is displayed in UTC.
        /// * `creator` -The creator of the CMK.
        /// * `delete_date` -The scheduled date to delete CMK. The time is displayed in UTC. This value is returned only when the KeyState value is PendingDeletion.
        /// </summary>
        [Output("arn")]
        public Output<string> Arn { get; private set; } = null!;

        /// <summary>
        /// Specifies whether to enable automatic key rotation. Valid values: 
        /// - Enabled
        /// - Disabled (default value)
        /// **NOTE**: If you set the origin parameter to EXTERNAL or the key_spec parameter to an asymmetric CMK type, automatic key rotation is unavailable.
        /// </summary>
        [Output("automaticRotation")]
        public Output<string?> AutomaticRotation { get; private set; } = null!;

        [Output("creationDate")]
        public Output<string> CreationDate { get; private set; } = null!;

        [Output("creator")]
        public Output<string> Creator { get; private set; } = null!;

        [Output("deleteDate")]
        public Output<string> DeleteDate { get; private set; } = null!;

        /// <summary>
        /// Field `deletion_window_in_days` has been deprecated from provider version 1.85.0. New field `pending_window_in_days` instead.
        /// </summary>
        [Output("deletionWindowInDays")]
        public Output<int> DeletionWindowInDays { get; private set; } = null!;

        /// <summary>
        /// The description of the CMK. The description can be 0 to 8,192 characters in length.
        /// </summary>
        [Output("description")]
        public Output<string?> Description { get; private set; } = null!;

        /// <summary>
        /// The instance ID of the exclusive KMS instance.
        /// </summary>
        [Output("dkmsInstanceId")]
        public Output<string?> DkmsInstanceId { get; private set; } = null!;

        /// <summary>
        /// Field `is_enabled` has been deprecated from provider version 1.85.0. New field `key_state` instead.
        /// </summary>
        [Output("isEnabled")]
        public Output<bool?> IsEnabled { get; private set; } = null!;

        /// <summary>
        /// The type of the CMK. Valid values: 
        /// "Aliyun_AES_256", "Aliyun_AES_128", "Aliyun_AES_192", "Aliyun_SM4", "RSA_2048", "RSA_3072", "EC_P256", "EC_P256K", "EC_SM2".
        /// Note: The default type of the CMK is Aliyun_AES_256. Only Dedicated KMS supports Aliyun_AES_128 and Aliyun_AES_192.
        /// </summary>
        [Output("keySpec")]
        public Output<string> KeySpec { get; private set; } = null!;

        /// <summary>
        /// Field `key_state` has been deprecated from provider version 1.123.1. New field `status` instead.
        /// </summary>
        [Output("keyState")]
        public Output<string> KeyStatus { get; private set; } = null!;

        /// <summary>
        /// The usage of the CMK. Valid values:
        /// - ENCRYPT/DECRYPT(default value): encrypts or decrypts data.
        /// - SIGN/VERIFY: generates or verifies a digital signature.
        /// </summary>
        [Output("keyUsage")]
        public Output<string?> KeyUsage { get; private set; } = null!;

        /// <summary>
        /// The date and time the last rotation was performed. The time is displayed in UTC.
        /// </summary>
        [Output("lastRotationDate")]
        public Output<string> LastRotationDate { get; private set; } = null!;

        /// <summary>
        /// The time and date the key material for the CMK expires. The time is displayed in UTC. If the value is empty, the key material for the CMK does not expire.
        /// </summary>
        [Output("materialExpireTime")]
        public Output<string> MaterialExpireTime { get; private set; } = null!;

        /// <summary>
        /// The time the next rotation is scheduled for execution.
        /// </summary>
        [Output("nextRotationDate")]
        public Output<string> NextRotationDate { get; private set; } = null!;

        /// <summary>
        /// The source of key material. Valid values: 
        /// - Aliyun_KMS (default value)
        /// - EXTERNAL
        /// **NOTE**: The value of this parameter is case-sensitive. If you set the `key_spec` to an asymmetric CMK type,
        /// you are not allowed to set the `origin` to EXTERNAL. If you set the `origin` to EXTERNAL, you must import key material.
        /// For more information, see [import key material](https://www.alibabacloud.com/help/en/doc-detail/68523.htm).
        /// </summary>
        [Output("origin")]
        public Output<string> Origin { get; private set; } = null!;

        /// <summary>
        /// The number of days before the CMK is deleted. 
        /// During this period, the CMK is in the PendingDeletion state.
        /// After this period ends, you cannot cancel the deletion. Valid values: 7 to 366. Unit: days.
        /// **NOTE:** From version 1.184.0, `pending_window_in_days` can be set to `366`.
        /// </summary>
        [Output("pendingWindowInDays")]
        public Output<int> PendingWindowInDays { get; private set; } = null!;

        /// <summary>
        /// The ID of the current primary key version of the symmetric CMK.
        /// </summary>
        [Output("primaryKeyVersion")]
        public Output<string> PrimaryKeyVersion { get; private set; } = null!;

        /// <summary>
        /// The protection level of the CMK. Valid values:
        /// - SOFTWARE (default value)
        /// - HSM
        /// **NOTE**: The value of this parameter is case-sensitive. Assume that you set this parameter to HSM.
        /// If you set the origin parameter to Aliyun_KMS, the CMK is created in a managed hardware security module (HSM).
        /// If you set the origin parameter to EXTERNA, you can import an external key to the managed HSM.
        /// </summary>
        [Output("protectionLevel")]
        public Output<string?> ProtectionLevel { get; private set; } = null!;

        /// <summary>
        /// The interval for automatic key rotation. Specify the value in the integer[unit] format.
        /// The following units are supported: d (day), h (hour), m (minute), and s (second).
        /// For example, you can use either 7d or 604800s to specify a seven-day interval.
        /// The interval can range from 7 days to 730 days.
        /// **NOTE**: It is Required when `automatic_rotation = "Enabled"`
        /// </summary>
        [Output("rotationInterval")]
        public Output<string?> RotationInterval { get; private set; } = null!;

        /// <summary>
        /// The status of CMK. Valid Values: 
        /// - Disabled
        /// - Enabled (default value)
        /// - PendingDeletion
        /// </summary>
        [Output("status")]
        public Output<string> Status { get; private set; } = null!;


        /// <summary>
        /// Create a Key resource with the given unique name, arguments, and options.
        /// </summary>
        ///
        /// <param name="name">The unique name of the resource</param>
        /// <param name="args">The arguments used to populate this resource's properties</param>
        /// <param name="options">A bag of options that control this resource's behavior</param>
        public Key(string name, KeyArgs? args = null, CustomResourceOptions? options = null)
            : base("alicloud:kms/key:Key", name, args ?? new KeyArgs(), MakeResourceOptions(options, ""))
        {
        }

        private Key(string name, Input<string> id, KeyState? state = null, CustomResourceOptions? options = null)
            : base("alicloud:kms/key:Key", name, state, MakeResourceOptions(options, id))
        {
        }

        private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input<string>? id)
        {
            var defaultOptions = new CustomResourceOptions
            {
                Version = Utilities.Version,
                PluginDownloadURL = "github://api.github.com/rhysmdnz/pulumi-alicloud",
            };
            var merged = CustomResourceOptions.Merge(defaultOptions, options);
            // Override the ID if one was specified for consistency with other language SDKs.
            merged.Id = id ?? merged.Id;
            return merged;
        }
        /// <summary>
        /// Get an existing Key resource's state with the given name, ID, and optional extra
        /// properties used to qualify the lookup.
        /// </summary>
        ///
        /// <param name="name">The unique name of the resulting resource.</param>
        /// <param name="id">The unique provider ID of the resource to lookup.</param>
        /// <param name="state">Any extra arguments used during the lookup.</param>
        /// <param name="options">A bag of options that control this resource's behavior</param>
        public static Key Get(string name, Input<string> id, KeyState? state = null, CustomResourceOptions? options = null)
        {
            return new Key(name, id, state, options);
        }
    }

    public sealed class KeyArgs : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// Specifies whether to enable automatic key rotation. Valid values: 
        /// - Enabled
        /// - Disabled (default value)
        /// **NOTE**: If you set the origin parameter to EXTERNAL or the key_spec parameter to an asymmetric CMK type, automatic key rotation is unavailable.
        /// </summary>
        [Input("automaticRotation")]
        public Input<string>? AutomaticRotation { get; set; }

        /// <summary>
        /// Field `deletion_window_in_days` has been deprecated from provider version 1.85.0. New field `pending_window_in_days` instead.
        /// </summary>
        [Input("deletionWindowInDays")]
        public Input<int>? DeletionWindowInDays { get; set; }

        /// <summary>
        /// The description of the CMK. The description can be 0 to 8,192 characters in length.
        /// </summary>
        [Input("description")]
        public Input<string>? Description { get; set; }

        /// <summary>
        /// The instance ID of the exclusive KMS instance.
        /// </summary>
        [Input("dkmsInstanceId")]
        public Input<string>? DkmsInstanceId { get; set; }

        /// <summary>
        /// Field `is_enabled` has been deprecated from provider version 1.85.0. New field `key_state` instead.
        /// </summary>
        [Input("isEnabled")]
        public Input<bool>? IsEnabled { get; set; }

        /// <summary>
        /// The type of the CMK. Valid values: 
        /// "Aliyun_AES_256", "Aliyun_AES_128", "Aliyun_AES_192", "Aliyun_SM4", "RSA_2048", "RSA_3072", "EC_P256", "EC_P256K", "EC_SM2".
        /// Note: The default type of the CMK is Aliyun_AES_256. Only Dedicated KMS supports Aliyun_AES_128 and Aliyun_AES_192.
        /// </summary>
        [Input("keySpec")]
        public Input<string>? KeySpec { get; set; }

        /// <summary>
        /// Field `key_state` has been deprecated from provider version 1.123.1. New field `status` instead.
        /// </summary>
        [Input("keyState")]
        public Input<string>? KeyStatus { get; set; }

        /// <summary>
        /// The usage of the CMK. Valid values:
        /// - ENCRYPT/DECRYPT(default value): encrypts or decrypts data.
        /// - SIGN/VERIFY: generates or verifies a digital signature.
        /// </summary>
        [Input("keyUsage")]
        public Input<string>? KeyUsage { get; set; }

        /// <summary>
        /// The source of key material. Valid values: 
        /// - Aliyun_KMS (default value)
        /// - EXTERNAL
        /// **NOTE**: The value of this parameter is case-sensitive. If you set the `key_spec` to an asymmetric CMK type,
        /// you are not allowed to set the `origin` to EXTERNAL. If you set the `origin` to EXTERNAL, you must import key material.
        /// For more information, see [import key material](https://www.alibabacloud.com/help/en/doc-detail/68523.htm).
        /// </summary>
        [Input("origin")]
        public Input<string>? Origin { get; set; }

        /// <summary>
        /// The number of days before the CMK is deleted. 
        /// During this period, the CMK is in the PendingDeletion state.
        /// After this period ends, you cannot cancel the deletion. Valid values: 7 to 366. Unit: days.
        /// **NOTE:** From version 1.184.0, `pending_window_in_days` can be set to `366`.
        /// </summary>
        [Input("pendingWindowInDays")]
        public Input<int>? PendingWindowInDays { get; set; }

        /// <summary>
        /// The protection level of the CMK. Valid values:
        /// - SOFTWARE (default value)
        /// - HSM
        /// **NOTE**: The value of this parameter is case-sensitive. Assume that you set this parameter to HSM.
        /// If you set the origin parameter to Aliyun_KMS, the CMK is created in a managed hardware security module (HSM).
        /// If you set the origin parameter to EXTERNA, you can import an external key to the managed HSM.
        /// </summary>
        [Input("protectionLevel")]
        public Input<string>? ProtectionLevel { get; set; }

        /// <summary>
        /// The interval for automatic key rotation. Specify the value in the integer[unit] format.
        /// The following units are supported: d (day), h (hour), m (minute), and s (second).
        /// For example, you can use either 7d or 604800s to specify a seven-day interval.
        /// The interval can range from 7 days to 730 days.
        /// **NOTE**: It is Required when `automatic_rotation = "Enabled"`
        /// </summary>
        [Input("rotationInterval")]
        public Input<string>? RotationInterval { get; set; }

        /// <summary>
        /// The status of CMK. Valid Values: 
        /// - Disabled
        /// - Enabled (default value)
        /// - PendingDeletion
        /// </summary>
        [Input("status")]
        public Input<string>? Status { get; set; }

        public KeyArgs()
        {
        }
        public static new KeyArgs Empty => new KeyArgs();
    }

    public sealed class KeyState : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// The Alicloud Resource Name (ARN) of the key.
        /// * `creation_date` -The date and time when the CMK was created. The time is displayed in UTC.
        /// * `creator` -The creator of the CMK.
        /// * `delete_date` -The scheduled date to delete CMK. The time is displayed in UTC. This value is returned only when the KeyState value is PendingDeletion.
        /// </summary>
        [Input("arn")]
        public Input<string>? Arn { get; set; }

        /// <summary>
        /// Specifies whether to enable automatic key rotation. Valid values: 
        /// - Enabled
        /// - Disabled (default value)
        /// **NOTE**: If you set the origin parameter to EXTERNAL or the key_spec parameter to an asymmetric CMK type, automatic key rotation is unavailable.
        /// </summary>
        [Input("automaticRotation")]
        public Input<string>? AutomaticRotation { get; set; }

        [Input("creationDate")]
        public Input<string>? CreationDate { get; set; }

        [Input("creator")]
        public Input<string>? Creator { get; set; }

        [Input("deleteDate")]
        public Input<string>? DeleteDate { get; set; }

        /// <summary>
        /// Field `deletion_window_in_days` has been deprecated from provider version 1.85.0. New field `pending_window_in_days` instead.
        /// </summary>
        [Input("deletionWindowInDays")]
        public Input<int>? DeletionWindowInDays { get; set; }

        /// <summary>
        /// The description of the CMK. The description can be 0 to 8,192 characters in length.
        /// </summary>
        [Input("description")]
        public Input<string>? Description { get; set; }

        /// <summary>
        /// The instance ID of the exclusive KMS instance.
        /// </summary>
        [Input("dkmsInstanceId")]
        public Input<string>? DkmsInstanceId { get; set; }

        /// <summary>
        /// Field `is_enabled` has been deprecated from provider version 1.85.0. New field `key_state` instead.
        /// </summary>
        [Input("isEnabled")]
        public Input<bool>? IsEnabled { get; set; }

        /// <summary>
        /// The type of the CMK. Valid values: 
        /// "Aliyun_AES_256", "Aliyun_AES_128", "Aliyun_AES_192", "Aliyun_SM4", "RSA_2048", "RSA_3072", "EC_P256", "EC_P256K", "EC_SM2".
        /// Note: The default type of the CMK is Aliyun_AES_256. Only Dedicated KMS supports Aliyun_AES_128 and Aliyun_AES_192.
        /// </summary>
        [Input("keySpec")]
        public Input<string>? KeySpec { get; set; }

        /// <summary>
        /// Field `key_state` has been deprecated from provider version 1.123.1. New field `status` instead.
        /// </summary>
        [Input("keyState")]
        public Input<string>? KeyStatus { get; set; }

        /// <summary>
        /// The usage of the CMK. Valid values:
        /// - ENCRYPT/DECRYPT(default value): encrypts or decrypts data.
        /// - SIGN/VERIFY: generates or verifies a digital signature.
        /// </summary>
        [Input("keyUsage")]
        public Input<string>? KeyUsage { get; set; }

        /// <summary>
        /// The date and time the last rotation was performed. The time is displayed in UTC.
        /// </summary>
        [Input("lastRotationDate")]
        public Input<string>? LastRotationDate { get; set; }

        /// <summary>
        /// The time and date the key material for the CMK expires. The time is displayed in UTC. If the value is empty, the key material for the CMK does not expire.
        /// </summary>
        [Input("materialExpireTime")]
        public Input<string>? MaterialExpireTime { get; set; }

        /// <summary>
        /// The time the next rotation is scheduled for execution.
        /// </summary>
        [Input("nextRotationDate")]
        public Input<string>? NextRotationDate { get; set; }

        /// <summary>
        /// The source of key material. Valid values: 
        /// - Aliyun_KMS (default value)
        /// - EXTERNAL
        /// **NOTE**: The value of this parameter is case-sensitive. If you set the `key_spec` to an asymmetric CMK type,
        /// you are not allowed to set the `origin` to EXTERNAL. If you set the `origin` to EXTERNAL, you must import key material.
        /// For more information, see [import key material](https://www.alibabacloud.com/help/en/doc-detail/68523.htm).
        /// </summary>
        [Input("origin")]
        public Input<string>? Origin { get; set; }

        /// <summary>
        /// The number of days before the CMK is deleted. 
        /// During this period, the CMK is in the PendingDeletion state.
        /// After this period ends, you cannot cancel the deletion. Valid values: 7 to 366. Unit: days.
        /// **NOTE:** From version 1.184.0, `pending_window_in_days` can be set to `366`.
        /// </summary>
        [Input("pendingWindowInDays")]
        public Input<int>? PendingWindowInDays { get; set; }

        /// <summary>
        /// The ID of the current primary key version of the symmetric CMK.
        /// </summary>
        [Input("primaryKeyVersion")]
        public Input<string>? PrimaryKeyVersion { get; set; }

        /// <summary>
        /// The protection level of the CMK. Valid values:
        /// - SOFTWARE (default value)
        /// - HSM
        /// **NOTE**: The value of this parameter is case-sensitive. Assume that you set this parameter to HSM.
        /// If you set the origin parameter to Aliyun_KMS, the CMK is created in a managed hardware security module (HSM).
        /// If you set the origin parameter to EXTERNA, you can import an external key to the managed HSM.
        /// </summary>
        [Input("protectionLevel")]
        public Input<string>? ProtectionLevel { get; set; }

        /// <summary>
        /// The interval for automatic key rotation. Specify the value in the integer[unit] format.
        /// The following units are supported: d (day), h (hour), m (minute), and s (second).
        /// For example, you can use either 7d or 604800s to specify a seven-day interval.
        /// The interval can range from 7 days to 730 days.
        /// **NOTE**: It is Required when `automatic_rotation = "Enabled"`
        /// </summary>
        [Input("rotationInterval")]
        public Input<string>? RotationInterval { get; set; }

        /// <summary>
        /// The status of CMK. Valid Values: 
        /// - Disabled
        /// - Enabled (default value)
        /// - PendingDeletion
        /// </summary>
        [Input("status")]
        public Input<string>? Status { get; set; }

        public KeyState()
        {
        }
        public static new KeyState Empty => new KeyState();
    }
}
