

# AssociateApplicationStatusCheck
<a name="API_AssociateApplicationStatusCheck"></a>

Associates an application status check with instances or [tags](https://docs.amazonaws.cn/AWSEC2/latest/UserGuide/Using_Tags.html). Once you create an association, health monitoring automatically begins for the specified instances or for instances that match the specified tags. The following rules apply:
+ You must specify either `TargetTagAssociations` or `InstanceIds`, but not both. Specifying both results in an `InvalidParameterCombination` error.
+ The application status check must already exist and belong to your account.
+ Tag keys must not be blank.
+ Maximum 50 tag associations per application status check.
+ Use `DisassociateApplicationStatusCheck` to remove associations.
+ When you associate [tags](https://docs.amazonaws.cn/AWSEC2/latest/UserGuide/Using_Tags.html), the application status check automatically monitors all current and future instances that have the specified tags.

## Request Parameters
<a name="API_AssociateApplicationStatusCheck_RequestParameters"></a>

The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see [Common Query Parameters](CommonParameters.md).

 **ApplicationStatusCheckId**   
The ID of the application status check to associate.  
Type: String  
Required: Yes

 **ClientToken**   
Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see [Ensuring idempotency](https://docs.amazonaws.cn/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html).  
Type: String  
Required: No

 **DryRun**   
Checks whether you have the required permissions for the operation, without actually making the request, and provides an error response. If you have the required permissions, the error response is `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.  
Type: Boolean  
Required: No

 **InstanceId.N**   
The IDs of the instances to associate with the application status check.  
Type: Array of strings  
Required: No

 **TargetTagAssociation.N**   
The [tags](https://docs.amazonaws.cn/AWSEC2/latest/UserGuide/Using_Tags.html) to associate the application status check with. Each tag is a key-value pair. When you associate tags, the application status check automatically monitors all instances that have the specified tags.  
Type: Array of [CustomTagKeyValueRequestPair](API_CustomTagKeyValueRequestPair.md) objects  
Required: No

## Response Elements
<a name="API_AssociateApplicationStatusCheck_ResponseElements"></a>

The following elements are returned by the service.

 **requestId**   
The ID of the request.  
Type: String

 **successfulResultSet**   
The associations that were successfully created.  
Type: Array of [SuccessfulAssociationResponseObject](API_SuccessfulAssociationResponseObject.md) objects

 **unsuccessfulResultSet**   
The associations that failed to be created.  
Type: Array of [UnsuccessfulAssociationResponseObject](API_UnsuccessfulAssociationResponseObject.md) objects

## Errors
<a name="API_AssociateApplicationStatusCheck_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

## Examples
<a name="API_AssociateApplicationStatusCheck_Examples"></a>

### To associate an application status check with instances
<a name="API_AssociateApplicationStatusCheck_Example_1"></a>

This example associates an application status check with the specified instance.

#### Sample Request
<a name="API_AssociateApplicationStatusCheck_Example_1_Request"></a>

```
https://ec2.amazonaws.com/?Action=AssociateApplicationStatusCheck
&ApplicationStatusCheckId=asc-0123456789abcdef0
&InstanceId.1=i-0123456789abcdef0
&AUTHPARAMS
```

#### Sample Response
<a name="API_AssociateApplicationStatusCheck_Example_1_Response"></a>

```
<AssociateApplicationStatusCheckResult xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
    <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
    <successfulResultSet>
        <item>
            <applicationStatusCheckId>asc-0123456789abcdef0</applicationStatusCheckId>
            <associationType>instance</associationType>
            <associationValue>i-0123456789abcdef0</associationValue>
        </item>
    </successfulResultSet>
</AssociateApplicationStatusCheckResult>
```

### To associate an application status check with tags
<a name="API_AssociateApplicationStatusCheck_Example_2"></a>

The following example associates an application status check with instances that have the specified tag. All current and future instances with this tag are automatically monitored.

#### Sample Request
<a name="API_AssociateApplicationStatusCheck_Example_2_Request"></a>

```
https://ec2.amazonaws.com/?Action=AssociateApplicationStatusCheck
&ApplicationStatusCheckId=asc-0123456789abcdef0
&TargetTagAssociation.1.Key=environment
&TargetTagAssociation.1.Value=production
&AUTHPARAMS
```

#### Sample Response
<a name="API_AssociateApplicationStatusCheck_Example_2_Response"></a>

```
<AssociateApplicationStatusCheckResult xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
    <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
    <successfulResultSet>
        <item>
            <applicationStatusCheckId>asc-0123456789abcdef0</applicationStatusCheckId>
            <associationType>tag</associationType>
            <associationValue>environment=production</associationValue>
        </item>
    </successfulResultSet>
</AssociateApplicationStatusCheckResult>
```

## See Also
<a name="API_AssociateApplicationStatusCheck_SeeAlso"></a>

For more information about using this API in one of the language-specific Amazon SDKs, see the following:
+  [Amazon Command Line Interface V2](https://docs.amazonaws.cn/goto/cli2/ec2-2016-11-15/AssociateApplicationStatusCheck) 
+  [Amazon SDK for .NET V4](https://docs.amazonaws.cn/goto/DotNetSDKV4/ec2-2016-11-15/AssociateApplicationStatusCheck) 
+  [Amazon SDK for C\+\+](https://docs.amazonaws.cn/goto/SdkForCpp/ec2-2016-11-15/AssociateApplicationStatusCheck) 
+  [Amazon SDK for Go v2](https://docs.amazonaws.cn/goto/SdkForGoV2/ec2-2016-11-15/AssociateApplicationStatusCheck) 
+  [Amazon SDK for Java V2](https://docs.amazonaws.cn/goto/SdkForJavaV2/ec2-2016-11-15/AssociateApplicationStatusCheck) 
+  [Amazon SDK for JavaScript V3](https://docs.amazonaws.cn/goto/SdkForJavaScriptV3/ec2-2016-11-15/AssociateApplicationStatusCheck) 
+  [Amazon SDK for Kotlin](https://docs.amazonaws.cn/goto/SdkForKotlin/ec2-2016-11-15/AssociateApplicationStatusCheck) 
+  [Amazon SDK for PHP V3](https://docs.amazonaws.cn/goto/SdkForPHPV3/ec2-2016-11-15/AssociateApplicationStatusCheck) 
+  [Amazon SDK for Python](https://docs.amazonaws.cn/goto/boto3/ec2-2016-11-15/AssociateApplicationStatusCheck) 
+  [Amazon SDK for Ruby V3](https://docs.amazonaws.cn/goto/SdkForRubyV3/ec2-2016-11-15/AssociateApplicationStatusCheck) 