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

Tech 1048/cacluate cost elastic ip #703

Merged
merged 4 commits into from
Apr 7, 2023

Conversation

jakepage91
Copy link
Contributor

Hey there!

I've added a cost calculation part for Elastic IPs here. But, the AWS Go SDK doesn't let me find the exact creation time of the Elastic IP. So, I've come up with a workaround that calculates the cost of unassociated Elastic IPs from the moment they're first fetched. This isn't perfect, though, as it may give inaccurate cost calculations. Unassociated IP addresses will only start counting towards the cost after Komiser fetches them, which could lead to underestimating the actual costs.

Can you think of any better way?
Cheers

@mlabouardy mlabouardy added the aws label Apr 4, 2023
@mlabouardy mlabouardy added this to the v3.0.11 milestone Apr 4, 2023
eneskaya
eneskaya previously approved these changes Apr 5, 2023
Comment on lines 46 to 47
fetchedAt := time.Now()
hoursSinceFetched := hoursSince(fetchedAt)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, I approved but now I just saw, that this will be always 0 hours, hence 0$ monthly cost

@eneskaya eneskaya self-requested a review April 5, 2023 07:47
@eneskaya eneskaya dismissed their stale review April 5, 2023 07:53

logical error

Copy link
Collaborator

@mlabouardy mlabouardy left a comment

Choose a reason for hiding this comment

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

You can get the creation date of the IP by leveraging AWS Config.
This command should return the creation date (under configurationItemCaptureTime attribute):
aws configservice batch-get-resource-config --resource-keys resourceType=AWS::EC2::EIP,resourceId=eipalloc-ID_HERE

Screenshot 2023-04-05 at 10 29 48

@jakepage91
Copy link
Contributor Author

Hey there @eneskaya and @mlabouardy just to let you know that I made some updates (thanks for the help Moh!)

@mlabouardy mlabouardy force-pushed the tech-1048/cacluate-cost-elastic-ip branch from ebd1978 to 87d7b92 Compare April 7, 2023 08:12
@mlabouardy mlabouardy self-requested a review April 7, 2023 08:12
Copy link
Collaborator

@mlabouardy mlabouardy left a comment

Choose a reason for hiding this comment

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

@jakepage91 I've added missing AWS permission to IAM policy file as well handled when the permission is missing otherwise the resource won't be collected

@mlabouardy mlabouardy merged commit acd6373 into develop Apr 7, 2023
@mlabouardy mlabouardy deleted the tech-1048/cacluate-cost-elastic-ip branch April 7, 2023 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants