|
|
|
|
@ -24,15 +24,13 @@ type AMIConfig struct {
|
|
|
|
|
AMISriovNetSupport bool `mapstructure:"sriov_support"`
|
|
|
|
|
AMIForceDeregister bool `mapstructure:"force_deregister"`
|
|
|
|
|
AMIForceDeleteSnapshot bool `mapstructure:"force_delete_snapshot"`
|
|
|
|
|
RawAMIEncryptBootVolume config.Trilean `mapstructure:"encrypt_boot"`
|
|
|
|
|
AMIEncryptBootVolume config.Trilean `mapstructure:"encrypt_boot"`
|
|
|
|
|
AMIKmsKeyId string `mapstructure:"kms_key_id"`
|
|
|
|
|
AMIRegionKMSKeyIDs map[string]string `mapstructure:"region_kms_key_ids"`
|
|
|
|
|
SnapshotTags TagMap `mapstructure:"snapshot_tags"`
|
|
|
|
|
SnapshotUsers []string `mapstructure:"snapshot_users"`
|
|
|
|
|
SnapshotGroups []string `mapstructure:"snapshot_groups"`
|
|
|
|
|
AMISkipBuildRegion bool `mapstructure:"skip_save_build_region"`
|
|
|
|
|
|
|
|
|
|
AMIEncryptBootVolume *bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func stringInSlice(s []string, searchstr string) bool {
|
|
|
|
|
@ -63,10 +61,9 @@ func (c *AMIConfig) Prepare(accessConfig *AccessConfig, ctx *interpolate.Context
|
|
|
|
|
|
|
|
|
|
errs = append(errs, c.prepareRegions(accessConfig)...)
|
|
|
|
|
|
|
|
|
|
c.AMIEncryptBootVolume = c.RawAMIEncryptBootVolume.ToBoolPointer()
|
|
|
|
|
// Prevent sharing of default KMS key encrypted volumes with other aws users
|
|
|
|
|
if len(c.AMIUsers) > 0 {
|
|
|
|
|
if len(c.AMIKmsKeyId) == 0 && c.AMIEncryptBootVolume != nil && *c.AMIEncryptBootVolume {
|
|
|
|
|
if len(c.AMIKmsKeyId) == 0 && c.AMIEncryptBootVolume.True() {
|
|
|
|
|
errs = append(errs, fmt.Errorf("Cannot share AMI encrypted with default KMS key"))
|
|
|
|
|
}
|
|
|
|
|
if len(c.AMIRegionKMSKeyIDs) > 0 {
|
|
|
|
|
@ -96,7 +93,7 @@ func (c *AMIConfig) Prepare(accessConfig *AccessConfig, ctx *interpolate.Context
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(c.SnapshotUsers) > 0 {
|
|
|
|
|
if len(c.AMIKmsKeyId) == 0 && c.AMIEncryptBootVolume != nil && *c.AMIEncryptBootVolume {
|
|
|
|
|
if len(c.AMIKmsKeyId) == 0 && c.AMIEncryptBootVolume.True() {
|
|
|
|
|
errs = append(errs, fmt.Errorf("Cannot share snapshot encrypted with default KMS key"))
|
|
|
|
|
}
|
|
|
|
|
if len(c.AMIRegionKMSKeyIDs) > 0 {
|
|
|
|
|
|