provider/aws: Add validation for aws_vpc.cidr_block

- closes #2340
This commit is contained in:
Radek Simko 2015-06-25 11:20:54 +01:00
parent a76105b0f1
commit f424085f44
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{