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:
commit
0aa1854127
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue