Run the following command to cleanup the SSM instances
# Cleanup SSM
aws ssm describe-activations | jq ".ActivationList | .[] | .ActivationId" | xargs -L 1 aws ssm delete-activation --activation-id
aws ssm describe-instance-information | jq ".InstanceInformationList | .[] | .InstanceId" | grep "mi-" | xargs -L 1 aws ssm deregister-managed-instance --instance-id
Run the following command to cleanup ECS resources
# Cleanup ECS resources
aws ecs list-container-instances --cluster $CLUSTER_NAME | jq ".containerInstanceArns | .[]" | xargs -L 1 aws ecs deregister-container-instance --cluster $CLUSTER_NAME --force --container-instance
aws ecs delete-cluster --cluster $CLUSTER_NAME
Run the command to verify the deletion of all the items
# Verify all items deleted are empty
aws ssm describe-activations
aws ssm describe-instance-information
aws ecs list-container-instances --cluster $CLUSTER_NAME
Output
# aws ssm describe-activations
{
"ActivationList": []
}
# aws ssm describe-instance-information
{
"InstanceInformationList": []
}
# aws ecs list-container-instances --cluster $CLUSTER_NAME
{
"containerInstanceArns": []
}
Run the following command to delete the vagrant VM
#Remove vagrant VM
vagrant halt
vagrant destroy