Clean up
-
From your local machine, delete the cluster.
$pcluster delete-cluster --cluster-name"ad-cluster"--region"region-id"{ "cluster": { "clusterName": "ad-cluster", "cloudformationStackStatus": "DELETE_IN_PROGRESS", "cloudformationStackArn": "arn:aws:cloudformation:region-id:123456789012:stack/ad-cluster/1234567-abcd-0123-def0-abcdef0123456", "region": "region-id", "version": "3.14.2", "clusterStatus": "DELETE_IN_PROGRESS" } } -
Check the progress of the cluster being deleted.
$pcluster describe-cluster --cluster-name"ad-cluster"--region"region-id"--query "clusterStatus""DELETE_IN_PROGRESS"After the cluster is successfully deleted, proceed to the next step.
Delete the Active Directory resources
-
From https://console.aws.amazon.com/cloudformation/
. -
In the navigation pane, choose Stacks.
-
From the list of stacks, choose the AD stack (for example,
pcluster-ad). -
Choose Delete.
-
Delete the Amazon EC2 instance.
-
From https://console.aws.amazon.com/ec2/
, choose Instances in the navigation pane. -
From the list of instances, choose the instance that you created to add users to the directory.
-
Choose Instance state, then Terminate instance.
-
-
Delete the hosted zone.
-
Create a
recordset-delete.jsonwith the following content. In this example, HostedZoneId is the canonical hosted zone ID of the load balancer.{ "Changes": [ { "Action": "DELETE", "ResourceRecordSet": { "Name": "corp.example.com", "Type": "A", "Region":"region-id", "SetIdentifier": "pcluster-active-directory", "AliasTarget": { "HostedZoneId":"Z2IFOLAFXWLO4F", "DNSName": "CorpExampleCom-NLB-3afe296bf4ba80d4.elb.region-id.amazonaws.com", "EvaluateTargetHealth": true } } } ] } -
Submit the recordset change to the hosted zone using the hosted zone ID.
$aws route53 change-resource-record-sets --hosted-zone-idZ09020002B5MZQNXMSJUB\ --change-batch file://recordset-delete.json{ "ChangeInfo": { "Id": "/change/C04853642A0TH2TJ5NLNI", "Status": "PENDING", "SubmittedAt": "2022-05-05T14:25:51.046000+00:00" } } -
Delete the hosted zone.
$aws route53 delete-hosted-zone --idZ09020002B5MZQNXMSJUB{ "ChangeInfo": { "Id": "/change/C0468051QFABTVHMDEG9", "Status": "PENDING", "SubmittedAt": "2022-05-05T14:26:13.814000+00:00" } }
-
-
Delete the LB listener.
$aws elbv2 delete-listener \ --listener-arn arn:aws:elasticloadbalancing:region-id:123456789012:listener/net/CorpExampleCom-NLB/3afe296bf4ba80d4/a8f9d97318743d4b--regionregion-id -
Delete the target group.
$aws elbv2 delete-target-group \ --target-group-arn arn:aws:elasticloadbalancing:region-id:123456789012:targetgroup/CorpExampleCom-Targets/44577c583b695e81--regionregion-id -
Delete the load balancer.
$aws elbv2 delete-load-balancer \ --load-balancer-arn arn:aws:elasticloadbalancing:region-id:123456789012:loadbalancer/net/CorpExampleCom-NLB/3afe296bf4ba80d4--regionregion-id -
Delete the policy that the cluster uses to read the certificate from Secrets Manager.
$aws iam delete-policy --policy-arn arn:aws:iam::123456789012:policy/ReadCertExample -
Delete the secret that contains the domain certificate.
$aws secretsmanager delete-secret \ --secret-id arn:aws:secretsmanager:region-id:123456789012:secret:example-cert-123abc\ --regionregion-id{ "ARN": "arn:aws:secretsmanager:region-id:123456789012:secret:example-cert-123abc", "Name": "example-cert", "DeletionDate": "2022-06-04T16:27:36.183000+02:00" } -
Delete the certificate from ACM.
$aws acm delete-certificate \ --certificate-arn arn:aws:acm:region-id:123456789012:certificate/343db133-490f-4077-b8d4-3da5bfd89e72--regionregion-id -
Delete the Active Directory (AD) resources.
-
Get the following resource IDs from the output of the python script
ad.py:-
AD ID
-
AD subnet IDs
-
AD VPC ID
-
-
Delete the directory by running the following command.
$aws ds delete-directory --directory-idd-abcdef0123456789--regionregion-id{ "DirectoryId": "d-abcdef0123456789" } -
List the security groups in the VPC.
$aws ec2 describe-security-groups --filters '[{"Name":"vpc-id","Values":["vpc-07614ade95ebad1bc"]}]' --regionregion-id -
Delete the custom security group.
$aws ec2 delete-security-group --group-idsg-021345abcdef6789--regionregion-id -
Delete the subnets.
$aws ec2 delete-subnet --subnet-idsubnet-1234567890abcdef--regionregion-id$aws ec2 delete-subnet --subnet-idsubnet-021345abcdef6789--regionregion-id -
Describe internet gateway.
$aws ec2 describe-internet-gateways \ --filters Name=attachment.vpc-id,Values=vpc-021345abcdef6789\ --regionregion-id{ "InternetGateways": [ { "Attachments": [ { "State": "available", "VpcId": "vpc-021345abcdef6789" } ], "InternetGatewayId": "igw-1234567890abcdef", "OwnerId": "123456789012", "Tags": [] } ] } -
Detach the internet gateway.
$aws ec2 detach-internet-gateway \ --internet-gateway-idigw-1234567890abcdef\ --vpc-idvpc-021345abcdef6789\ --regionregion-id -
Delete the internet gateway.
$aws ec2 delete-internet-gateway \ --internet-gateway-idigw-1234567890abcdef\ --regionregion-id -
Delete the VPC.
$aws ec2 delete-vpc \ --vpc-idvpc-021345abcdef6789\ --regionregion-id -
Delete the secret that contains the
ReadOnlyUserpassword.$aws secretsmanager delete-secret \ --secret-id arn:aws:secretsmanager:region-id:123456789012:secret:ADSecretPassword-1234" \ --regionregion-id
-