Clean up resources

Clean up resources

Follow the steps below in the exact order. DRS creates several resources outside the CloudFormation stack (replication server, staging disk, snapshot, launch template, two security groups, and a source network), so deleting only the stack is not enough.

  1. Open AWS Elastic Disaster Recovery → Recovery instances

    • The list contains two drill instances.
    • Tick the checkbox at the top of the list to select all recovery instances.
    • Select Actions → Terminate recovery instances.
    • In the confirmation dialog, select Terminate.

    AWS Elastic Disaster Recovery Workshop

  2. After about 1–5 minutes, the Recovery instances list is empty

    • In EC2 → Instances, the two drill instances show Terminated.

    AWS Elastic Disaster Recovery Workshop

  3. On the Source servers page

    • In the left menu of the DRS console, select Source servers. The list contains wordpress-web.onpremsim.env and wordpress-db.onpremsim.env.
    • Tick both source servers.
    • Select Actions → Disconnect from AWS.
    • In the confirmation dialog, select Disconnect.
    • Data replication status shows Disconnected. The agent is removed from the servers, and DRS starts terminating the replication server.

    AWS Elastic Disaster Recovery Workshop

  4. On the Source servers page (with both servers still selected)

    • Select Actions → Delete server.
    • In the confirmation dialog, select Permanently delete. The Source servers list is empty.

    AWS Elastic Disaster Recovery Workshop

  5. In the CloudShell window

    • Select the CloudShell icon (>_) on the top bar of the console. The top bar still shows Oregon.
    • List the DRS source network created by the agent installer in section 6. The command prints one line with an ID beginning with sn- and the VPC ID of onpremsim-source-vpc; if the result is empty, continue to item 6:
    aws drs describe-source-networks --region us-west-2 --query "items[].[sourceNetworkID,sourceVpcID]" --output text
    
    • Delete the source network, replacing <source-network-id> with the sn-... value just obtained.
    aws drs delete-source-network --source-network-id <source-network-id> --region us-west-2
    

    AWS Elastic Disaster Recovery Workshop

  6. After about 5–20 minutes, the replication server changes to Terminated

    • Go to EC2 → Instances and select refresh from time to time.
    • The instances named AWS Elastic Disaster Recovery Replication Server and AWS Elastic Disaster Recovery Conversion Server show Terminated, and only the two source servers remain Running.

    AWS Elastic Disaster Recovery Workshop

  7. On the EC2 → Launch templates page

    • In the left menu of the EC2 console, select Launch templates. The list may show 3 created-and-used-by-elastic-disaster-recovery-service-* templates:
    • If no ...-s-<source-server-id>-... template remains, continue to item 8.
    • Tick one ...-service-s-<source-server-id>-... template.
    • Select Actions → Delete template.
    • In the dialog, type Delete in the field, then select Delete.
    • Repeat for the other template.

    AWS Elastic Disaster Recovery Workshop

  8. On the EC2 → Security groups page

    • In the search box above the list, type AWS Elastic Disaster Recovery and press Enter. The list shows AWS Elastic Disaster Recovery default Replication Server Security Group and AWS Elastic Disaster Recovery default Conversion Server Security Group (created by the drill in section 8), both in VPC drs-recovery-vpc. Keep TargetSecurityGroup and the default security group; the stack deletes them.
    • Tick AWS Elastic Disaster Recovery default Replication Server Security Group.
    • Select Actions → Delete security groups.
    • In the dialog, select Delete. If the group is reported as still in use, the replication server has not finished terminating: wait a few minutes and try again.
    • Repeat for AWS Elastic Disaster Recovery default Conversion Server Security Group. If this group remains, the stack cannot delete drs-recovery-vpc.

    AWS Elastic Disaster Recovery Workshop

  9. On the EC2 → Snapshots page

    • In the search box above the list, type AWS Elastic Disaster Recovery and press Enter. The list shows snapshots named AWS Elastic Disaster Recovery Snapshot, AWS Elastic Disaster Recovery Converted Snapshot, and AWS Elastic Disaster Recovery Base Snapshot. If the list is empty, continue to item 11.
    • Tick the checkbox at the top of the list to select all these snapshots.
    • Select Actions → Delete snapshot.
    • In the dialog, type delete and press Delete.

    AWS Elastic Disaster Recovery Workshop

  10. Open the CloudFormation console

    • In the search bar, type CloudFormation, then select CloudFormation. The Stacks page contains the EDRW stack.
    • Select the EDRW stack.
    • Select Delete.

    AWS Elastic Disaster Recovery Workshop

  11. Open IAM → Roles

    • In the search bar, type IAM, then select IAM. In the left menu, select Roles.
    • In the search box, type drs-agent-installation-role.
    • Tick the checkbox for drs-agent-installation-role.
    • Select Delete.
    • In the dialog, type drs-agent-installation-role in the field, then select Delete. The role disappears from the list.

    AWS Elastic Disaster Recovery Workshop

  12. (Only if you used the IAM user fallback in section 5) On the IAM → IAM Users page

    • If you did not use the IAM user, continue to item 16.
    • In the left menu of IAM, select IAM Users. Tick the checkbox for drs-agent-user.
    • Select Delete.
    • In the dialog, select Deactivate access key, type confirm in the field, then select Delete user. The user disappears from the list. Its access key is also deleted.

    AWS Elastic Disaster Recovery Workshop

  13. (Optional) In the CloudShell window

    • When you uploaded the template in section 2, CloudFormation created an S3 bucket named cf-templates-<random>-us-west-2. Find it (the command prints one bucket name, for example cf-templates-abc123def456-us-west-2; if the result is empty, or if you still use this bucket for another stack, continue to item 14):
    aws s3api list-buckets --query "Buckets[?starts_with(Name, 'cf-templates-') && ends_with(Name, '-us-west-2')].Name" --output text
    
    • Delete the bucket and all its contents, replacing <bucket-name> with the name just found. Each uploaded template prints a delete: s3://<bucket-name>/... line, followed by remove_bucket: <bucket-name>:
    aws s3 rb s3://<bucket-name> --force
    

    AWS Elastic Disaster Recovery Workshop