throw error if encrypted ami is shared
This commit is contained in:
parent
6b7ed3aaab
commit
c6a527dc46
|
@ -55,6 +55,10 @@ func (c *AMIConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
c.AMIRegions = regions
|
||||
}
|
||||
|
||||
if len(c.AMIUsers) > 0 && c.AMIEncryptBootVolume {
|
||||
errs = append(errs, fmt.Errorf("Cannot share AMI with encrypted boot volume"))
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return errs
|
||||
}
|
||||
|
|
|
@ -58,3 +58,12 @@ func TestAMIConfigPrepare_regions(t *testing.T) {
|
|||
c.AMISkipRegionValidation = false
|
||||
|
||||
}
|
||||
|
||||
func TestAMIConfigPrepare_EncryptBoot(t *testing.T) {
|
||||
c := testAMIConfig()
|
||||
c.AMIUsers = []string{"testAccountID"}
|
||||
c.AMIEncryptBootVolume = true
|
||||
if err := c.Prepare(nil); err == nil {
|
||||
t.Fatal("should have error")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue