Search code examples
javascriptamazon-web-servicesaws-sdkaws-code-deploy

Get out-of-date instances within AWS CodeDeploy


I'm looking for a way to get a list of out-of-date instances for an application deployment group, I've been looking in to using the JavaScriptSDK but can't seem to find a call that will list the instances.

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CodeDeploy.html

All I can seem to find is a way to update out of instances by setting the updateOutdatedInstancesOnly flag when calling createDeployment - https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CodeDeploy.html#createDeployment-property

Does anyone know if it's possible to just get a list of out of date instances?


Solution

  • Unfortunately, there is not an easy way to answer that question exactly with the existing APIs. You configure EC2 tags and AutoScaling Groups in your deployment group, so there are no hard associations between a DG and a host, and the list of hosts in a given deployment group are created dynamically when you create a deployment.

    However, if answering the question "What hosts failed in the last deployment?" gets you want you need, there is a way to get that information.

    1. Call listDeploymentInstances repeatedly until you get all of the instance IDs.
    2. Call batchGetDeploymentInstances repeatedly until you get all of the hosts and check the status of each host to find the failed ones.

    That should at least get information regarding the last deployment.