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

bug: EC2EBSVolumeEncrypted (AwsSolutions-EC26): Non compliant when no volumes are defined #1441

Open
udondan opened this issue Sep 13, 2023 · 1 comment
Labels
other This issue doesn't fit into the other categories

Comments

@udondan
Copy link

udondan commented Sep 13, 2023

What is the problem?

I have an ASG defined like so:

    const asg = new aws_autoscaling.AutoScalingGroup(this, 'asg', {
      ...
      machineImage: ami,
    });

The blockDevices property of the ASG contains this description:

@default

- Uses the block device mapping of the AMI

So my understanding is, that the volumes are encrypted when the AMI device mapping is encrypted. The AMI device indeed is encrypted and so is the volume of resulting EC2 instances of the ASG.

cdk-nag fails with

[Error at /StackName/asg/LaunchConfig] AwsSolutions-EC26: The resource creates one or more EBS volumes that have encryption disabled.

The source of this false positive is

if (blockDeviceMappings == undefined) {
return NagRuleCompliance.NON_COMPLIANT;
} else {

Is this intentional and am I supposed to suppress this? IMHO, when no volumes are defined, there should be nothing to complain about. At very least the error message should be adjusted and instead should point out, that this might be due to use of an AMI without specifically setting blockDevices.

Reproduction Steps

Create and ASG w/o blockDevices.

What did you expect to happen?

Validation pass

What actually happened?

Validation fails

[Error at /StackName/asg/LaunchConfig] AwsSolutions-EC26: The resource creates one or more EBS volumes that have encryption disabled.

cdk-nag version

2.27.129

Language

Typescript

Other information

No response

@udondan udondan added bug Something isn't working needs-triage This issue or PR still needs to be triaged. labels Sep 13, 2023
@dontirun
Copy link
Collaborator

Yes , this is intentional. If you don't explicitly set the root volume on the EC2 instance as encrypted, it will be unencrypted.

The documentation around this rule isn't great 😔, any suggestions?

@dontirun dontirun added other This issue doesn't fit into the other categories and removed bug Something isn't working needs-triage This issue or PR still needs to be triaged. labels Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
other This issue doesn't fit into the other categories
Projects
None yet
Development

No branches or pull requests

2 participants