Merge pull request #8387 from DanHam/fix-validate-aws-vpc-info

Only validate the user has provided a subnet_id when vpc_id has been set
This commit is contained in:
Wilken Rivera 2019-11-19 14:56:04 -05:00 committed by GitHub
commit c5df4ed2a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 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
}

View File

@ -11,11 +11,8 @@ import (
//DescribeVpcs mocks an ec2.DescribeVpcsOutput for a given input
func (m *mockEC2Conn) DescribeVpcs(input *ec2.DescribeVpcsInput) (*ec2.DescribeVpcsOutput, error) {
m.lock.Lock()
m.copyImageCount++
m.lock.Unlock()
if input == nil || len(input.VpcIds) == 0 {
if input == nil || aws.StringValue(input.VpcIds[0]) == "" {
return nil, fmt.Errorf("oops looks like we need more input")
}