

# Instances managed by MediaConnect Gateway
<a name="gateway-components-instances"></a>



An *instance* is a compute instance running on equipment in your data center and managed by MediaConnect Gateway. This instance is an on-premises implementation of the MediaConnect service and is contained within a gateway. 

Instances use bridges to communicate between your data center and the AWS Cloud. Instances are created by installing software on an on-premises server.

This section covers the fundamental procedures for working with gateways.

**Topics**
+ [Registering a MediaConnect Gateway instance](gateway-components-instances-create.md)
+ [Deregistering a MediaConnect Gateway instance](gateway-components-instances-delete.md)

# Registering a MediaConnect Gateway instance
<a name="gateway-components-instances-create"></a>



You can register an instance by running a custom Linux command on the device that will be hosting the instance. You generate the command by following the instance registration process in the AWS Management Console. Registering an instance using the AWS CLI is not currently supported. 

**Contents**
+ [Prerequisites](#gateway-components-instances-create-prerequisites)
+ [Procedure](#gateway-components-instances-create-procedure)
+ [Next steps](#gateway-components-instances-create-next-steps)
+ [Additional resources](#gateway-components-instances-create-additional-resources)

## Prerequisites
<a name="gateway-components-instances-create-prerequisites"></a>

The following procedure assumes that you have previously created a gateway.

## Procedure
<a name="gateway-components-instances-create-procedure"></a>

**To register a MediaConnect Gateway instance**

1. Open the MediaConnect console at [https://console.aws.amazon.com/mediaconnect/](https://console.aws.amazon.com/mediaconnect/).

1. From the navigation pane, select **Gateways**. 

1. In the **Gateways** section, select the gateway you want to register the instance to. 

1. On the gateway **Details** page, select the **Instances** tab. 

1. On the **Instances** tab, choose **Register instance**.

1. On the **Register Gateway instances** page, complete the following steps:

   1. For **Activation key duration**, enter the number of days that the activation key will remain active. After that number of days, the key will no longer work when registering a gateway instance.

   1. For **Number of instances**, enter the number of instances that you want to register to your gateway with this activation key.

   1. For **Instance role**, choose the IAM role to associate with your external instances.

   1. Select **Generate registration command**.

1. Copy the **Linux command** that is displayed. 

1. Run the command on each instance you want to register to this gateway.
**Important**  
The bash portion of the script must be run as root. If the command isn't run as root, an error is returned.

1. After a few minutes, the instance will register to the gateway. All instances registered to this gateway will appear in the **Instances** tab.

## Next steps
<a name="gateway-components-instances-create-next-steps"></a>

After you’ve registered an instance to a MediaConnect Gateway, you can create a bridge on that instance. For instructions, see [Creating a MediaConnect Gateway bridge](gateway-components-bridges-create.md).

## Additional resources
<a name="gateway-components-instances-create-additional-resources"></a>
+ [Deregistering a MediaConnect Gateway instance](gateway-components-instances-delete.md)

 

# Deregistering a MediaConnect Gateway instance
<a name="gateway-components-instances-delete"></a>



You can deregister an instance you no longer want to use within MediaConnect Gateway. By deregistering the instance, it will no longer support bridges and will not be a part of your gateway. 

**Contents**
+ [Prerequisites](#gateway-components-instances-delete-prerequisites)
+ [Procedure](#gateway-components-instances-delete-procedure)
+ [Next steps](#gateway-components-instances-delete-next-steps)
  + [Reusing a gateway instance](#gateway-components-instances-reuse)
+ [Additional resources](#gateway-components-instances-delete-additional-resources)

## Prerequisites
<a name="gateway-components-instances-delete-prerequisites"></a>

The following procedure assumes that you have previously registered at least one instance to your gateway.

## Procedure
<a name="gateway-components-instances-delete-procedure"></a>

**To deregister a gateway instance**

1. Open the MediaConnect console at [https://console.aws.amazon.com/mediaconnect/](https://console.aws.amazon.com/mediaconnect/).

1. From the navigation pane, select **Gateways**. In the **Gateways** section, select the gateway that contains the instance you want to deregister. 

1. On the gateway **Details** page, select the **Instances** tab. Select the **Instance ID** of the instance you want to deregister.

1. Select **Deregister**.

1. Confirm the deregistration of the instance by selecting **Deregister instance**.

1. Repeat the previous steps for any additional instances you need to deregister.

## Next steps
<a name="gateway-components-instances-delete-next-steps"></a>

### Reusing a gateway instance
<a name="gateway-components-instances-reuse"></a>

If you want to reuse the instance for Amazon ECS Anywhere or as another gateway instance, you will need to complete the following steps.

**To reuse a gateway instance (optional)**

1. Open the MediaConnect console at [https://console.aws.amazon.com/mediaconnect/](https://console.aws.amazon.com/mediaconnect/).

1. From the navigation pane, select **Gateways**. In the **Gateways** section, select the gateway that contains the instance you want to reuse. 

1. On the gateway **Details** page, select the **Instances** tab. Locate the **Instance ID** of the instance you want to reuse.

1. Make sure that the **Instance state** is **Deregistered** for the instance you want to reuse.

1. From a computer with the access to do so, connect to the instance using SSH.

1. Run the following commands, in order.

   ```
   sudo docker stop $(sudo docker ps -f "name=MediaConnectGatewayAgent" -q); \
   sudo docker stop ecs-agent; \
   sudo systemctl stop ecs amazon-ssm-agent; \
   sudo yum remove -y amazon-ecs-init amazon-ssm-agent;  `# or apt or snap as needed` \
   sudo rm /var/lib/ecs /etc/ecs /var/lib/amazon/ssm /var/log/ecs /var/log/amazon/ssm -rf; \
   sudo docker rm -f ecs-agent ssm-agent; \
   sudo docker container rm -f $(sudo docker ps -a -f "name=MediaConnectGatewayAgent" -q); \
   sudo docker volume rm -f ecsdata docker run; \
   sudo pkill -f -KILL network_bootstra[p]; \
   sudo pkill -KILL mcproxy;
   ```

## Additional resources
<a name="gateway-components-instances-delete-additional-resources"></a>

For more information about deleting a MediaConnect Gateway and its networks, see [Removing a MediaConnect Gateway](gateway-cleanup-console.md).