anchor.diff:      hostname=$(${hostname}).${zone}
       record_value=$(${wget} http://169.254.169.254/latest/meta-data/${query})
   
  -    ${retry} ${curl-nofail} -d @/dev/stdin \
  +    ${curl-nofail} -d @/dev/stdin \
             -H "Content-Type: text/xml" \
             -H "x-amz-date: $date" \
             -H "$auth_header" \
  
positive.code:   bash = "${pkgs.bash}/bin/bash";
    xargs = "${pkgs.findutils}/bin/xargs";
  
    register-hostname = {
      zoneId, zone, iamCredentialName,
      useLocalHostname,
      query ? if useLocalHostname then "local-ipv4" else "public-hostname",
      recordType ? if useLocalHostname then "A" else "CNAME"
    }: pkgs.writeScript "ec2-register-hostname" ''
      date=$(${curl} -I https://route53.amazonaws.com/date | ${awk} '/^Date: / {sub("Date: ", "", $0); sub("\\r", "", $0); print $0}')
  
      iam="${iamCredentialName}"
  
negative.code:   };
  
    config = {
      systemd.services.ec2-autohostname = {
        description = "EC2: apply dynamic hostname";
  
        after = [ "fetch-ec2-data.service" ];
  
        script = ec2-autohostname;
  
        serviceConfig.Type = "oneshot";
        serviceConfig.RemainAfterExit = true;
        unitConfig.X-StopOnReconfiguration = true;
      };
    };
  }
  