

# Managing on-premises instances operations in CodeDeploy
<a name="on-premises-instances-operations"></a>

Follow the instructions in this section to manage operations on your on-premises instances after you have registered them with CodeDeploy, such as getting more information about, removing tags from, and uninstalling and deregistering on-premises instances.

**Topics**
+ [Get information about a single on-premises instance](on-premises-instances-operations-view-details-single.md)
+ [Get information about multiple on-premises instances](on-premises-instances-operations-view-details-multiple.md)
+ [Manually remove on-premises instance tags from an on-premises instance](on-premises-instances-operations-remove-tags.md)
+ [Automatically uninstall the CodeDeploy agent and remove the configuration file from an on-premises instance](on-premises-instances-operations-uninstall-agent.md)
+ [Automatically deregister an on-premises instance](on-premises-instances-operations-deregister-automatically.md)
+ [Manually deregister an on-premises instance](on-premises-instances-operations-deregister-manually.md)

# Get information about a single on-premises instance
<a name="on-premises-instances-operations-view-details-single"></a>

You can get information about a single on-premises instance by following the instructions in [View CodeDeploy deployment details](deployments-view-details.md). You can use the AWS CLI or the CodeDeploy console to get more information about a single on-premises instance.

**To get information about a single on-premises instance (CLI)**
+ Call the [get-on-premises-instance](https://docs.aws.amazon.com/cli/latest/reference/deploy/get-on-premises-instance.html) command, specifying the name that uniquely identifies the on-premises instance (with the `--instance-name` option):

  ```
  aws deploy get-on-premises-instance --instance-name AssetTag12010298EX
  ```

**To get information about a single on-premises instance (console)**

1. Sign in to the AWS Management Console and open the CodeDeploy console at [https://console.aws.amazon.com/codedeploy](https://console.aws.amazon.com/codedeploy).
**Note**  
Sign in with the same user that you set up in [Getting started with CodeDeploy](getting-started-codedeploy.md).

1. In the navigation pane, expand **Deploy**, and choose **On-premises instances**.

1. In the list of on-premises instances, choose the name of an on-premises instance to view its detail.

# Get information about multiple on-premises instances
<a name="on-premises-instances-operations-view-details-multiple"></a>

You can get information about on-premises instances by following the instructions in [View CodeDeploy deployment details](deployments-view-details.md). You can use the AWS CLI or the CodeDeploy console to get more information about on-premises instances.

**To get information about multiple on-premises instances (CLI)**

1. For a list of on-premises instance names, call the [list-on-premises-instances](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-on-premises-instances.html) command, specifying:
   + Whether to get information about all registered or deregistered on-premises instances (with the `--registration-status` option and `Registered` or `Deregistered`, respectively). If you omit this, then both registered and deregistered on-premises instance names are returned.
   + Whether to get information only about on-premises instances tagged with specific on-premises instance tags (with the `--tag-filters` option). For each on-premises instance tag, specify the `Key`, `Value`, and `Type` (which should always be `KEY_AND_VALUE`). Separate multiple on-premises instance tags with spaces between each `Key`, `Value`, and `Type` triplet.

   For example:

   ```
   aws deploy list-on-premises-instances --registration-status Registered --tag-filters Key=Name,Value=CodeDeployDemo-OnPrem,Type=KEY_AND_VALUE Key=Name,Value=CodeDeployDemo-OnPrem-Beta,Type=KEY_AND_VALUE
   ```

1. For more detailed information, call the [batch-get-on-premises-instances](https://docs.aws.amazon.com/cli/latest/reference/deploy/batch-get-on-premises-instances.html) command, with the names of the on-premises instances (with the `--instance-names` option): 

   ```
   aws deploy batch-get-on-premises-instances --instance-names AssetTag12010298EX AssetTag09920444EX
   ```

**To get information about multiple on-premises instances (console)**

1. Sign in to the AWS Management Console and open the CodeDeploy console at [https://console.aws.amazon.com/codedeploy](https://console.aws.amazon.com/codedeploy).
**Note**  
Sign in with the same user that you set up in [Getting started with CodeDeploy](getting-started-codedeploy.md).

1. In the navigation pane, expand **Deploy**, and choose **On-premises instances**.

   Information about the on-premises instances is displayed.

# Manually remove on-premises instance tags from an on-premises instance
<a name="on-premises-instances-operations-remove-tags"></a>

Typically, you remove an on-premises instance tag from an on-premises instance when that tag is no longer being used, or you want to remove the on-premises instance from any deployment groups that rely on that tag. You can use the AWS CLI or the AWS CodeDeploy console to remove on-premises instance tags from on-premises instances.

You do not need to remove the on-premises instance tags from an on-premises instance before you deregister it. 

Manually removing on-premises instance tags from an on-premises instance does not deregister the instance. It does not uninstall the CodeDeploy agent from the instance. It does not remove the configuration file from the instance. It does not delete the IAM user associated with the instance. 

To automatically deregister the on-premises instance, see [Automatically deregister an on-premises instance](on-premises-instances-operations-deregister-automatically.md).

To manually deregister the on-premises instance, see [Manually deregister an on-premises instance](on-premises-instances-operations-deregister-manually.md).

To automatically uninstall the CodeDeploy agent and remove the configuration file from the on-premises instance, see [Automatically uninstall the CodeDeploy agent and remove the configuration file from an on-premises instance](on-premises-instances-operations-uninstall-agent.md).

To manually uninstall just the CodeDeploy agent from the on-premises instance, see [Managing CodeDeploy agent operations](codedeploy-agent-operations.md).

To manually delete the associated IAM user, see [Deleting an IAM user from your AWS account](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_DeletingUserFromAccount.html). 

**To remove on-premises instance tags from an on-premises instance (CLI)**
+ Call the [remove-tags-from-on-premises-instances](https://docs.aws.amazon.com/cli/latest/reference/deploy/remove-tags-from-on-premises-instances.html), specifying:

   
  + The names that uniquely identify the on-premises instance (with the `--instance-names` option). 
  + The names and values of the tags you want to remove (with the `--tags` option).

    For example:

    ```
    aws deploy remove-tags-from-on-premises-instances --instance-names AssetTag12010298EX --tags Key=Name,Value=CodeDeployDemo-OnPrem
    ```

**To remove on-premises instance tags from an on-premises instance (console)**

1. Sign in to the AWS Management Console and open the CodeDeploy console at [https://console.aws.amazon.com/codedeploy](https://console.aws.amazon.com/codedeploy).
**Note**  
Sign in with the same user that you set up in [Getting started with CodeDeploy](getting-started-codedeploy.md).

1. In the navigation pane, expand **Deploy**, and choose **On-premises instances**.

1. In the list of on-premises instances, choose the name of the on-premises instance from which you want to remove tags.

1. In **Tags**, choose **Remove** next to each tag you want to remove.

1. After you have deleted the tags, choose **Update tags**.

# Automatically uninstall the CodeDeploy agent and remove the configuration file from an on-premises instance
<a name="on-premises-instances-operations-uninstall-agent"></a>

Typically, you uninstall the CodeDeploy agent and remove the configuration file from an on-premises instance after you're no longer planning to deploy to it.

**Note**  
Automatically uninstalling the CodeDeploy agent and removing the configuration file from an on-premises instance does not deregister an on-premises instance. It does not disassociate any on-premises instance tags associated with the on-premises instance. It does not delete the IAM user associated with the on-premises instance.   
To automatically deregister the on-premises instance, see [Automatically deregister an on-premises instance](on-premises-instances-operations-deregister-automatically.md).  
To manually deregister the on-premises instance, see [Manually deregister an on-premises instance](on-premises-instances-operations-deregister-manually.md).  
To manually disassociate any associated on-premises instance tags, see [Manually remove on-premises instance tags from an on-premises instance](on-premises-instances-operations-remove-tags.md).  
To manually uninstall the CodeDeploy agent from the on-premises instance, see [Managing CodeDeploy agent operations](codedeploy-agent-operations.md).  
To manually delete the associated IAM user, see [Deleting an IAM user from your AWS account](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_DeletingUserFromAccount.html). 

From the on-premises instance, use the AWS CLI to call the [uninstall](https://docs.aws.amazon.com/cli/latest/reference/deploy/uninstall.html) command.

For example:

```
aws deploy uninstall
```

The **uninstall** command does the following:

1. Stops the running CodeDeploy agent on the on-premises instance.

1. Uninstalls the CodeDeploy agent from the on-premises instance.

1. Removes the configuration file from the on-premises instance. (For Ubuntu Server and RHEL, this is `/etc/codedeploy-agent/conf`/`codedeploy.onpremises.yml`. For Windows Server, this is `C:\ProgramData\Amazon\CodeDeploy`\$1`conf.onpremises.yml`.)

# Automatically deregister an on-premises instance
<a name="on-premises-instances-operations-deregister-automatically"></a>

Typically, you deregister an on-premises instance after you're no longer planning to deploy to it. When you deregister an on-premises instance, even though the on-premises instance might be part of a deployment group's on-premises instance tags, the on-premises instance will not be included in any deployments. You can use the AWS CLI to deregister on-premises instances.

**Note**  
You cannot use the CodeDeploy console to deregister an on-premises instance. Also, deregistering an on-premises instance removes any on-premises instance tags that are associated with the on-premises instance. It does not uninstall the CodeDeploy agent from the on-premises instance. It does not remove the on-premises instance configuration file from the on-premises instance.  
To use the CodeDeploy console to perform some (but not all) of the activities in this section, see the CodeDeploy console section of [Manually deregister an on-premises instance](on-premises-instances-operations-deregister-manually.md).  
To manually disassociate any associated on-premises instance tags, see [Manually remove on-premises instance tags from an on-premises instance](on-premises-instances-operations-remove-tags.md).  
To automatically uninstall the CodeDeploy agent and remove the configuration file from the on-premises instance, see [Automatically uninstall the CodeDeploy agent and remove the configuration file from an on-premises instance](on-premises-instances-operations-uninstall-agent.md).  
To manually uninstall only the CodeDeploy agent from the on-premises instance, see [Managing CodeDeploy agent operations](codedeploy-agent-operations.md). 

Use the AWS CLI to call the [deregister](https://docs.aws.amazon.com/cli/latest/reference/deploy/deregister.html) command, specifying:
+ The name that uniquely identifies the on-premises instance to CodeDeploy (with the `--instance-name` option). 
+  Optionally, whether to delete the IAM user associated with the on-premises instance. The default behaviour is to delete the IAM user. If you do not want to delete the IAM user associated with the on-premises instance, specify the `--no-delete-iam-user` option in the command. 
+ Optionally, the AWS region where the on-premises instance was registered with CodeDeploy (with the `--region` option). This must be one of the supported regions listed in [Region and endpoints](https://docs.aws.amazon.com/general/latest/gr/rande.html#codedeploy_region) in the *AWS General Reference* (for example, `us-west-2`). If this option is not specified, the default AWS region associated with the calling IAM user will be used.

An example that degisters an instance and deletes the user:

```
aws deploy deregister --instance-name AssetTag12010298EX --region us-west-2
```

An example that degisters an instance and does not delete the user:

```
aws deploy deregister --instance-name AssetTag12010298EX --no-delete-iam-user --region us-west-2
```

The **deregister** command does the following:

1. Deregisters the on-premises instance with CodeDeploy.

1. If specified, deletes the IAM user associated with the on-premises instance.

After you deregister an on-premises instance:
+  It stops appearing in the console immediately. 
+  You can create another instance with the same name immediately. 

If this command encounters any errors, an error message appears, describing how you can manually complete the remaining steps. Otherwise, a success message appears, describing how to call the **uninstall** command.

# Manually deregister an on-premises instance
<a name="on-premises-instances-operations-deregister-manually"></a>

Typically, you deregister an on-premises instance after you're no longer planning to deploy to it. You use the AWS CLI to manually deregister on-premises instances.

Manually deregistering an on-premises instance does not uninstall the CodeDeploy agent. It does not remove the configuration file from the instance. It does not delete the IAM user associated with the instance. It does not remove any tags associated with the instance.

To automatically uninstall the CodeDeploy agent and remove the configuration file from the on-premises instance, see [Automatically uninstall the CodeDeploy agent and remove the configuration file from an on-premises instance](on-premises-instances-operations-uninstall-agent.md).

To manually uninstall only the CodeDeploy agent, see [Managing CodeDeploy agent operations](codedeploy-agent-operations.md). 

To manually delete the associated IAM user, see [Deleting an IAM user from your AWS account](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_DeletingUserFromAccount.html). 

To manually remove only the associated on-premises instance tags, see [Manually remove on-premises instance tags from an on-premises instance](on-premises-instances-operations-remove-tags.md).
+ Call the [deregister-on-premises-instance](https://docs.aws.amazon.com/cli/latest/reference/deploy/deregister-on-premises-instance.html) command, specifying the name that uniquely identifies the on-premises instance (with the `--instance-name` option):

  ```
  aws deploy deregister-on-premises-instance --instance-name AssetTag12010298EX
  ```

  After you deregister an on-premises instance:
  +  It stops appearing in the console immediately. 
  +  You can create another instance with the same name immediately. 