Merge pull request #2039 from stephenchu/master

Added support for 'comment' field for an AWS route53 zone resource.
This commit is contained in:
Clint 2015-05-22 07:11:19 -05:00
commit 11f67ddc39
3 changed files with 15 additions and 2 deletions

View File

@ -29,6 +29,12 @@ func resourceAwsRoute53Zone() *schema.Resource {
ForceNew: true, ForceNew: true,
}, },
"comment": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "Managed by Terraform",
},
"vpc_id": &schema.Schema{ "vpc_id": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
@ -61,10 +67,9 @@ func resourceAwsRoute53Zone() *schema.Resource {
func resourceAwsRoute53ZoneCreate(d *schema.ResourceData, meta interface{}) error { func resourceAwsRoute53ZoneCreate(d *schema.ResourceData, meta interface{}) error {
r53 := meta.(*AWSClient).r53conn r53 := meta.(*AWSClient).r53conn
comment := &route53.HostedZoneConfig{Comment: aws.String("Managed by Terraform")}
req := &route53.CreateHostedZoneInput{ req := &route53.CreateHostedZoneInput{
Name: aws.String(d.Get("name").(string)), Name: aws.String(d.Get("name").(string)),
HostedZoneConfig: comment, HostedZoneConfig: &route53.HostedZoneConfig{Comment: aws.String(d.Get("comment").(string))},
CallerReference: aws.String(time.Now().Format(time.RFC3339Nano)), CallerReference: aws.String(time.Now().Format(time.RFC3339Nano)),
} }
if v := d.Get("vpc_id"); v != "" { if v := d.Get("vpc_id"); v != "" {

View File

@ -203,6 +203,12 @@ func testAccCheckRoute53ZoneExistsWithProvider(s *terraform.State, n string, zon
return fmt.Errorf("Hosted zone err: %v", err) return fmt.Errorf("Hosted zone err: %v", err)
} }
aws_comment := *resp.HostedZone.Config.Comment
rs_comment := rs.Primary.Attributes["comment"]
if rs_comment != "" && rs_comment != aws_comment {
return fmt.Errorf("Hosted zone with comment '%s' found but does not match '%s'", aws_comment, rs_comment)
}
if !*resp.HostedZone.Config.PrivateZone { if !*resp.HostedZone.Config.PrivateZone {
sorted_ns := make([]string, len(resp.DelegationSet.NameServers)) sorted_ns := make([]string, len(resp.DelegationSet.NameServers))
for i, ns := range resp.DelegationSet.NameServers { for i, ns := range resp.DelegationSet.NameServers {
@ -272,6 +278,7 @@ func testAccLoadTagsR53(zone *route53.GetHostedZoneOutput, td *route53.ResourceT
const testAccRoute53ZoneConfig = ` const testAccRoute53ZoneConfig = `
resource "aws_route53_zone" "main" { resource "aws_route53_zone" "main" {
name = "hashicorp.com" name = "hashicorp.com"
comment = "Custom comment"
tags { tags {
foo = "bar" foo = "bar"

View File

@ -54,6 +54,7 @@ resource "aws_route53_record" "dev-ns" {
The following arguments are supported: The following arguments are supported:
* `name` - (Required) This is the name of the hosted zone. * `name` - (Required) This is the name of the hosted zone.
* `comment` - (Optional) A comment for the hosted zone. Defaults to 'Managed by Terraform'.
* `tags` - (Optional) A mapping of tags to assign to the zone. * `tags` - (Optional) A mapping of tags to assign to the zone.
* `vpc_id` - (Optional) The VPC to associate with a private hosted zone. Specifying `vpc_id` will create a private hosted zone. * `vpc_id` - (Optional) The VPC to associate with a private hosted zone. Specifying `vpc_id` will create a private hosted zone.
* `vpc_region` - (Optional) The VPC's region. Defaults to the region of the AWS provider. * `vpc_region` - (Optional) The VPC's region. Defaults to the region of the AWS provider.