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

AWS EC2 health codebundle #3

Open
wants to merge 57 commits into
base: main
Choose a base branch
from

Conversation

saurabh3460
Copy link
Contributor

This code bundle contains task to check for old AWS EC2 instances in AWS account in specified region.

saurabh3460 and others added 30 commits November 20, 2024 17:14
@saurabh3460 saurabh3460 force-pushed the ec2 branch 2 times, most recently from 3652218 to 35e139c Compare December 18, 2024 06:49
@saurabh3460
Copy link
Contributor Author

Tested with age 2min = 0.00139

image
image

cc @stewartshea

... cmd=custodian run -r ${AWS_REGION} --output-dir ${OUTPUT_DIR}/aws-c7n-ec2-health ${CURDIR}/old-ec2-instances.yaml --cache-period 0
... secret__aws_access_key_id=${AWS_ACCESS_KEY_ID}
... secret__aws_secret_access_key=${AWS_SECRET_ACCESS_KEY}
${count}= RW.CLI.Run Cli
Copy link
Contributor

Choose a reason for hiding this comment

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

This likely is more complicated that it needs to be. Why evaluate a 1 or a 0 when this is a single check - the total count is a fine metric to push, and then SLI alerts can be configured as needed. This only makes sense as a 1 or a 0 if you want to perform an aggregate score across multiple tasks. Do you plan on adding more tasks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

next code bundle like AutoScaling Group - Verify ASGs have valid configurations comes under EC2 instance so I was thinking to include in this EC2 health codebundle



*** Tasks ***
List old AWS EC2 instances in AWS Region `${AWS_REGION}` in AWS account `${AWS_ACCOUNT_ID}`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need more than one task here to evaluate "AWS EC2 Health" - otherwise this is just a codebundle that is focused on "AWS EC2 Age" - let's come up with a few more tasks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, what is the idea behind this task? It seems normal for a user to have a "running" instance older than "60 days"... are the defaults here appropriate? Are we checking the right thing? One task might be to look for EC2 instances that are not in a running state and older than a specific age. Another task might be to look for instances that need a refresh (e.g. running over a certain age, since it implies a lack of patch/update?).

Copy link
Contributor Author

@saurabh3460 saurabh3460 Dec 18, 2024

Choose a reason for hiding this comment

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

Yes, because sometimes instances get patched and restart, and if an instance is quite old, it becomes difficult to patch since it will require numerous updates. This means that old instances can indicate unpatchable systems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and yes agree we can also look for stopped instances as well that too make sense.

@stewartshea
Copy link
Contributor

@saurabh3460 I've added a few comments which we can discuss - this was not a thorough review, as I think we need to think through the purpose of this codebundle a little more before a full review can be performed.

@saurabh3460
Copy link
Contributor Author

tested unpatched and unused tasks:
Screenshot from 2024-12-19 20-09-52
Screenshot from 2024-12-19 20-11-50

let me know if next steps looks ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants