feat(rds): add new check rds_instance_inside_vpc
#5029
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Implemented a check to ensure that Amazon RDS instances are deployed within a Virtual Private Cloud (VPC). This check helps enhance security and network isolation by verifying that RDS instances are not publicly accessible and are properly integrated within a VPC for controlled access.
The way to know if an instance is deployed in a VPC comes across the DBSubnetGroup parameter of the Amazon RDS API, it allows to know if an instance is within a VPC, as this group defines the subnets within a VPC where an RDS instance can be deployed. If the field is present, the instance is in a VPC, and if it's absent, the instance is likely in EC2-Classic.
Another problem that came up during testing of the check is that AWS no longer allows creating an instance outside of a VPC. So, this check would only be useful for verifying old RDS instances, but all new ones will be in a VPC.
This issue also affects the unit test to verify instances not in a VPC because neither boto nor Moto allows me to create an instance outside of a VPC or in the old EC2-Classic environment. Therefore, this unit test needs to be mocked using MagicMock.
Description
Added new check
rds_instance_inside_vpc
with its unit tests.Checklist
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.