def delete_global_cluster()

in global-clusters-automation/failover_and_delete_global_cluster.py [0:0]


def delete_global_cluster(global_cluster_id, secondary_cluster_arn, secondary_clusters, is_delete_global_cluster):
    # Remove and promote all clusters to standalone clusters
    for each_secondary_cluster in secondary_clusters:
        # each_secondary_cluster_id = each_secondary_cluster.split(":")[-1]
        if each_secondary_cluster != secondary_cluster_arn:
            print('Removing secondary cluster ', each_secondary_cluster, ' from global cluster ', global_cluster_id)
            remove_from_global_cluster(each_secondary_cluster, global_cluster_id)
    # Wait until all standalone clusters are promoted
    print('Waiting till all secondary clusters are removed from global cluster ', global_cluster_id)
    wait_for_promotion_to_complete(global_cluster_id, secondary_cluster_arn)

    # Delete secondary clusters
    print('All secondary clusters are promoted to standalone cluster. Begin deleting each cluster.')
    for each_secondary_cluster in secondary_clusters:
        if each_secondary_cluster != secondary_cluster_arn:
            print('Deleting secondary cluster ', each_secondary_cluster, ' within global cluster ', global_cluster_id)
            delete_cluster(each_secondary_cluster)
    # delete primary cluster
    delete_primary_cluster(global_cluster_id)
    print('Deleting global cluster... ', global_cluster_id)
    # delete global cluster
    deleted_global_cluster = client.delete_global_cluster(
        GlobalClusterIdentifier=global_cluster_id
    )

    print('********* SUCCESS : Secondary cluster ', secondary_cluster_arn, ' has been promoted to standalone '
                                                                           'primary and global cluster ',
          global_cluster_id, 'has been deleted. *********')