Giter Club home page Giter Club logo

Comments (2)

gyuho avatar gyuho commented on July 17, 2024
// DeleteHost deletes a Hosted zone with record types.
// Works with https://github.com/mitchellh/goamz/pull/162
func DeleteHost(
    client *route53.Route53,
    domain string,
    recordType string,
) (changeID string, deleteID string, ERR error) {
    log.Println("Deleting:", domain)
    id, err := GetHostedZoneID(client, domain)
    if err != nil {
        changeID = ""
        deleteID = ""
        ERR = err
        return
    }
    listOpt := route53.ListOpts{
        Name: domain,
    }
    resp0, err := client.ListResourceRecordSets(id, &listOpt)
    if err != nil {
        changeID = ""
        deleteID = ""
        ERR = err
        return
    }
    changes := []route53.Change{}
    for _, record := range resp0.Records {
        if record.Type != recordType {
            continue
        }
        change := route53.Change{
            Action: "DELETE",
            Record: route53.ResourceRecordSet{
                Name:          record.Name,
                Type:          record.Type,
                TTL:           record.TTL,
                Records:       record.Records,
                SetIdentifier: record.SetIdentifier,
                Weight:        record.Weight,
                HealthCheckId: record.HealthCheckId,
                Region:        record.Region,
                Failover:      record.Failover,
                AliasTarget:   record.AliasTarget,
                // RecordsXML: recordsXML,
            },
        }
        changes = append(changes, change)
    }
    resp1, err := changeRecordSets(client, id, "Delete", changes)
    if err != nil {
        changeID = ""
        deleteID = ""
        ERR = err
        return
    }
    resp2, err := client.DeleteHostedZone(id)
    if err != nil {
        changeID = ""
        deleteID = ""
        ERR = err
        return
    }
    changeID = route53.CleanChangeID(resp1.ChangeInfo.ID)
    deleteID = route53.CleanChangeID(resp2.ChangeInfo.ID)
    ERR = nil
    log.Println("Deleted:", domain)
    return
}

from goamz.

gyuho avatar gyuho commented on July 17, 2024

Actually doesn't need to be deleted one by one. Just need to omit RecordsXML: recordsXML

from goamz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.