Skip to content

Commit ae9ef2a

Browse files
Added a flag to allow users to pass a custom Customer Managed Key to encrypt the volume. The default behaviour is to use aws/ebs alias when no key is specified and encryption is turned on
1 parent de41505 commit ae9ef2a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/amazonec2/amazonec2.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ type Driver struct {
126126
DisableSSL bool
127127
UserDataFile string
128128
EncryptEbsVolume bool
129-
130-
spotInstanceRequestId string
129+
spotInstanceRequestId string
130+
KmsKeyId string
131131
}
132132

133133
type clientFactory interface {
@@ -299,6 +299,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
299299
Usage: "Encrypt the EBS volume using the AWS Managed CMK",
300300
EnvVar: "AWS_ENCRYPT_EBS_VOLUME",
301301
},
302+
mcnflag.StringFlag{
303+
Name: "amazonec2-kms-key",
304+
Usage: "Custom KMS key using the AWS Managed CMK",
305+
Value: "alias/aws/ebs",
306+
EnvVar: "AWS_KMS_KEY",
307+
},
302308
}
303309
}
304310

@@ -397,6 +403,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
397403
d.OpenPorts = flags.StringSlice("amazonec2-open-port")
398404
d.UserDataFile = flags.String("amazonec2-userdata")
399405
d.EncryptEbsVolume = flags.Bool("amazonec2-encrypt-ebs-volume")
406+
d.KmsKeyId = flags.String("amazonec2-kms-key")
400407

401408
d.DisableSSL = flags.Bool("amazonec2-insecure-transport")
402409

@@ -606,6 +613,7 @@ func (d *Driver) innerCreate() error {
606613
VolumeType: aws.String(d.VolumeType),
607614
DeleteOnTermination: aws.Bool(true),
608615
Encrypted: aws.Bool(d.EncryptEbsVolume),
616+
KmsKeyId: aws.String(d.KmsKeyId),
609617
},
610618
}
611619
netSpecs := []*ec2.InstanceNetworkInterfaceSpecification{{

0 commit comments

Comments
 (0)