Merge pull request #1396 from hashicorp/f-aws-route53record-add-update

provider/aws: Change Route 53 record to allow resource updates
This commit is contained in:
Clint 2015-04-08 15:14:46 -05:00
commit 28f8dab87f

View File

@ -18,6 +18,7 @@ func resourceAwsRoute53Record() *schema.Resource {
return &schema.Resource{
Create: resourceAwsRoute53RecordCreate,
Read: resourceAwsRoute53RecordRead,
Update: resourceAwsRoute53RecordUpdate,
Delete: resourceAwsRoute53RecordDelete,
Schema: map[string]*schema.Schema{
@ -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))
},
@ -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))