Skip to content

Commit

Permalink
Merge pull request #1396 from hashicorp/f-aws-route53record-add-update
Browse files Browse the repository at this point in the history
provider/aws: Change Route 53 record to allow resource updates
  • Loading branch information
catsby committed Apr 8, 2015
2 parents 650b9d5 + c2b293d commit 28f8dab
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions builtin/providers/aws/resource_aws_route53_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func resourceAwsRoute53Record() *schema.Resource {
return &schema.Resource{
Create: resourceAwsRoute53RecordCreate,
Read: resourceAwsRoute53RecordRead,
Update: resourceAwsRoute53RecordUpdate,
Delete: resourceAwsRoute53RecordDelete,

Schema: map[string]*schema.Schema{
Expand All @@ -42,14 +43,12 @@ func resourceAwsRoute53Record() *schema.Resource {
"ttl": &schema.Schema{
Type: schema.TypeInt,
Required: true,
ForceNew: true,
},

"records": &schema.Schema{
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Required: true,
ForceNew: true,
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Expand All @@ -58,6 +57,19 @@ func resourceAwsRoute53Record() *schema.Resource {
}
}

func resourceAwsRoute53RecordUpdate(d *schema.ResourceData, meta interface{}) error {
// Route 53 supports CREATE, DELETE, and UPSERT actions. We use UPSERT, and
// AWS dynamically determines if a record should be created or updated.
// Amazon Route 53 can update an existing resource record set only when all
// of the following values match: Name, Type
// (and SetIdentifier, which we don't use yet).
// See http://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets_Requests.html#change-rrsets-request-action
//
// Because we use UPSERT, for resouce update here we simply fall through to
// our resource create function.
return resourceAwsRoute53RecordCreate(d, meta)
}

func resourceAwsRoute53RecordCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).r53conn
zone := cleanZoneID(d.Get("zone_id").(string))
Expand Down

0 comments on commit 28f8dab

Please sign in to comment.