// *** 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.Cfg
{
    /// <summary>
    /// Provides a Config Rule resource.
    /// 
    /// For information about Config Rule and how to use it, see [What is Rule](https://www.alibabacloud.com/help/en/).
    /// 
    /// &gt; **NOTE:** Available in v1.204.0+.
    /// 
    /// ## Example Usage
    /// 
    /// Basic Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using Pulumi;
    /// using AliCloud = Pulumi.AliCloud;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     var @default = new AliCloud.Cfg.Rule("default", new()
    ///     {
    ///         ConfigRuleTriggerTypes = "ConfigurationItemChangeNotification",
    ///         Description = "关联的资源类型下实体资源均已有指定标签，存在没有指定标签的资源则视为“不合规”。",
    ///         ExcludeResourceIdsScope = "test",
    ///         InputParameters = ,
    ///         RegionIdsScope = "cn-hangzhou",
    ///         ResourceGroupIdsScope = "rg-acfmvoh45rhcfly",
    ///         ResourceTypesScopes = new[]
    ///         {
    ///             "ACS::RDS::DBInstance",
    ///         },
    ///         RiskLevel = 1,
    ///         RuleName = "tf-cicd-rule-by-required-tags",
    ///         SourceIdentifier = "required-tags",
    ///         SourceOwner = "ALIYUN",
    ///         TagKeyScope = "test",
    ///         TagValueScope = "test",
    ///     });
    /// 
    /// });
    /// ```
    /// 
    /// ## Import
    /// 
    /// Config Rule can be imported using the id, e.g.
    /// 
    /// ```sh
    ///  $ pulumi import alicloud:cfg/rule:Rule example &lt;id&gt;
    /// ```
    /// </summary>
    [AliCloudResourceType("alicloud:cfg/rule:Rule")]
    public partial class Rule : global::Pulumi.CustomResource
    {
        /// <summary>
        /// The ID of Alicloud account.
        /// </summary>
        [Output("accountId")]
        public Output<int> AccountId { get; private set; } = null!;

        /// <summary>
        /// compliance information.
        /// </summary>
        [Output("compliance")]
        public Output<Outputs.RuleCompliance> Compliance { get; private set; } = null!;

        /// <summary>
        /// Compliance Package ID.
        /// </summary>
        [Output("compliancePackId")]
        public Output<string> CompliancePackId { get; private set; } = null!;

        /// <summary>
        /// config rule arn.
        /// </summary>
        [Output("configRuleArn")]
        public Output<string> ConfigRuleArn { get; private set; } = null!;

        /// <summary>
        /// The ID of the rule.
        /// </summary>
        [Output("configRuleId")]
        public Output<string> ConfigRuleId { get; private set; } = null!;

        /// <summary>
        /// The trigger type of the rule. Valid values:  `ConfigurationItemChangeNotification`: The rule is triggered upon configuration changes. `ScheduledNotification`: The rule is triggered as scheduled.
        /// </summary>
        [Output("configRuleTriggerTypes")]
        public Output<string> ConfigRuleTriggerTypes { get; private set; } = null!;

        /// <summary>
        /// The timestamp when the rule was created.
        /// </summary>
        [Output("createTime")]
        public Output<int> CreateTime { get; private set; } = null!;

        /// <summary>
        /// The description of the rule.
        /// </summary>
        [Output("description")]
        public Output<string?> Description { get; private set; } = null!;

        /// <summary>
        /// The event source of the rule.
        /// </summary>
        [Output("eventSource")]
        public Output<string> EventSource { get; private set; } = null!;

        /// <summary>
        /// The rule monitors excluded resource IDs, multiple of which are separated by commas, only applies to rules created based on managed rules, , custom rule this field is empty.
        /// </summary>
        [Output("excludeResourceIdsScope")]
        public Output<string?> ExcludeResourceIdsScope { get; private set; } = null!;

        /// <summary>
        /// The settings of the input parameters for the rule.See the following `Block InputParameters`.
        /// </summary>
        [Output("inputParameters")]
        public Output<ImmutableDictionary<string, object>?> InputParameters { get; private set; } = null!;

        /// <summary>
        /// The frequency of the compliance evaluations, it is required if the ConfigRuleTriggerTypes value is ScheduledNotification. Valid values:  `One_Hour`, `Three_Hours`, `Six_Hours`, `Twelve_Hours`, `TwentyFour_Hours`.
        /// </summary>
        [Output("maximumExecutionFrequency")]
        public Output<string> MaximumExecutionFrequency { get; private set; } = null!;

        /// <summary>
        /// The timestamp when the rule was last modified.
        /// </summary>
        [Output("modifiedTimestamp")]
        public Output<int> ModifiedTimestamp { get; private set; } = null!;

        /// <summary>
        /// The rule monitors region IDs, separated by commas, only applies to rules created based on managed rules.
        /// </summary>
        [Output("regionIdsScope")]
        public Output<string?> RegionIdsScope { get; private set; } = null!;

        /// <summary>
        /// The rule monitors resource group IDs, separated by commas, only applies to rules created based on managed rules.
        /// </summary>
        [Output("resourceGroupIdsScope")]
        public Output<string?> ResourceGroupIdsScope { get; private set; } = null!;

        /// <summary>
        /// The types of the resources to be evaluated against the rule.
        /// </summary>
        [Output("resourceTypesScopes")]
        public Output<ImmutableArray<string>> ResourceTypesScopes { get; private set; } = null!;

        /// <summary>
        /// The risk level of the resources that are not compliant with the rule. Valid values:  `1`: critical `2`: warning `3`: info
        /// </summary>
        [Output("riskLevel")]
        public Output<int> RiskLevel { get; private set; } = null!;

        /// <summary>
        /// The name of the rule.
        /// </summary>
        [Output("ruleName")]
        public Output<string> RuleName { get; private set; } = null!;

        /// <summary>
        /// Field 'scope_compliance_resource_types' has been deprecated from provider version 1.124.1. New field 'resource_types_scope' instead.
        /// </summary>
        [Output("scopeComplianceResourceTypes")]
        public Output<string> ScopeComplianceResourceTypes { get; private set; } = null!;

        /// <summary>
        /// Field 'source_detail_message_type' has been deprecated from provider version 1.124.1. New field 'config_rule_trigger_types' instead.
        /// </summary>
        [Output("sourceDetailMessageType")]
        public Output<string> SourceDetailMessageType { get; private set; } = null!;

        /// <summary>
        /// The identifier of the rule.  For a managed rule, the value is the name of the managed rule. For a custom rule, the value is the ARN of the custom rule.
        /// </summary>
        [Output("sourceIdentifier")]
        public Output<string> SourceIdentifier { get; private set; } = null!;

        /// <summary>
        /// Field 'source_maximum_execution_frequency' has been deprecated from provider version 1.124.1. New field 'maximum_execution_frequency' instead.
        /// </summary>
        [Output("sourceMaximumExecutionFrequency")]
        public Output<string> SourceMaximumExecutionFrequency { get; private set; } = null!;

        /// <summary>
        /// Specifies whether you or Alibaba Cloud owns and manages the rule. Valid values:  `CUSTOM_FC`: The rule is a custom rule and you own the rule. `ALIYUN`: The rule is a managed rule and Alibaba Cloud owns the rule
        /// </summary>
        [Output("sourceOwner")]
        public Output<string> SourceOwner { get; private set; } = null!;

        /// <summary>
        /// The status of the rule. Valid values: ACTIVE: The rule is monitoring the configurations of target resources. DELETING_RESULTS: The compliance evaluation result returned by the rule is being deleted. EVALUATING: The rule is triggered and is evaluating whether the configurations of target resources are compliant. INACTIVE: The rule is disabled from monitoring the configurations of target resources.
        /// </summary>
        [Output("status")]
        public Output<string> Status { get; private set; } = null!;

        /// <summary>
        /// The rule monitors the tag key, only applies to rules created based on managed rules.
        /// </summary>
        [Output("tagKeyScope")]
        public Output<string?> TagKeyScope { get; private set; } = null!;

        /// <summary>
        /// The rule monitors the tag value, only applies to rules created based on managed rules.
        /// </summary>
        [Output("tagValueScope")]
        public Output<string?> TagValueScope { get; private set; } = null!;


        /// <summary>
        /// Create a Rule 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 Rule(string name, RuleArgs args, CustomResourceOptions? options = null)
            : base("alicloud:cfg/rule:Rule", name, args ?? new RuleArgs(), MakeResourceOptions(options, ""))
        {
        }

        private Rule(string name, Input<string> id, RuleState? state = null, CustomResourceOptions? options = null)
            : base("alicloud:cfg/rule:Rule", 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 Rule 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 Rule Get(string name, Input<string> id, RuleState? state = null, CustomResourceOptions? options = null)
        {
            return new Rule(name, id, state, options);
        }
    }

    public sealed class RuleArgs : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// The trigger type of the rule. Valid values:  `ConfigurationItemChangeNotification`: The rule is triggered upon configuration changes. `ScheduledNotification`: The rule is triggered as scheduled.
        /// </summary>
        [Input("configRuleTriggerTypes")]
        public Input<string>? ConfigRuleTriggerTypes { get; set; }

        /// <summary>
        /// The description of the rule.
        /// </summary>
        [Input("description")]
        public Input<string>? Description { get; set; }

        /// <summary>
        /// The rule monitors excluded resource IDs, multiple of which are separated by commas, only applies to rules created based on managed rules, , custom rule this field is empty.
        /// </summary>
        [Input("excludeResourceIdsScope")]
        public Input<string>? ExcludeResourceIdsScope { get; set; }

        [Input("inputParameters")]
        private InputMap<object>? _inputParameters;

        /// <summary>
        /// The settings of the input parameters for the rule.See the following `Block InputParameters`.
        /// </summary>
        public InputMap<object> InputParameters
        {
            get => _inputParameters ?? (_inputParameters = new InputMap<object>());
            set => _inputParameters = value;
        }

        /// <summary>
        /// The frequency of the compliance evaluations, it is required if the ConfigRuleTriggerTypes value is ScheduledNotification. Valid values:  `One_Hour`, `Three_Hours`, `Six_Hours`, `Twelve_Hours`, `TwentyFour_Hours`.
        /// </summary>
        [Input("maximumExecutionFrequency")]
        public Input<string>? MaximumExecutionFrequency { get; set; }

        /// <summary>
        /// The rule monitors region IDs, separated by commas, only applies to rules created based on managed rules.
        /// </summary>
        [Input("regionIdsScope")]
        public Input<string>? RegionIdsScope { get; set; }

        /// <summary>
        /// The rule monitors resource group IDs, separated by commas, only applies to rules created based on managed rules.
        /// </summary>
        [Input("resourceGroupIdsScope")]
        public Input<string>? ResourceGroupIdsScope { get; set; }

        [Input("resourceTypesScopes")]
        private InputList<string>? _resourceTypesScopes;

        /// <summary>
        /// The types of the resources to be evaluated against the rule.
        /// </summary>
        public InputList<string> ResourceTypesScopes
        {
            get => _resourceTypesScopes ?? (_resourceTypesScopes = new InputList<string>());
            set => _resourceTypesScopes = value;
        }

        /// <summary>
        /// The risk level of the resources that are not compliant with the rule. Valid values:  `1`: critical `2`: warning `3`: info
        /// </summary>
        [Input("riskLevel", required: true)]
        public Input<int> RiskLevel { get; set; } = null!;

        /// <summary>
        /// The name of the rule.
        /// </summary>
        [Input("ruleName", required: true)]
        public Input<string> RuleName { get; set; } = null!;

        /// <summary>
        /// Field 'scope_compliance_resource_types' has been deprecated from provider version 1.124.1. New field 'resource_types_scope' instead.
        /// </summary>
        [Input("scopeComplianceResourceTypes")]
        public Input<string>? ScopeComplianceResourceTypes { get; set; }

        /// <summary>
        /// Field 'source_detail_message_type' has been deprecated from provider version 1.124.1. New field 'config_rule_trigger_types' instead.
        /// </summary>
        [Input("sourceDetailMessageType")]
        public Input<string>? SourceDetailMessageType { get; set; }

        /// <summary>
        /// The identifier of the rule.  For a managed rule, the value is the name of the managed rule. For a custom rule, the value is the ARN of the custom rule.
        /// </summary>
        [Input("sourceIdentifier", required: true)]
        public Input<string> SourceIdentifier { get; set; } = null!;

        /// <summary>
        /// Field 'source_maximum_execution_frequency' has been deprecated from provider version 1.124.1. New field 'maximum_execution_frequency' instead.
        /// </summary>
        [Input("sourceMaximumExecutionFrequency")]
        public Input<string>? SourceMaximumExecutionFrequency { get; set; }

        /// <summary>
        /// Specifies whether you or Alibaba Cloud owns and manages the rule. Valid values:  `CUSTOM_FC`: The rule is a custom rule and you own the rule. `ALIYUN`: The rule is a managed rule and Alibaba Cloud owns the rule
        /// </summary>
        [Input("sourceOwner", required: true)]
        public Input<string> SourceOwner { get; set; } = null!;

        /// <summary>
        /// The status of the rule. Valid values: ACTIVE: The rule is monitoring the configurations of target resources. DELETING_RESULTS: The compliance evaluation result returned by the rule is being deleted. EVALUATING: The rule is triggered and is evaluating whether the configurations of target resources are compliant. INACTIVE: The rule is disabled from monitoring the configurations of target resources.
        /// </summary>
        [Input("status")]
        public Input<string>? Status { get; set; }

        /// <summary>
        /// The rule monitors the tag key, only applies to rules created based on managed rules.
        /// </summary>
        [Input("tagKeyScope")]
        public Input<string>? TagKeyScope { get; set; }

        /// <summary>
        /// The rule monitors the tag value, only applies to rules created based on managed rules.
        /// </summary>
        [Input("tagValueScope")]
        public Input<string>? TagValueScope { get; set; }

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

    public sealed class RuleState : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// The ID of Alicloud account.
        /// </summary>
        [Input("accountId")]
        public Input<int>? AccountId { get; set; }

        /// <summary>
        /// compliance information.
        /// </summary>
        [Input("compliance")]
        public Input<Inputs.RuleComplianceGetArgs>? Compliance { get; set; }

        /// <summary>
        /// Compliance Package ID.
        /// </summary>
        [Input("compliancePackId")]
        public Input<string>? CompliancePackId { get; set; }

        /// <summary>
        /// config rule arn.
        /// </summary>
        [Input("configRuleArn")]
        public Input<string>? ConfigRuleArn { get; set; }

        /// <summary>
        /// The ID of the rule.
        /// </summary>
        [Input("configRuleId")]
        public Input<string>? ConfigRuleId { get; set; }

        /// <summary>
        /// The trigger type of the rule. Valid values:  `ConfigurationItemChangeNotification`: The rule is triggered upon configuration changes. `ScheduledNotification`: The rule is triggered as scheduled.
        /// </summary>
        [Input("configRuleTriggerTypes")]
        public Input<string>? ConfigRuleTriggerTypes { get; set; }

        /// <summary>
        /// The timestamp when the rule was created.
        /// </summary>
        [Input("createTime")]
        public Input<int>? CreateTime { get; set; }

        /// <summary>
        /// The description of the rule.
        /// </summary>
        [Input("description")]
        public Input<string>? Description { get; set; }

        /// <summary>
        /// The event source of the rule.
        /// </summary>
        [Input("eventSource")]
        public Input<string>? EventSource { get; set; }

        /// <summary>
        /// The rule monitors excluded resource IDs, multiple of which are separated by commas, only applies to rules created based on managed rules, , custom rule this field is empty.
        /// </summary>
        [Input("excludeResourceIdsScope")]
        public Input<string>? ExcludeResourceIdsScope { get; set; }

        [Input("inputParameters")]
        private InputMap<object>? _inputParameters;

        /// <summary>
        /// The settings of the input parameters for the rule.See the following `Block InputParameters`.
        /// </summary>
        public InputMap<object> InputParameters
        {
            get => _inputParameters ?? (_inputParameters = new InputMap<object>());
            set => _inputParameters = value;
        }

        /// <summary>
        /// The frequency of the compliance evaluations, it is required if the ConfigRuleTriggerTypes value is ScheduledNotification. Valid values:  `One_Hour`, `Three_Hours`, `Six_Hours`, `Twelve_Hours`, `TwentyFour_Hours`.
        /// </summary>
        [Input("maximumExecutionFrequency")]
        public Input<string>? MaximumExecutionFrequency { get; set; }

        /// <summary>
        /// The timestamp when the rule was last modified.
        /// </summary>
        [Input("modifiedTimestamp")]
        public Input<int>? ModifiedTimestamp { get; set; }

        /// <summary>
        /// The rule monitors region IDs, separated by commas, only applies to rules created based on managed rules.
        /// </summary>
        [Input("regionIdsScope")]
        public Input<string>? RegionIdsScope { get; set; }

        /// <summary>
        /// The rule monitors resource group IDs, separated by commas, only applies to rules created based on managed rules.
        /// </summary>
        [Input("resourceGroupIdsScope")]
        public Input<string>? ResourceGroupIdsScope { get; set; }

        [Input("resourceTypesScopes")]
        private InputList<string>? _resourceTypesScopes;

        /// <summary>
        /// The types of the resources to be evaluated against the rule.
        /// </summary>
        public InputList<string> ResourceTypesScopes
        {
            get => _resourceTypesScopes ?? (_resourceTypesScopes = new InputList<string>());
            set => _resourceTypesScopes = value;
        }

        /// <summary>
        /// The risk level of the resources that are not compliant with the rule. Valid values:  `1`: critical `2`: warning `3`: info
        /// </summary>
        [Input("riskLevel")]
        public Input<int>? RiskLevel { get; set; }

        /// <summary>
        /// The name of the rule.
        /// </summary>
        [Input("ruleName")]
        public Input<string>? RuleName { get; set; }

        /// <summary>
        /// Field 'scope_compliance_resource_types' has been deprecated from provider version 1.124.1. New field 'resource_types_scope' instead.
        /// </summary>
        [Input("scopeComplianceResourceTypes")]
        public Input<string>? ScopeComplianceResourceTypes { get; set; }

        /// <summary>
        /// Field 'source_detail_message_type' has been deprecated from provider version 1.124.1. New field 'config_rule_trigger_types' instead.
        /// </summary>
        [Input("sourceDetailMessageType")]
        public Input<string>? SourceDetailMessageType { get; set; }

        /// <summary>
        /// The identifier of the rule.  For a managed rule, the value is the name of the managed rule. For a custom rule, the value is the ARN of the custom rule.
        /// </summary>
        [Input("sourceIdentifier")]
        public Input<string>? SourceIdentifier { get; set; }

        /// <summary>
        /// Field 'source_maximum_execution_frequency' has been deprecated from provider version 1.124.1. New field 'maximum_execution_frequency' instead.
        /// </summary>
        [Input("sourceMaximumExecutionFrequency")]
        public Input<string>? SourceMaximumExecutionFrequency { get; set; }

        /// <summary>
        /// Specifies whether you or Alibaba Cloud owns and manages the rule. Valid values:  `CUSTOM_FC`: The rule is a custom rule and you own the rule. `ALIYUN`: The rule is a managed rule and Alibaba Cloud owns the rule
        /// </summary>
        [Input("sourceOwner")]
        public Input<string>? SourceOwner { get; set; }

        /// <summary>
        /// The status of the rule. Valid values: ACTIVE: The rule is monitoring the configurations of target resources. DELETING_RESULTS: The compliance evaluation result returned by the rule is being deleted. EVALUATING: The rule is triggered and is evaluating whether the configurations of target resources are compliant. INACTIVE: The rule is disabled from monitoring the configurations of target resources.
        /// </summary>
        [Input("status")]
        public Input<string>? Status { get; set; }

        /// <summary>
        /// The rule monitors the tag key, only applies to rules created based on managed rules.
        /// </summary>
        [Input("tagKeyScope")]
        public Input<string>? TagKeyScope { get; set; }

        /// <summary>
        /// The rule monitors the tag value, only applies to rules created based on managed rules.
        /// </summary>
        [Input("tagValueScope")]
        public Input<string>? TagValueScope { get; set; }

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