Skip to content

Commit

Permalink
Merge pull request #2514 from TimeIncOSS/f-aws-vpc-cidr-validation
Browse files Browse the repository at this point in the history
provider/aws: Add validation for aws_vpc.cidr_block
  • Loading branch information
phinze committed Jun 26, 2015
2 parents 3e9ed9c + f424085 commit 0aa1854
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions builtin/providers/aws/resource_aws_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"fmt"
"log"
"net"
"time"

"github.com/aws/aws-sdk-go/aws"
Expand All @@ -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{
Expand Down

0 comments on commit 0aa1854

Please sign in to comment.