Container for the parameters to the PutConfigRule operation. Adds or updates an AWS Config rule for evaluating whether your AWS resources comply with your desired configurations.

You can use this action for custom Config rules and AWS managed Config rules. A custom Config rule is a rule that you develop and maintain. An AWS managed Config rule is a customizable, predefined rule that AWS Config provides.

If you are adding a new custom Config rule, you must first create the AWS Lambda function that the rule invokes to evaluate your resources. When you use the PutConfigRule action to add the rule to AWS Config, you must specify the Amazon Resource Name (ARN) that AWS Lambda assigns to the function. Specify the ARN for the SourceIdentifier key. This key is part of the Source object, which is part of the ConfigRule object.

If you are adding a new AWS managed Config rule, specify the rule's identifier for the SourceIdentifier key. To reference AWS managed Config rule identifiers, see Using AWS Managed Config Rules.

For any new rule that you add, specify the ConfigRuleName in the ConfigRule object. Do not specify the ConfigRuleArn or the ConfigRuleId. These values are generated by AWS Config for new rules.

If you are updating a rule that you added previously, you can specify the rule by ConfigRuleName, ConfigRuleId, or ConfigRuleArn in the ConfigRule data type that you use in this request.

The maximum number of rules that AWS Config supports is 50.

For more information about requesting a rule limit increase, see AWS Config Limits in the AWS General Reference Guide.

For more information about developing and using AWS Config rules, see Evaluating AWS Resource Configurations with AWS Config in the AWS Config Developer Guide.

