-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
list the DNS Zones when running in AWS
- Loading branch information
Showing
8 changed files
with
272 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"cSpell.words": [ | ||
"apimachinery", | ||
"armdns", | ||
"AWSDNS", | ||
"azidentity", | ||
"bmatcuk", | ||
"cgroups", | ||
"doublestar", | ||
"metav", | ||
"OIDC", | ||
"resourcemanager", | ||
"tbody", | ||
"terramate" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"sort" | ||
"strings" | ||
|
||
"github.com/aws/aws-sdk-go-v2/config" | ||
"github.com/aws/aws-sdk-go-v2/service/route53" | ||
) | ||
|
||
func getAWSDNSZones(ctx context.Context) []nameValuePair { | ||
// bail when not running in aws. | ||
// see https://docs.aws.amazon.com/eks/latest/userguide/pod-id-how-it-works.html | ||
if os.Getenv("AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE") == "" { | ||
return []nameValuePair{} | ||
} | ||
|
||
var zones nameValuePairs | ||
|
||
cfg, err := config.LoadDefaultConfig(ctx) | ||
if err != nil { | ||
return []nameValuePair{{"ERROR", fmt.Sprintf("%v", err)}} | ||
} | ||
|
||
client := route53.NewFromConfig(cfg) | ||
|
||
response, err := client.ListHostedZones(ctx, nil) | ||
if err != nil { | ||
return []nameValuePair{{"ERROR", fmt.Sprintf("%v", err)}} | ||
} | ||
|
||
for _, hostedZone := range response.HostedZones { | ||
zone, err := client.GetHostedZone(ctx, &route53.GetHostedZoneInput{Id: hostedZone.Id}) | ||
if err != nil { | ||
return []nameValuePair{{"ERROR", fmt.Sprintf("%v", err)}} | ||
} | ||
zones = append(zones, nameValuePair{ | ||
Name: *zone.HostedZone.Name, | ||
Value: strings.Join(zone.DelegationSet.NameServers, "\n")}) | ||
} | ||
|
||
sort.Sort(zones) | ||
|
||
return zones | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.