Merge pull request #2514 from TimeIncOSS/f-aws-vpc-cidr-validation

provider/aws: Add validation for aws_vpc.cidr_block
This commit is contained in:
Paul Hinze 2015-06-26 08:46:29 -05:00
commit 0aa1854127
1 changed files with 11 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package aws
import (
"fmt"
"log"
"net"
"time"
"github.com/aws/aws-sdk-go/aws"
@ -24,6 +25,16 @@ func resourceAwsVpc() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
_, ipnet, err := net.ParseCIDR(value)
if err != nil || ipnet == nil || value != ipnet.String() {
errors = append(errors, fmt.Errorf(
"%q must contain a valid CIDR", k))
}
return
},
},
"instance_tenancy": &schema.Schema{