moia-oss / bastion-host-forward

CDK Construct for creating a bastion host to forward a connection to several AWS data services inside a private subnet from your local machine
https://www.npmjs.com/package/@moia-oss/bastion-host-forward
Apache License 2.0
31 stars 6 forks source link

Bastion Host EBS encryption #317

Closed glmourad closed 9 months ago

glmourad commented 1 year ago

Hi,

The construct is not compliant with the following Config rule once the EBS volume attached to the instance is not encrypted: https://docs.aws.amazon.com/config/latest/developerguide/encrypted-volumes.html

Is it possible to add parameters in order to specify if volume is needed or not? If can't remove the ebs volume I would say to add the "encrypted=True" option to the volume and optionally specify a KMS key.

Thanks in advance!

e-dixo commented 11 months ago

For now we are dealing with it in the following way:

...
        self._bastion_host = BastionHostForward(
            self,
            "BastionHostAuroraServerless",
            vpc=self._vpc,
            name="gdl-auroraserverless-bastionhost",
            security_group=bastion_host_security_group,
            address=self._aurora_db.db_cluster.cluster_endpoint.hostname,
            port=str(self._aurora_db.db_cluster.cluster_endpoint.port),
        )

        cdk.Aspects.of(self).add(EncryptEbsInEc2Instance())

@jsii.implements(cdk.IAspect)
class EncryptEbsInEc2Instance:
    def visit(self, node):
        if isinstance(node, ec2.CfnInstance):
            node.add_property_override(
                property_path="BlockDeviceMappings",
                value=[
                    {
                        "DeviceName": "/dev/xvda",
                        "Ebs": {
                            "Encrypted": "true",
                            "VolumeSize": 8,
                            "VolumeType": "gp3",
                        },
                    },
                ],
            )
snowiow commented 9 months ago

Hi, we included this now into the bastion host for v2.0.0