Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a check for AMI encryption #889

Merged
merged 5 commits into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 7 additions & 2 deletions pkg/ami/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ func Use(ec2api ec2iface.EC2API, ng *api.NodeGroup) error {
return fmt.Errorf("%q is an instance-store AMI and EBS block device mappings not supported for instance-store AMIs", ng.AMI)
}

if *output.Images[0].RootDeviceType == "ebs" && !api.IsSetAndNonEmptyString(ng.VolumeName) {
ng.VolumeName = output.Images[0].RootDeviceName
if *output.Images[0].RootDeviceType == "ebs" {
if !api.IsSetAndNonEmptyString(ng.VolumeName) {
ng.VolumeName = output.Images[0].RootDeviceName
}
if ng.VolumeEncrypted == nil {
ng.VolumeEncrypted = output.Images[0].BlockDeviceMappings[0].Ebs.Encrypted
}
}

return nil
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ type NodeGroup struct {
// +optional
VolumeName *string `json:"volumeName,omitempty"`
// +optional
VolumeEncrypted *bool `json:"volumeEncrypted,omitempty"`
// +optional
MaxPodsPerNode int `json:"maxPodsPerNode,omitempty"`

// +optional
Expand Down
3 changes: 3 additions & 0 deletions pkg/cfn/builder/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ var _ = Describe("CloudFormation template builder API", func() {
*ng.VolumeType = api.NodeVolumeTypeIO1
ng.VolumeName = new(string)
*ng.VolumeName = "/dev/xvda"
ng.VolumeEncrypted = api.Disabled()
*ng.VolumeEncrypted = false
adamjohnson01 marked this conversation as resolved.
Show resolved Hide resolved

if withFullVPC {
cfg.VPC = testVPC()
Expand Down Expand Up @@ -403,6 +405,7 @@ var _ = Describe("CloudFormation template builder API", func() {
VolumeSize: aws.Int(2),
VolumeType: aws.String(api.NodeVolumeTypeIO1),
VolumeName: aws.String("/dev/xvda"),
VolumeEncrypted: api.Disabled(),
IAM: &api.NodeGroupIAM{
WithAddonPolicies: api.NodeGroupIAMAddonPolicies{
ImageBuilder: api.Disabled(),
Expand Down
1 change: 1 addition & 0 deletions pkg/cfn/builder/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (n *NodeGroupResourceSet) addResourcesForNodeGroup() error {
Ebs: &gfn.AWSEC2LaunchTemplate_Ebs{
VolumeSize: gfn.NewInteger(*volumeSize),
VolumeType: gfn.NewString(*n.spec.VolumeType),
Encrypted: gfn.NewBoolean(*n.spec.VolumeEncrypted),
},
}}
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/eks/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ func mockDescribeImages(p *mockprovider.MockProvider, expectedNamePattern string
State: aws.String("available"),
OwnerId: aws.String("123"),
RootDeviceType: aws.String("ebs"),
BlockDeviceMappings: []*ec2.BlockDeviceMapping{
{
Ebs: &ec2.EbsBlockDevice{
Encrypted: aws.Bool(false),
},
},
},
},
},
}, nil)
Expand Down