Inheritance: AmazonConfigServiceRequest
        /// <summary>
        /// Initiates the asynchronous execution of the PutConfigRule operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutConfigRule operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<PutConfigRuleResponse> PutConfigRuleAsync(PutConfigRuleRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new PutConfigRuleRequestMarshaller();
            var unmarshaller = PutConfigRuleResponseUnmarshaller.Instance;

            return InvokeAsync<PutConfigRuleRequest,PutConfigRuleResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        /// <summary>
        /// Adds or updates an AWS Config rule for evaluating whether your AWS resources comply
        /// with your desired configurations. 
        /// 
        ///  
        /// <para>
        /// You can use this action for customer managed Config rules and AWS managed Config rules.
        /// A customer managed Config rule is a custom rule that you develop and maintain. An
        /// AWS managed Config rule is a customizable, predefined rule that is provided by AWS
        /// Config.
        /// </para>
        ///  
        /// <para>
        /// If you are adding a new customer managed Config rule, you must first create the AWS
        /// Lambda function that the rule invokes to evaluate your resources. When you use the
        /// <code>PutConfigRule</code> action to add the rule to AWS Config, you must specify
        /// the Amazon Resource Name (ARN) that AWS Lambda assigns to the function. Specify the
        /// ARN for the <code>SourceIdentifier</code> key. This key is part of the <code>Source</code>
        /// object, which is part of the <code>ConfigRule</code> object. 
        /// </para>
        ///  
        /// <para>
        /// If you are adding a new AWS managed Config rule, specify the rule's identifier for
        /// the <code>SourceIdentifier</code> key. To reference AWS managed Config rule identifiers,
        /// see <a href="http://docs.aws.amazon.com/config/latest/developerguide/evaluate-config_use-managed-rules.html">Using
        /// AWS Managed Config Rules</a>.
        /// </para>
        ///  
        /// <para>
        /// For any new rule that you add, specify the <code>ConfigRuleName</code> in the <code>ConfigRule</code>
        /// object. Do not specify the <code>ConfigRuleArn</code> or the <code>ConfigRuleId</code>.
        /// These values are generated by AWS Config for new rules.
        /// </para>
        ///  
        /// <para>
        /// If you are updating a rule that you have added previously, specify the rule's <code>ConfigRuleName</code>,
        /// <code>ConfigRuleId</code>, or <code>ConfigRuleArn</code> in the <code>ConfigRule</code>
        /// data type that you use in this request.
        /// </para>
        ///  
        /// <para>
        /// The maximum number of rules that AWS Config supports is 25.
        /// </para>
        ///  
        /// <para>
        /// For more information about developing and using AWS Config rules, see <a href="http://docs.aws.amazon.com/config/latest/developerguide/evaluate-config.html">Evaluating
        /// AWS Resource Configurations with AWS Config</a> in the <i>AWS Config Developer Guide</i>.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the PutConfigRule service method.</param>
        /// 
        /// <returns>The response from the PutConfigRule service method, as returned by ConfigService.</returns>
        /// <exception cref="Amazon.ConfigService.Model.InsufficientPermissionsException">
        /// Indicates one of the following errors:
        /// 
        ///  <ul> <li>The rule cannot be created because the IAM role assigned to AWS Config lacks
        /// permissions to perform the config:Put* action.</li> <li>The AWS Lambda function cannot
        /// be invoked. Check the function ARN, and check the function's permissions.</li> </ul>
        /// </exception>
        /// <exception cref="Amazon.ConfigService.Model.InvalidParameterValueException">
        /// One or more of the specified parameters are invalid. Verify that your parameters are
        /// valid and try again.
        /// </exception>
        /// <exception cref="Amazon.ConfigService.Model.MaxNumberOfConfigRulesExceededException">
        /// Failed to add the AWS Config rule because the account already contains the maximum
        /// number of 25 rules. Consider deleting any deactivated rules before adding new rules.
        /// </exception>
        /// <exception cref="Amazon.ConfigService.Model.ResourceInUseException">
        /// The rule is currently being deleted. Wait for a while and try again.
        /// </exception>
        public PutConfigRuleResponse PutConfigRule(PutConfigRuleRequest request)
        {
            var marshaller = new PutConfigRuleRequestMarshaller();
            var unmarshaller = PutConfigRuleResponseUnmarshaller.Instance;

            return Invoke<PutConfigRuleRequest,PutConfigRuleResponse>(request, marshaller, unmarshaller);
        }
 private Amazon.ConfigService.Model.PutConfigRuleResponse CallAWSServiceOperation(IAmazonConfigService client, Amazon.ConfigService.Model.PutConfigRuleRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Config", "PutConfigRule");
     try
     {
         #if DESKTOP
         return(client.PutConfigRule(request));
         #elif CORECLR
         return(client.PutConfigRuleAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
        /// <summary>
        /// Initiates the asynchronous execution of the PutConfigRule operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutConfigRule operation on AmazonConfigServiceClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndPutConfigRule
        ///         operation.</returns>
        public IAsyncResult BeginPutConfigRule(PutConfigRuleRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new PutConfigRuleRequestMarshaller();
            var unmarshaller = PutConfigRuleResponseUnmarshaller.Instance;

            return BeginInvoke<PutConfigRuleRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.ConfigService.Model.PutConfigRuleRequest();


            // populate ConfigRule
            var requestConfigRuleIsNull = true;

            request.ConfigRule = new Amazon.ConfigService.Model.ConfigRule();
            System.String requestConfigRule_configRule_ConfigRuleArn = null;
            if (cmdletContext.ConfigRule_ConfigRuleArn != null)
            {
                requestConfigRule_configRule_ConfigRuleArn = cmdletContext.ConfigRule_ConfigRuleArn;
            }
            if (requestConfigRule_configRule_ConfigRuleArn != null)
            {
                request.ConfigRule.ConfigRuleArn = requestConfigRule_configRule_ConfigRuleArn;
                requestConfigRuleIsNull          = false;
            }
            System.String requestConfigRule_configRule_ConfigRuleId = null;
            if (cmdletContext.ConfigRule_ConfigRuleId != null)
            {
                requestConfigRule_configRule_ConfigRuleId = cmdletContext.ConfigRule_ConfigRuleId;
            }
            if (requestConfigRule_configRule_ConfigRuleId != null)
            {
                request.ConfigRule.ConfigRuleId = requestConfigRule_configRule_ConfigRuleId;
                requestConfigRuleIsNull         = false;
            }
            System.String requestConfigRule_configRule_ConfigRuleName = null;
            if (cmdletContext.ConfigRule_ConfigRuleName != null)
            {
                requestConfigRule_configRule_ConfigRuleName = cmdletContext.ConfigRule_ConfigRuleName;
            }
            if (requestConfigRule_configRule_ConfigRuleName != null)
            {
                request.ConfigRule.ConfigRuleName = requestConfigRule_configRule_ConfigRuleName;
                requestConfigRuleIsNull           = false;
            }
            Amazon.ConfigService.ConfigRuleState requestConfigRule_configRule_ConfigRuleState = null;
            if (cmdletContext.ConfigRule_ConfigRuleState != null)
            {
                requestConfigRule_configRule_ConfigRuleState = cmdletContext.ConfigRule_ConfigRuleState;
            }
            if (requestConfigRule_configRule_ConfigRuleState != null)
            {
                request.ConfigRule.ConfigRuleState = requestConfigRule_configRule_ConfigRuleState;
                requestConfigRuleIsNull            = false;
            }
            System.String requestConfigRule_configRule_CreatedBy = null;
            if (cmdletContext.ConfigRule_CreatedBy != null)
            {
                requestConfigRule_configRule_CreatedBy = cmdletContext.ConfigRule_CreatedBy;
            }
            if (requestConfigRule_configRule_CreatedBy != null)
            {
                request.ConfigRule.CreatedBy = requestConfigRule_configRule_CreatedBy;
                requestConfigRuleIsNull      = false;
            }
            System.String requestConfigRule_configRule_Description = null;
            if (cmdletContext.ConfigRule_Description != null)
            {
                requestConfigRule_configRule_Description = cmdletContext.ConfigRule_Description;
            }
            if (requestConfigRule_configRule_Description != null)
            {
                request.ConfigRule.Description = requestConfigRule_configRule_Description;
                requestConfigRuleIsNull        = false;
            }
            System.String requestConfigRule_configRule_InputParameter = null;
            if (cmdletContext.ConfigRule_InputParameter != null)
            {
                requestConfigRule_configRule_InputParameter = cmdletContext.ConfigRule_InputParameter;
            }
            if (requestConfigRule_configRule_InputParameter != null)
            {
                request.ConfigRule.InputParameters = requestConfigRule_configRule_InputParameter;
                requestConfigRuleIsNull            = false;
            }
            Amazon.ConfigService.MaximumExecutionFrequency requestConfigRule_configRule_MaximumExecutionFrequency = null;
            if (cmdletContext.ConfigRule_MaximumExecutionFrequency != null)
            {
                requestConfigRule_configRule_MaximumExecutionFrequency = cmdletContext.ConfigRule_MaximumExecutionFrequency;
            }
            if (requestConfigRule_configRule_MaximumExecutionFrequency != null)
            {
                request.ConfigRule.MaximumExecutionFrequency = requestConfigRule_configRule_MaximumExecutionFrequency;
                requestConfigRuleIsNull = false;
            }
            Amazon.ConfigService.Model.Source requestConfigRule_configRule_Source = null;

            // populate Source
            var requestConfigRule_configRule_SourceIsNull = true;

            requestConfigRule_configRule_Source = new Amazon.ConfigService.Model.Source();
            Amazon.ConfigService.Owner requestConfigRule_configRule_Source_source_Owner = null;
            if (cmdletContext.Source_Owner != null)
            {
                requestConfigRule_configRule_Source_source_Owner = cmdletContext.Source_Owner;
            }
            if (requestConfigRule_configRule_Source_source_Owner != null)
            {
                requestConfigRule_configRule_Source.Owner = requestConfigRule_configRule_Source_source_Owner;
                requestConfigRule_configRule_SourceIsNull = false;
            }
            List <Amazon.ConfigService.Model.SourceDetail> requestConfigRule_configRule_Source_source_SourceDetail = null;

            if (cmdletContext.Source_SourceDetail != null)
            {
                requestConfigRule_configRule_Source_source_SourceDetail = cmdletContext.Source_SourceDetail;
            }
            if (requestConfigRule_configRule_Source_source_SourceDetail != null)
            {
                requestConfigRule_configRule_Source.SourceDetails = requestConfigRule_configRule_Source_source_SourceDetail;
                requestConfigRule_configRule_SourceIsNull         = false;
            }
            System.String requestConfigRule_configRule_Source_source_SourceIdentifier = null;
            if (cmdletContext.Source_SourceIdentifier != null)
            {
                requestConfigRule_configRule_Source_source_SourceIdentifier = cmdletContext.Source_SourceIdentifier;
            }
            if (requestConfigRule_configRule_Source_source_SourceIdentifier != null)
            {
                requestConfigRule_configRule_Source.SourceIdentifier = requestConfigRule_configRule_Source_source_SourceIdentifier;
                requestConfigRule_configRule_SourceIsNull            = false;
            }
            // determine if requestConfigRule_configRule_Source should be set to null
            if (requestConfigRule_configRule_SourceIsNull)
            {
                requestConfigRule_configRule_Source = null;
            }
            if (requestConfigRule_configRule_Source != null)
            {
                request.ConfigRule.Source = requestConfigRule_configRule_Source;
                requestConfigRuleIsNull   = false;
            }
            Amazon.ConfigService.Model.Scope requestConfigRule_configRule_Scope = null;

            // populate Scope
            var requestConfigRule_configRule_ScopeIsNull = true;

            requestConfigRule_configRule_Scope = new Amazon.ConfigService.Model.Scope();
            System.String requestConfigRule_configRule_Scope_scope_ComplianceResourceId = null;
            if (cmdletContext.Scope_ComplianceResourceId != null)
            {
                requestConfigRule_configRule_Scope_scope_ComplianceResourceId = cmdletContext.Scope_ComplianceResourceId;
            }
            if (requestConfigRule_configRule_Scope_scope_ComplianceResourceId != null)
            {
                requestConfigRule_configRule_Scope.ComplianceResourceId = requestConfigRule_configRule_Scope_scope_ComplianceResourceId;
                requestConfigRule_configRule_ScopeIsNull = false;
            }
            List <System.String> requestConfigRule_configRule_Scope_scope_ComplianceResourceType = null;

            if (cmdletContext.Scope_ComplianceResourceType != null)
            {
                requestConfigRule_configRule_Scope_scope_ComplianceResourceType = cmdletContext.Scope_ComplianceResourceType;
            }
            if (requestConfigRule_configRule_Scope_scope_ComplianceResourceType != null)
            {
                requestConfigRule_configRule_Scope.ComplianceResourceTypes = requestConfigRule_configRule_Scope_scope_ComplianceResourceType;
                requestConfigRule_configRule_ScopeIsNull = false;
            }
            System.String requestConfigRule_configRule_Scope_scope_TagKey = null;
            if (cmdletContext.Scope_TagKey != null)
            {
                requestConfigRule_configRule_Scope_scope_TagKey = cmdletContext.Scope_TagKey;
            }
            if (requestConfigRule_configRule_Scope_scope_TagKey != null)
            {
                requestConfigRule_configRule_Scope.TagKey = requestConfigRule_configRule_Scope_scope_TagKey;
                requestConfigRule_configRule_ScopeIsNull  = false;
            }
            System.String requestConfigRule_configRule_Scope_scope_TagValue = null;
            if (cmdletContext.Scope_TagValue != null)
            {
                requestConfigRule_configRule_Scope_scope_TagValue = cmdletContext.Scope_TagValue;
            }
            if (requestConfigRule_configRule_Scope_scope_TagValue != null)
            {
                requestConfigRule_configRule_Scope.TagValue = requestConfigRule_configRule_Scope_scope_TagValue;
                requestConfigRule_configRule_ScopeIsNull    = false;
            }
            // determine if requestConfigRule_configRule_Scope should be set to null
            if (requestConfigRule_configRule_ScopeIsNull)
            {
                requestConfigRule_configRule_Scope = null;
            }
            if (requestConfigRule_configRule_Scope != null)
            {
                request.ConfigRule.Scope = requestConfigRule_configRule_Scope;
                requestConfigRuleIsNull  = false;
            }
            // determine if request.ConfigRule should be set to null
            if (requestConfigRuleIsNull)
            {
                request.ConfigRule = null;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }