Only validate the user has provided a subnet_id when vpc_id has been set

This commit is contained in:
DanHam 2019-11-19 14:05:24 +00:00
parent 3571c585bb
commit 074be9942d
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
1 changed files with 4 additions and 2 deletions

View File

@ -121,8 +121,10 @@ func (s *StepPreValidate) Run(ctx context.Context, state multistep.StateBag) mul
}
func (s *StepPreValidate) checkVpc(conn ec2iface.EC2API) error {
if s.VpcId != "" && s.SubnetId != "" {
// skip validation if both VpcId and SubnetId are provided; AWS API will error if something is wrong.
if s.VpcId == "" || (s.VpcId != "" && s.SubnetId != "") {
// Skip validation if:
// * The user has not provided a VpcId.
// * Both VpcId and SubnetId are provided; AWS API will error if something is wrong.
return nil
}