Skip to content

Instantly share code, notes, and snippets.

@munisystem
Last active March 28, 2016 08:25
Show Gist options
  • Save munisystem/438d2969a680090e0fbd to your computer and use it in GitHub Desktop.
Save munisystem/438d2969a680090e0fbd to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/route53"
)
func main() {
domain := "test."
client := route53.New(session.New(&aws.Config{}))
hostedZones, err := client.ListHostedZonesByName(&route53.ListHostedZonesByNameInput{DNSName: aws.String(domain)})
if err != nil {
panic(err)
}
hostedZoneId := hostedZones.HostedZones[0].Id
params := &route53.ChangeResourceRecordSetsInput{
ChangeBatch: &route53.ChangeBatch{
Changes: []*route53.Change{
{
Action: aws.String("UPSERT"),
//Action: aws.String("DELETE"),
ResourceRecordSet: &route53.ResourceRecordSet{
Name: aws.String("hoge.fuga.test."),
Type: aws.String("A"),
ResourceRecords: []*route53.ResourceRecord{
{
Value: aws.String("192.168.1.1"),
},
},
TTL: aws.Int64(60),
},
},
},
},
HostedZoneId: hostedZoneId,
}
resourceRecordResp, err := client.ChangeResourceRecordSets(params)
if err != nil {
panic(err)
}
fmt.Println(resourceRecordResp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment