---
title: Uninstall the ECS integration
source: https://docs.newrelic.com/docs/infrastructure/elastic-container-service-integration/uninstall-ecs-integration
---

New Relic's on-host [ECS integration](https://docs.newrelic.com/docs/introduction-amazon-ecs-integration) reports and displays performance data from your [Amazon ECS](https://docs.aws.amazon.com/ecs/index.html) environment. Read on to learn how to uninstall this integration.

## Uninstall

There are several uninstall options, depending on how you [installed](https://docs.newrelic.com/docs/install-ecs-integration#install-ec2):

-   [Uninstall with CloudFormation](#cloudformation)
-   [Use automatic installer script](#auto-installer)
-   [Manual uninstall](#manual-uninstall)

### CloudFormation uninstall [#cloudformation]

To uninstall the ECS integration using the CloudFormation templates:

1.  Go to the [list of stacks in your AWS console.](https://console.aws.amazon.com/cloudformation/home?#/stacks?filteringText=&filteringStatus=active&viewNested=true&hideStacks=false)
2.  For each New Relic stack:
    1.  Select the stack
    2.  Click the delete button
    3.  Click the delete stack button on the confirmation pop-up.

### Automatic uninstall [#auto-installer]

To uninstall the ECS integration using the installer script:

-   For EC2 and EXTERNAL launch type: run

    ```ah
    ./newrelic-infrastructure-ecs-installer.sh -u -c YOUR_CLUSTER_NAME
    ```
-   For Fargate launch type:

    ```sh
    ./newrelic-infrastructure-ecs-installer.sh -f -u -c YOUR_CLUSTER_NAME
    ```

You only need to execute the command once, regardless of the number of nodes in your cluster. The command will delete the [AWS resources created during the install procedure](https://docs.newrelic.com/docs/install-ecs-integration#aws-resources).

The installer provides a dry run mode that shows you the awscli commands that are going to be executed. The dry run mode for the uninstall process is activated by passing the `-d` flag to the command:

```sh
./newrelic-infrastructure-ecs-installer.sh -d -u -c YOUR_CLUSTER_NAME
```

### Manual uninstall

To uninstall manually, you must delete all the [AWS resources](https://docs.newrelic.com/docs/install-ecs-integration#aws-resources) related to the integration. To do this:

1.  Check that your AWS profile points to the same region where your ECS cluster was created:

    ```sh
    aws configure get region
    [output] us-east-1
    [output] 
    aws ecs list-clusters
    [output] YOUR_CLUSTER_ARNS	
    [output] arn:aws:ecs:us-east-1:YOUR_AWS_ACCOUNT:cluster/YOUR_CLUSTER
    ```
2.  Delete the Systems Manager (SSM) parameter that stores the New Relic license key:

    ```sh
    aws ssm delete-parameter --name "/newrelic-infra/ecs/license-key"
    ```
3.  Before deleting the IAM role, you need to detach all of its policies. To get a list of the attached policies:

    ```sh
    aws iam list-attached-role-policies \
      --role-name "NewRelicECSTaskExecutionRole" \
      --output text \
      --query 'AttachedPolicies[*].PolicyArn'
    ```
4.  Detach all the policies returned in the previous step from the IAM role:

    ```sh
    aws iam detach-role-policy --role-name "NewRelicECSTaskExecutionRole" --policy-arn "POLICY_ARN"
    ```
5.  Delete the IAM role:

    ```sh
    aws iam delete-role --role-name "NewRelicECSTaskExecutionRole"
    ```
6.  Delete the IAM policy `NewRelicSSMLicenseKeyReadAccess`, which grants System Manager license key access:

    ```sh
    aws iam delete-policy --policy-arn "POLICY_ARN"
    ```
7.  The remaining steps are only for EC2 and EXTERNAL launch type, and not Fargate:

    1.  Delete the services:

        ```sh
        aws ecs delete-service --service "newrelic-infra" --cluster "YOUR_CLUSTER_NAME"
        ```

        ```sh
        aws ecs delete-service --service "newrelic-infra-external" --cluster "YOUR_CLUSTER_NAME"
        ```
    2.  List the task definition for the `newrelic-infra` family of tasks:

        ```sh
        aws ecs list-task-definitions \
          --family-prefix newrelic-infra \
          --output text \
          --query taskDefinitionArns
        ```
    3.  Deregister the tasks:

        ```sh
        aws ecs deregister-task-definition --task-definition "TASK_DEFINITION_ARN"
        ```
