Wednesday, February 3, 2016

route53 : windows: change resource record fails with Paramter validation error

Error:
1) 'ascii' codec can't encode character u'\xff' in position 26: ordinal not in range(128)
2) Parameter validation failed:
Invalid type for parameter ChangeBatch.Changes[0].ResourceRecordSet.TTL, value:
120, type: <type 'unicode'>, valid types: <type 'int'>, <type 'long'>
Invalid type for parameter ChangeBatch.Changes[0].ResourceRecordSet.ResourceRec
rds, value: ue1010248068100.corp.adobe.com, type: <type 'unicode'>, valid types
 <type 'list'>, <type 'tuple'>

Reason: Due to Encoding

Remedy:
# Create file for Route53
$X=@"
{
  "Comment": "Route53 Weighted Routing - $SID with value $Weight",
  "Changes": [
    {
      "Action": "UPSERT",
      "ResourceRecordSet": {
        "Name": "$MYCNAME",
        "Type": "CNAME",
        "SetIdentifier": "$SID",
        "Weight": $Weight,
        "TTL": 120,
        "ResourceRecords": [{"Value": "$FQDN"}]
      }
    }
  ]
}
"@
$X | out-file -Encoding ASCII  C:\r53.json

# Set CNAME
(aws --region $AWSREGION route53 change-resource-record-sets --hosted-zone-id $Route53zone  --change-batch file://C:\r53.json)

1 comment: