(ctx context.Context, nameOrId string)
| 311 | } |
| 312 | |
| 313 | func lookupZone(ctx context.Context, nameOrId string) *route53types.HostedZone { |
| 314 | if isZoneId(nameOrId) { |
| 315 | // lookup by id |
| 316 | id := nameOrId |
| 317 | if !strings.HasPrefix(nameOrId, "/hostedzone/") { |
| 318 | id = "/hostedzone/" + id |
| 319 | } |
| 320 | req := route53.GetHostedZoneInput{ |
| 321 | Id: aws.String(id), |
| 322 | } |
| 323 | resp, err := r53.GetHostedZone(ctx, &req) |
| 324 | var notFound *route53types.NoSuchHostedZone |
| 325 | if errors.As(err, ¬Found) { |
| 326 | errorAndExit(fmt.Sprintf("Zone '%s' not found", nameOrId)) |
| 327 | } |
| 328 | fatalIfErr(err) |
| 329 | return resp.HostedZone |
| 330 | } else { |
| 331 | // lookup by name |
| 332 | matches := []route53types.HostedZone{} |
| 333 | req := route53.ListHostedZonesByNameInput{ |
| 334 | DNSName: aws.String(nameOrId), |
| 335 | } |
| 336 | resp, err := r53.ListHostedZonesByName(ctx, &req) |
| 337 | fatalIfErr(err) |
| 338 | for _, zone := range resp.HostedZones { |
| 339 | if zoneName(*zone.Name) == zoneName(nameOrId) { |
| 340 | matches = append(matches, zone) |
| 341 | } |
| 342 | } |
| 343 | switch len(matches) { |
| 344 | case 0: |
| 345 | errorAndExit(fmt.Sprintf("Zone '%s' not found", nameOrId)) |
| 346 | case 1: |
| 347 | return &matches[0] |
| 348 | default: |
| 349 | errorAndExit("Multiple zones match - you will need to use Zone ID to uniquely identify the zone") |
| 350 | } |
| 351 | } |
| 352 | return nil |
| 353 | } |
| 354 | |
| 355 | func waitForChange(ctx context.Context, change *route53types.ChangeInfo) { |
| 356 | fmt.Printf("Waiting for sync") |
no test coverage detected