Uninstall the ECS integration

New Relic Infrastructure's on-host ECS integration reports and displays performance data from your Amazon ECS environment. This document explains how to uninstall this integration.

Uninstall

There are several uninstall options, depending on how you installed:

CloudFormation uninstall

To uninstall the ECS integration using the CloudFormation templates:

  1. Go to the list of stacks in your AWS console.
  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

To uninstall the ECS integration using the installer script:

  • For EC2 launch type: run

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

    $ ./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.

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:

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

Manual uninstall

To uninstall manually, you must delete all the 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:
    $ aws configure get region
    us-east-1
    
    $ aws ecs list-clusters
    YOUR_CLUSTER_ARNS	
    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:
    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:
      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:
    aws iam detach-role-policy --role-name "NewRelicECSTaskExecutionRole" --policy-arn "POLICY_ARN"
    
  5. Delete the IAM role:
    aws iam delete-role --role-name "NewRelicECSTaskExecutionRole"
    
  6. Delete the IAM policy NewRelicSSMLicenseKeyReadAccess, which grants System Manager license key access:
    aws iam delete-policy --policy-arn "POLICY_ARN"
    
  7. The remaining steps are only for EC2 launch type, and not Fargate:
    1. Delete the service:
      aws ecs delete-service --service "newrelic-infra" --cluster "YOUR_CLUSTER_NAME"
      
    2. List the task definition for the newrelic-infra family of tasks:
      aws ecs list-task-definitions \
      --family-prefix newrelic-infra \
                  --output text \
                  --query taskDefinitionArns
      
    3. Deregister the tasks:
      aws ecs deregister-task-definition --task-definition "TASK_DEFINITION_ARN"
      

For more help

Recommendations for learning more: