Automating AWS CodeDeploy with Instance Exclusion: Best Practices

Removing an On-Premises Instance from CodeDeploy Deployment Group

Prev Question Next Question

Question

Your team uses AWS CodeDeploy to automate the deployments to several AWS EC2 instances and on-premises instances.

A deployment group is used to define which individual instances are included.

For some testing activities, you need to remove one on-premises instance from the deployment group for two weeks.

During the time, AWS CodeDeploy should not deploy any new revisions to this particular instance.

Which of the following methods is the most appropriate?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer - D.

Option A is incorrect because it is inappropriate to uninstall the CodeDeploy agent or remove the configuration file from the on-premises instance since you only need to suspend the deployments for two weeks.

The correct way is to remove the tag from the instance.

Option B is incorrect because it is unnecessary to deregister the instance from CodeDeploy.

Normally, you deregister an on-premises instance when you are no longer planning to deploy to it.

Option C is incorrect because only one on-premises instance should be removed.

With the new deployment group, all the on-premises instances will be excluded.

Option D is CORRECT because by removing the tag from the instance, any further deployments will not impact the on-premises instance as a deployment group relies on tags to determine which instances are included.

Reference:

https://docs.aws.amazon.com/codedeploy/latest/userguide/on-premises-instances-operations-remove-tags.html, https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-groups-create-in-place.html.

Option A - Use the AWS CLI command aws deploy uninstall to uninstall the CodeDeploy agent and remove the configuration file from the on-premises instance.

This option is not appropriate for the scenario described in the question. Uninstalling the CodeDeploy agent from the on-premises instance would remove it from the deployment group altogether, which is not desired as the question asks to remove the instance from the deployment group only for a specific period of time. Additionally, uninstalling the CodeDeploy agent would prevent any further deployment to this on-premises instance, which is not required for the scenario.

Option B - Use the AWS CLI command aws deploy deregister to deregister the on-premises instance from the AWS CodeDeploy service.

This option is a valid solution to the scenario described in the question. By deregistering the on-premises instance from the AWS CodeDeploy service, the instance is removed from the deployment group temporarily. This would prevent AWS CodeDeploy from deploying new revisions to the particular on-premises instance. Once the testing activities are completed, the on-premises instance can be registered back to the deployment group, and the deployment will resume as normal.

Option C - Create another deployment group with a new tag that is not used by all the on-premises instances. Modify the CodeDeploy application to use this new deployment group.

This option is not an appropriate solution to the scenario described in the question. Creating a new deployment group for a single on-premises instance would add complexity to the deployment process and create additional maintenance overhead. It is not necessary to create a new deployment group to remove an instance temporarily from the existing deployment group.

Option D - Check the tag used by the deployment group and use the AWS CLI "aws deploy remove-tags-from-on-premises-instances" to remove the tag from the particular on-premises instance.

This option is not an appropriate solution to the scenario described in the question. Removing the tag used by the deployment group would affect all instances with that tag, not just the single on-premises instance that needs to be removed temporarily. This option would not achieve the desired outcome.

Conclusion:

Option B - Use the AWS CLI command aws deploy deregister to deregister the on-premises instance from the AWS CodeDeploy service is the most appropriate solution to the scenario described in the question.