File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -622,10 +622,20 @@ func (e EC2Client) MakeLaunchTemplateBlockDeviceMappings(blocks []schemas.BlockD
622622 var LaunchTemplateEbsBlockDevice * ec2.LaunchTemplateEbsBlockDeviceRequest
623623
624624 if enabledEBSEncrypted {
625- keyId , err := e .getKmsKeyIdByAlias (block .KmsAlias )
626- if err != nil {
627- Logger .Fatal (fmt .Sprintf ("Error: %s" , err .Error ()))
625+ var keyId string
626+ var err error
627+
628+ // Priority: KmsKeyId > KmsAlias
629+ if len (block .KmsKeyId ) > 0 {
630+ keyId = block .KmsKeyId
631+ Logger .Infof ("Using provided KMS Key ID: %s" , keyId )
632+ } else {
633+ keyId , err = e .getKmsKeyIdByAlias (block .KmsAlias )
634+ if err != nil {
635+ Logger .Fatal (fmt .Sprintf ("Error: %s" , err .Error ()))
636+ }
628637 }
638+
629639 LaunchTemplateEbsBlockDevice = & ec2.LaunchTemplateEbsBlockDeviceRequest {
630640 VolumeSize : aws .Int64 (block .VolumeSize ),
631641 VolumeType : aws .String (block .VolumeType ),
Original file line number Diff line number Diff line change @@ -249,9 +249,12 @@ type BlockDevice struct {
249249 // Enable Encrypted
250250 Encrypted bool `yaml:"encrypted"`
251251
252- // KMS key
252+ // KMS key alias
253253 KmsAlias string `yaml:"kmsAlias"`
254254
255+ // KMS key ID (ARN or key ID)
256+ KmsKeyId string `yaml:"kmsKeyId"`
257+
255258 // Whether to delete the volume on instance termination
256259 DeleteOnTermination bool `yaml:"delete_on_termination"`
257260}
You can’t perform that action at this time.
0 commit comments