throw error if encrypted ami is shared

This commit is contained in:
Ali Hamidi 2016-05-12 09:21:44 -07:00
parent 6b7ed3aaab
commit c6a527dc46
2 changed files with 13 additions and 0 deletions

View File

@ -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
}

View File

@ -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")
}
}