Validate template settings when T2 Unlimited has been enabled
* T2 Unlimited cannot be used with anything other than T2 instance types * T2 Unlimited cannot be used with Spot Instances
This commit is contained in:
parent
482629ae90
commit
be02b3f613
|
@ -6,6 +6,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/common/uuid"
|
"github.com/hashicorp/packer/common/uuid"
|
||||||
|
@ -142,6 +143,18 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
errs = append(errs, fmt.Errorf("shutdown_behavior only accepts 'stop' or 'terminate' values."))
|
errs = append(errs, fmt.Errorf("shutdown_behavior only accepts 'stop' or 'terminate' values."))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.EnableT2Unlimited {
|
||||||
|
if c.SpotPrice != "" {
|
||||||
|
errs = append(errs, fmt.Errorf("Error: T2 Unlimited cannot be used in conjuction with Spot Instances"))
|
||||||
|
}
|
||||||
|
firstDotIndex := strings.Index(c.InstanceType, ".")
|
||||||
|
if firstDotIndex == -1 {
|
||||||
|
errs = append(errs, fmt.Errorf("Error determining main Instance Type from: %s", c.InstanceType))
|
||||||
|
} else if c.InstanceType[0:firstDotIndex] != "t2" {
|
||||||
|
errs = append(errs, fmt.Errorf("Error: T2 Unlimited enabled with a non-T2 Instance Type: %s", c.InstanceType))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue