There are several uninstall options, depending on how you installed:
To uninstall the ECS integration using the CloudFormation templates:
- Go to the list of stacks in your AWS console.
- For each New Relic stack:
- Select the stack
- Click the delete button
- Click the delete stack button on the confirmation pop-up.
To uninstall the ECS integration using the installer script:
For EC2 and EXTERNAL 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
To uninstall manually, you must delete all the AWS resources related to the integration. To do this:
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
Delete the Systems Manager (SSM) parameter that stores the New Relic license key:aws ssm delete-parameter --name "/newrelic-infra/ecs/license-key"
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'
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"
Delete the IAM role:aws iam delete-role --role-name "NewRelicECSTaskExecutionRole"
Delete the IAM policy
NewRelicSSMLicenseKeyReadAccess, which grants System Manager license key access:
aws iam delete-policy --policy-arn "POLICY_ARN"
The remaining steps are only for EC2 and EXTERNAL launch type, and not Fargate:
Delete the services:
aws ecs delete-service --service "newrelic-infra" --cluster "YOUR_CLUSTER_NAME"
aws ecs delete-service --service "newrelic-infra-external" --cluster "YOUR_CLUSTER_NAME"
List the task definition for the
newrelic-infrafamily of tasks:aws ecs list-task-definitions \--family-prefix newrelic-infra \--output text \--query taskDefinitionArns
Deregister the tasks:
aws ecs deregister-task-definition --task-definition "TASK_DEFINITION_ARN"