From a87f2a7987be055de773f5139a80c53c3cb88248 Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Tue, 15 Jul 2014 12:18:36 -0400 Subject: [PATCH] providers/aws: elb, eip config validations --- builtin/providers/aws/resource_aws_eip.go | 10 ++++++++++ .../providers/aws/resource_aws_eip_test.go | 1 - builtin/providers/aws/resource_aws_elb.go | 18 +++++++++++++++++ builtin/providers/aws/resources.go | 20 ++++++++++--------- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/builtin/providers/aws/resource_aws_eip.go b/builtin/providers/aws/resource_aws_eip.go index 326b20467..2410aeee5 100644 --- a/builtin/providers/aws/resource_aws_eip.go +++ b/builtin/providers/aws/resource_aws_eip.go @@ -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", + }, + } +} diff --git a/builtin/providers/aws/resource_aws_eip_test.go b/builtin/providers/aws/resource_aws_eip_test.go index f81b7ebca..d23d0da83 100644 --- a/builtin/providers/aws/resource_aws_eip_test.go +++ b/builtin/providers/aws/resource_aws_eip_test.go @@ -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" } diff --git a/builtin/providers/aws/resource_aws_elb.go b/builtin/providers/aws/resource_aws_elb.go index d74c7afd6..823de083a 100644 --- a/builtin/providers/aws/resource_aws_elb.go +++ b/builtin/providers/aws/resource_aws_elb.go @@ -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", + }, + } +} diff --git a/builtin/providers/aws/resources.go b/builtin/providers/aws/resources.go index 6fae00164..8648b8d39 100644 --- a/builtin/providers/aws/resources.go +++ b/builtin/providers/aws/resources.go @@ -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{