providers/aws: elb, eip config validations

This commit is contained in:
Jack Pearkes 2014-07-15 12:18:36 -04:00
parent 3c3e584beb
commit a87f2a7987
4 changed files with 39 additions and 10 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"log"
"github.com/hashicorp/terraform/helper/config"
"github.com/hashicorp/terraform/helper/diff"
"github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/goamz/ec2"
@ -200,3 +201,12 @@ func resource_aws_eip_retrieve_address(id string, vpc bool, ec2conn *ec2.EC2) (*
return &address, nil
}
func resource_aws_eip_validation() *config.Validator {
return &config.Validator{
Optional: []string{
"vpc",
"instance",
},
}
}

View File

@ -105,7 +105,6 @@ func testAccCheckAWSEIPExists(n string, res *ec2.Address) resource.TestCheckFunc
const testAccAWSEIPConfig = `
resource "aws_eip" "bar" {
name = "foobar-terraform-test"
image_id = "ami-fb8e9292"
instance_type = "t1.micro"
}

View File

@ -5,6 +5,7 @@ import (
"log"
"github.com/hashicorp/terraform/flatmap"
"github.com/hashicorp/terraform/helper/config"
"github.com/hashicorp/terraform/helper/diff"
"github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/goamz/elb"
@ -185,3 +186,20 @@ func resource_aws_elb_retrieve_balancer(id string, elbconn *elb.ELB) (*elb.LoadB
return &loadBalancer, nil
}
func resource_aws_elb_validation() *config.Validator {
return &config.Validator{
Required: []string{
"name",
"availability_zones.*",
"listener.*",
"listener.*.instance_port",
"listener.*.instance_protocol",
"listener.*.lb_port",
"listener.*.lb_protocol",
},
Optional: []string{
"instances",
},
}
}

View File

@ -20,18 +20,20 @@ func init() {
},
"aws_elb": resource.Resource{
Create: resource_aws_elb_create,
Update: resource_aws_elb_update,
Destroy: resource_aws_elb_destroy,
Diff: resource_aws_elb_diff,
Refresh: resource_aws_elb_refresh,
ConfigValidator: resource_aws_elb_validation(),
Create: resource_aws_elb_create,
Update: resource_aws_elb_update,
Destroy: resource_aws_elb_destroy,
Diff: resource_aws_elb_diff,
Refresh: resource_aws_elb_refresh,
},
"aws_eip": resource.Resource{
Create: resource_aws_eip_create,
Destroy: resource_aws_eip_destroy,
Diff: resource_aws_eip_diff,
Refresh: resource_aws_eip_refresh,
ConfigValidator: resource_aws_eip_validation(),
Create: resource_aws_eip_create,
Destroy: resource_aws_eip_destroy,
Diff: resource_aws_eip_diff,
Refresh: resource_aws_eip_refresh,
},
"aws_instance": resource.Resource{