Skip to content

Latest commit

 

History

History
88 lines (63 loc) · 1.91 KB

google_dns.md

File metadata and controls

88 lines (63 loc) · 1.91 KB

gocloud DNS - gce

Configure Google Cloud credentials.

Download your service account credentials file from Google Cloud and save it as googlecloudinfo.json in your HOME/.gocloud directory.

You can also set the credentials as environment variables:

export PrivateKey =  "xxxxxxxxxxxx"
export Type =  "xxxxxxxxxxxx"
export ProjectID = "xxxxxxxxxxxx"
export PrivateKeyID = "xxxxxxxxxxxx"
export ClientEmail = "xxxxxxxxxxxx"
export ClientID = "xxxxxxxxxxxx"
export AuthURI = "xxxxxxxxxxxx"
export TokenURI = "xxxxxxxxxxxx"
export AuthProviderX509CertURL = "xxxxxxxxxxxx"
export ClientX509CertURL =  "xxxxxxxxxxxx"

Initialize library

import "github.com/cloudlibz/gocloud/gocloud"

googlecloud, _ := gocloud.CloudProvider(gocloud.Googleprovider)

Create DNS

createdns := map[string]interface{}{
		"Project":     "sheltermap-1493101612061",
		"Kind":        "dns#managedZone",
		"Description": "dns",
		"DnsName":     "rootmonk.me.",
		"Name":        "gocloud",
	}

  resp, err := googlecloud.CreateDns(createdns)

  response := resp.(map[string]interface{})
  fmt.Println(response["body"])

List DNS

  listdns := map[string]string{
		"Project": "sheltermap-1493101612061",
	}

  resp, err := googlecloud.ListDns(listdns)

 response := resp.(map[string]interface{})
 fmt.Println(response["body"])

Delete DNS

  deletedns := map[string]string{
		"Project":     "sheltermap-1493101612061",
		"managedZone": "gocloud3",
	}

 resp, err := googlecloud.DeleteDns(deletedns)

 response := resp.(map[string]interface{})
 fmt.Println(response["body"])

Detach node with loadbalancer

  listResourcednsRecordSets := map[string]string{
	"Project"     : "sheltermap-1493101612061",
	"managedZone" : "gocloud3",
  }

  resp, err := googlecloud.ListResourceDnsRecordSets(listResourcednsRecordSets)

 response := resp.(map[string]interface{})
 fmt.Println(response["body"])