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

feat(autoscaling): add new check autoscaling_group_using_ec2_launch_template #5346

Conversation

danibarranqueroo
Copy link
Member

Context

This new check ensures that Amazon EC2 Auto Scaling groups are created using Amazon EC2 launch templates. Using launch templates provides access to the latest features and improvements, compared to launch configurations, and allows for more flexible and efficient management of Auto Scaling group settings.

Additionally, an ASG can utilize a Mixed Instances Policy to combine different instance types within the same group. Within this policy, a Launch Template can also be specified. In this case, the LaunchTemplate field is located within the MixedInstancesPolicy structure rather than at the root of the ASG.

So, if we only verify the LaunchTemplate field at the ASG level, you might overlook ASGs that use Launch Templates within a Mixed Instances Policy. Therefore, to ensure thoroughness and accuracy in your verification, it is crucial to examine both locations.

Description

Added new check autoscaling_group_launch_template 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.

@danibarranqueroo danibarranqueroo requested review from a team as code owners October 9, 2024 11:34
@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label Oct 9, 2024
Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.38%. Comparing base (3c929bd) to head (c5ee0b5).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5346      +/-   ##
==========================================
- Coverage   89.43%   89.38%   -0.05%     
==========================================
  Files        1027     1028       +1     
  Lines       31531    31551      +20     
==========================================
+ Hits        28200    28203       +3     
- Misses       3331     3348      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -0,0 +1,32 @@
{
"Provider": "aws",
"CheckID": "autoscaling_group_launch_template",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"CheckID": "autoscaling_group_launch_template",
"CheckID": "autoscaling_group_using_ec2_launch_template",

report.resource_tags = group.tags
report.status = "PASS"
report.status_extended = (
f"Autoscaling group {group.name} is using a launch template."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Autoscaling group {group.name} is using a launch template."
f"Autoscaling group {group.name} is using a EC2 launch template."

):
report.status = "FAIL"
report.status_extended = (
f"Autoscaling group {group.name} is not using a launch template."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Autoscaling group {group.name} is not using a launch template."
f"Autoscaling group {group.name} is not using a EC2 launch template."

@MrCloudSec MrCloudSec changed the title feat(autoscaling): add new check autoscaling_group_launch_template feat(autoscaling): add new check autoscaling_group_using_ec2_launch_template Oct 14, 2024
@MrCloudSec MrCloudSec self-requested a review October 14, 2024 14:13
@MrCloudSec MrCloudSec merged commit dfc8e3e into master Oct 14, 2024
10 of 11 checks passed
@MrCloudSec MrCloudSec deleted the PRWLR-4449-ensure-amazon-ec-2-auto-scaling-groups-use-amazon-ec-2-launch-templates branch October 14, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/aws Issues/PRs related with the AWS provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants