Home > other >  Route53 - Error while creating TXT type dns record (powershell)
Route53 - Error while creating TXT type dns record (powershell)

Time:03-06

I'm using Powershell to create a TXT record using sample code from AWS documentation

$change = New-Object Amazon.Route53.Model.Change
$change.Action = "CREATE"
$change.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet
$change.ResourceRecordSet.Name = "<domain name provided>"
$change.ResourceRecordSet.Type = "TXT"
$change.ResourceRecordSet.TTL = 600
$change.ResourceRecordSet.ResourceRecords.Add(@{Value="item 1 item 2 item 3"})

$params = @{
HostedZoneId="<Zone ID provided>"
ChangeBatch_Comment="Test"
ChangeBatch_Change=$change
}

Edit-R53ResourceRecordSet @params

Above code gives the error - "Edit-R53ResourceRecordSet : [Invalid Resource Record: 'FATAL problem: InvalidCharacterString (Value should be enclosed in quotation marks) encountered with 'item 1 item 2 item 3'']"

If I try to create an A type record with an IP (Value=IP address) with the same code, it works fine.

CodePudding user response:

The documentation seems to indicate you need inline quotation marks around each record value, so you'll want to do something like:

$change.ResourceRecordSet.ResourceRecords.Add(@{Value='"item 1 item 2 item 3"'})
  • Related