Container for the parameters to the CreateAssociation operation. Associates the specified SSM document with the specified instances or targets.

When you associate an SSM document with one or more instances using instance IDs or tags, the SSM agent running on the instance processes the document and configures the instance as specified.

If you associate a document with an instance that already has an associated document, the system throws the AssociationAlreadyExists exception.

Inheritance: AmazonSimpleSystemsManagementRequest
        /// <summary>
        /// Associates the specified SSM document with the specified instances or targets.
        /// 
        ///  
        /// <para>
        /// When you associate an SSM document with one or more instances using instance IDs or
        /// tags, the SSM agent running on the instance processes the document and configures
        /// the instance as specified.
        /// </para>
        ///  
        /// <para>
        /// If you associate a document with an instance that already has an associated document,
        /// the system throws the AssociationAlreadyExists exception.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the CreateAssociation service method.</param>
        /// 
        /// <returns>The response from the CreateAssociation service method, as returned by SimpleSystemsManagement.</returns>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.AssociationAlreadyExistsException">
        /// The specified association already exists.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.AssociationLimitExceededException">
        /// You can have at most 2,000 active associations.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.InternalServerErrorException">
        /// An error occurred on the server side.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidDocumentException">
        /// The specified document does not exist.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidDocumentVersionException">
        /// The document version is not valid or does not exist.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidInstanceIdException">
        /// The following problems can cause this exception:
        /// 
        ///  
        /// <para>
        /// You do not have permission to access the instance.
        /// </para>
        ///  
        /// <para>
        /// The SSM agent is not running. On managed instances and Linux instances, verify that
        /// the SSM agent is running. On EC2 Windows instances, verify that the EC2Config service
        /// is running.
        /// </para>
        ///  
        /// <para>
        /// The SSM agent or EC2Config service is not registered to the SSM endpoint. Try reinstalling
        /// the SSM agent or EC2Config service.
        /// </para>
        ///  
        /// <para>
        /// The instance is not in valid state. Valid states are: Running, Pending, Stopped, Stopping.
        /// Invalid states are: Shutting-down and Terminated.
        /// </para>
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidOutputLocationException">
        /// The output location is not valid or does not exist.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidParametersException">
        /// You must specify values for all required parameters in the SSM document. You can only
        /// supply values to parameters defined in the SSM document.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidScheduleException">
        /// The schedule is invalid. Verify your cron or rate expression and try again.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidTargetException">
        /// The target is not valid or does not exist. It might not be configured for EC2 Systems
        /// Manager or you might not have permission to perform the operation.
        /// </exception>
        /// <exception cref="Amazon.SimpleSystemsManagement.Model.UnsupportedPlatformTypeException">
        /// The document does not support the platform type of the given instance ID(s). For example,
        /// you sent an SSM document for a Windows instance to a Linux instance.
        /// </exception>
        public CreateAssociationResponse CreateAssociation(CreateAssociationRequest request)
        {
            var marshaller = new CreateAssociationRequestMarshaller();
            var unmarshaller = CreateAssociationResponseUnmarshaller.Instance;

            return Invoke<CreateAssociationRequest,CreateAssociationResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateAssociation operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateAssociation operation on AmazonSimpleSystemsManagementClient.</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 EndCreateAssociation
        ///         operation.</returns>
        public IAsyncResult BeginCreateAssociation(CreateAssociationRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new CreateAssociationRequestMarshaller();
            var unmarshaller = CreateAssociationResponseUnmarshaller.Instance;

            return BeginInvoke<CreateAssociationRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 /// <summary>
 /// Associates the specified SSM document with the specified instances or targets.
 /// 
 ///  
 /// <para>
 /// When you associate an SSM document with one or more instances using instance IDs or
 /// tags, the SSM agent running on the instance processes the document and configures
 /// the instance as specified.
 /// </para>
 ///  
 /// <para>
 /// If you associate a document with an instance that already has an associated document,
 /// the system throws the AssociationAlreadyExists exception.
 /// </para>
 /// </summary>
 /// <param name="instanceId">The instance ID.</param>
 /// <param name="name">The name of the SSM document.</param>
 /// 
 /// <returns>The response from the CreateAssociation service method, as returned by SimpleSystemsManagement.</returns>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.AssociationAlreadyExistsException">
 /// The specified association already exists.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.AssociationLimitExceededException">
 /// You can have at most 2,000 active associations.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidDocumentException">
 /// The specified document does not exist.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidDocumentVersionException">
 /// The document version is not valid or does not exist.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidInstanceIdException">
 /// The following problems can cause this exception:
 /// 
 ///  
 /// <para>
 /// You do not have permission to access the instance.
 /// </para>
 ///  
 /// <para>
 /// The SSM agent is not running. On managed instances and Linux instances, verify that
 /// the SSM agent is running. On EC2 Windows instances, verify that the EC2Config service
 /// is running.
 /// </para>
 ///  
 /// <para>
 /// The SSM agent or EC2Config service is not registered to the SSM endpoint. Try reinstalling
 /// the SSM agent or EC2Config service.
 /// </para>
 ///  
 /// <para>
 /// The instance is not in valid state. Valid states are: Running, Pending, Stopped, Stopping.
 /// Invalid states are: Shutting-down and Terminated.
 /// </para>
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidOutputLocationException">
 /// The output location is not valid or does not exist.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidParametersException">
 /// You must specify values for all required parameters in the SSM document. You can only
 /// supply values to parameters defined in the SSM document.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidScheduleException">
 /// The schedule is invalid. Verify your cron or rate expression and try again.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidTargetException">
 /// The target is not valid or does not exist. It might not be configured for EC2 Systems
 /// Manager or you might not have permission to perform the operation.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.UnsupportedPlatformTypeException">
 /// The document does not support the platform type of the given instance ID(s). For example,
 /// you sent an SSM document for a Windows instance to a Linux instance.
 /// </exception>
 public CreateAssociationResponse CreateAssociation(string instanceId, string name)
 {
     var request = new CreateAssociationRequest();
     request.InstanceId = instanceId;
     request.Name = name;
     return CreateAssociation(request);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateAssociation operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateAssociation 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<CreateAssociationResponse> CreateAssociationAsync(CreateAssociationRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CreateAssociationRequestMarshaller();
            var unmarshaller = CreateAssociationResponseUnmarshaller.Instance;

            return InvokeAsync<CreateAssociationRequest,CreateAssociationResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
 /// <summary>
 /// Associates the specified SSM document with the specified instances or targets.
 /// 
 ///  
 /// <para>
 /// When you associate an SSM document with one or more instances using instance IDs or
 /// tags, the SSM agent running on the instance processes the document and configures
 /// the instance as specified.
 /// </para>
 ///  
 /// <para>
 /// If you associate a document with an instance that already has an associated document,
 /// the system throws the AssociationAlreadyExists exception.
 /// </para>
 /// </summary>
 /// <param name="instanceId">The instance ID.</param>
 /// <param name="name">The name of the SSM document.</param>
 /// <param name="cancellationToken">
 ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
 /// </param>
 /// 
 /// <returns>The response from the CreateAssociation service method, as returned by SimpleSystemsManagement.</returns>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.AssociationAlreadyExistsException">
 /// The specified association already exists.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.AssociationLimitExceededException">
 /// You can have at most 2,000 active associations.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidDocumentException">
 /// The specified document does not exist.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidDocumentVersionException">
 /// The document version is not valid or does not exist.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidInstanceIdException">
 /// The following problems can cause this exception:
 /// 
 ///  
 /// <para>
 /// You do not have permission to access the instance.
 /// </para>
 ///  
 /// <para>
 /// The SSM agent is not running. On managed instances and Linux instances, verify that
 /// the SSM agent is running. On EC2 Windows instances, verify that the EC2Config service
 /// is running.
 /// </para>
 ///  
 /// <para>
 /// The SSM agent or EC2Config service is not registered to the SSM endpoint. Try reinstalling
 /// the SSM agent or EC2Config service.
 /// </para>
 ///  
 /// <para>
 /// The instance is not in valid state. Valid states are: Running, Pending, Stopped, Stopping.
 /// Invalid states are: Shutting-down and Terminated.
 /// </para>
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidOutputLocationException">
 /// The output location is not valid or does not exist.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidParametersException">
 /// You must specify values for all required parameters in the SSM document. You can only
 /// supply values to parameters defined in the SSM document.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidScheduleException">
 /// The schedule is invalid. Verify your cron or rate expression and try again.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.InvalidTargetException">
 /// The target is not valid or does not exist. It might not be configured for EC2 Systems
 /// Manager or you might not have permission to perform the operation.
 /// </exception>
 /// <exception cref="Amazon.SimpleSystemsManagement.Model.UnsupportedPlatformTypeException">
 /// The document does not support the platform type of the given instance ID(s). For example,
 /// you sent an SSM document for a Windows instance to a Linux instance.
 /// </exception>
 public Task<CreateAssociationResponse> CreateAssociationAsync(string instanceId, string name, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new CreateAssociationRequest();
     request.InstanceId = instanceId;
     request.Name = name;
     return CreateAssociationAsync(request, cancellationToken);
 }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.SimpleSystemsManagement.Model.CreateAssociationRequest();

            if (cmdletContext.AssociationName != null)
            {
                request.AssociationName = cmdletContext.AssociationName;
            }
            if (cmdletContext.AutomationTargetParameterName != null)
            {
                request.AutomationTargetParameterName = cmdletContext.AutomationTargetParameterName;
            }
            if (cmdletContext.ComplianceSeverity != null)
            {
                request.ComplianceSeverity = cmdletContext.ComplianceSeverity;
            }
            if (cmdletContext.DocumentVersion != null)
            {
                request.DocumentVersion = cmdletContext.DocumentVersion;
            }
            if (cmdletContext.InstanceId != null)
            {
                request.InstanceId = cmdletContext.InstanceId;
            }
            if (cmdletContext.MaxConcurrency != null)
            {
                request.MaxConcurrency = cmdletContext.MaxConcurrency;
            }
            if (cmdletContext.MaxError != null)
            {
                request.MaxErrors = cmdletContext.MaxError;
            }
            if (cmdletContext.Name != null)
            {
                request.Name = cmdletContext.Name;
            }

            // populate OutputLocation
            var requestOutputLocationIsNull = true;

            request.OutputLocation = new Amazon.SimpleSystemsManagement.Model.InstanceAssociationOutputLocation();
            Amazon.SimpleSystemsManagement.Model.S3OutputLocation requestOutputLocation_outputLocation_S3Location = null;

            // populate S3Location
            var requestOutputLocation_outputLocation_S3LocationIsNull = true;

            requestOutputLocation_outputLocation_S3Location = new Amazon.SimpleSystemsManagement.Model.S3OutputLocation();
            System.String requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3BucketName = null;
            if (cmdletContext.S3Location_OutputS3BucketName != null)
            {
                requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3BucketName = cmdletContext.S3Location_OutputS3BucketName;
            }
            if (requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3BucketName != null)
            {
                requestOutputLocation_outputLocation_S3Location.OutputS3BucketName = requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3BucketName;
                requestOutputLocation_outputLocation_S3LocationIsNull = false;
            }
            System.String requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3KeyPrefix = null;
            if (cmdletContext.S3Location_OutputS3KeyPrefix != null)
            {
                requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3KeyPrefix = cmdletContext.S3Location_OutputS3KeyPrefix;
            }
            if (requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3KeyPrefix != null)
            {
                requestOutputLocation_outputLocation_S3Location.OutputS3KeyPrefix = requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3KeyPrefix;
                requestOutputLocation_outputLocation_S3LocationIsNull             = false;
            }
            System.String requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3Region = null;
            if (cmdletContext.S3Location_OutputS3Region != null)
            {
                requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3Region = cmdletContext.S3Location_OutputS3Region;
            }
            if (requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3Region != null)
            {
                requestOutputLocation_outputLocation_S3Location.OutputS3Region = requestOutputLocation_outputLocation_S3Location_s3Location_OutputS3Region;
                requestOutputLocation_outputLocation_S3LocationIsNull          = false;
            }
            // determine if requestOutputLocation_outputLocation_S3Location should be set to null
            if (requestOutputLocation_outputLocation_S3LocationIsNull)
            {
                requestOutputLocation_outputLocation_S3Location = null;
            }
            if (requestOutputLocation_outputLocation_S3Location != null)
            {
                request.OutputLocation.S3Location = requestOutputLocation_outputLocation_S3Location;
                requestOutputLocationIsNull       = false;
            }
            // determine if request.OutputLocation should be set to null
            if (requestOutputLocationIsNull)
            {
                request.OutputLocation = null;
            }
            if (cmdletContext.Parameter != null)
            {
                request.Parameters = cmdletContext.Parameter;
            }
            if (cmdletContext.ScheduleExpression != null)
            {
                request.ScheduleExpression = cmdletContext.ScheduleExpression;
            }
            if (cmdletContext.Target != null)
            {
                request.Targets = cmdletContext.Target;
            }

            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);
        }
Beispiel #7
0
 private Amazon.SimpleSystemsManagement.Model.CreateAssociationResponse CallAWSServiceOperation(IAmazonSimpleSystemsManagement client, Amazon.SimpleSystemsManagement.Model.CreateAssociationRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Systems Manager", "CreateAssociation");
     try
     {
         #if DESKTOP
         return(client.CreateAssociation(request));
         #elif CORECLR
         return(client.CreateAssociationAsync(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;
     }
 }