Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions pkg/aws/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,20 @@ func (e EC2Client) MakeLaunchTemplateBlockDeviceMappings(blocks []schemas.BlockD
var LaunchTemplateEbsBlockDevice *ec2.LaunchTemplateEbsBlockDeviceRequest

if enabledEBSEncrypted {
keyId, err := e.getKmsKeyIdByAlias(block.KmsAlias)
if err != nil {
Logger.Fatal(fmt.Sprintf("Error: %s", err.Error()))
var keyId string
var err error

// Priority: KmsKeyId > KmsAlias
if len(block.KmsKeyId) > 0 {
keyId = block.KmsKeyId
Logger.Infof("Using provided KMS Key ID: %s", keyId)
} else {
keyId, err = e.getKmsKeyIdByAlias(block.KmsAlias)
if err != nil {
Logger.Fatal(fmt.Sprintf("Error: %s", err.Error()))
}
}

LaunchTemplateEbsBlockDevice = &ec2.LaunchTemplateEbsBlockDeviceRequest{
VolumeSize: aws.Int64(block.VolumeSize),
VolumeType: aws.String(block.VolumeType),
Expand Down
5 changes: 4 additions & 1 deletion pkg/schemas/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,12 @@ type BlockDevice struct {
// Enable Encrypted
Encrypted bool `yaml:"encrypted"`

// KMS key
// KMS key alias
KmsAlias string `yaml:"kmsAlias"`

// KMS key ID (ARN or key ID)
KmsKeyId string `yaml:"kmsKeyId"`

// Whether to delete the volume on instance termination
DeleteOnTermination bool `yaml:"delete_on_termination"`
}
Expand Down