Associate instances
By instance ID
Section titled “By instance ID”aws ec2 associate-application-status-check \ --application-status-check-id "$ASC_ID" \ --instance-ids "$INSTANCE_ID"Associate and disassociate calls return per-instance success and failure. If a check is already associated, that instance appears in the unsuccessful list with a reason.
By tag
Section titled “By tag”Lab from Create VPC and EC2:
aws ec2 associate-application-status-check \ --application-status-check-id "$ASC_ID" \ --target-tag-associations Key=asc-lab,Value=trueProduction-style example:
aws ec2 associate-application-status-check \ --application-status-check-id asc-0123456789abcdef0 \ --target-tag-associations Key=Environment,Value=productionTag associations are rules. Each rule counts as one association toward quotas, regardless of how many instances currently match.
Auto Scaling group
Section titled “Auto Scaling group”Amazon EC2 Auto Scaling stamps every instance with
aws:autoscaling:groupName. Associate once; new launches pick up the check.
aws ec2 associate-application-status-check \ --application-status-check-id asc-0123456789abcdef0 \ --target-tag-associations Key=aws:autoscaling:groupName,Value=my-asgNo launch template change is required.
Disassociate
Section titled “Disassociate”By instance ID:
aws ec2 disassociate-application-status-check \ --application-status-check-id asc-0123456789abcdef0 \ --instance-ids i-0123456789abcdef0If you associated by tag, remove the tag from the instance (or disassociate
the tag rule). After disassociation, overall status is not-applicable.
Verify in the console and CLI before you include
the check in aggregation. With excluded, the instance Status and alarms
card shows Application status as None associated or included.