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(aws): add elastic beanstalk environment #1411

Merged

Conversation

lukeadams84
Copy link
Contributor

@lukeadams84 lukeadams84 commented Feb 28, 2022

Objective:

Add support for aws_elastic_beanstalk_environment and aws_elastic_beanstalk_application as FREE. Fixes #1410.

Pricing details:

Price breakdown for elastic beanstalk environments is ec2 instances associated with the environment multiplied by the minimum ASG numbers.

Additional costs are associated for the load balancer type. If StreamLogs is enabled, there can be usage costs for cloudwatch metrics, including ingest, scanning and storage in GB.

Status:

  • Generated the resource files
  • Updated the internal/resources file
  • Updated the internal/provider/terraform/.../resources file
  • Added usage parameters to infracost-usage-example.yml
  • Added test cases without usage-file
  • Added test cases with usage-file
  • Compared test case output to cloud cost calculator
  • Created a PR to update "Supported Resources" in the docs

Issues:

None

@hugorut
Copy link
Contributor

hugorut commented Feb 28, 2022

@lukeadams84 thanks for doing this ❤️ . We've got some big planning meetings today so I might not get to review/look over this today, but i'll endeavour to get back to you as quick as I can.

@hugorut
Copy link
Contributor

hugorut commented Feb 28, 2022

@lukeadams84 thanks again for this. I've had a peek through the code and done some reading. I'm wasn't familiar with elastic beanstalk environments so I appreciate you bringing it to our attention. My initial thoughts though is that we might need to go a different route with this resource than the norm.

My understanding that elastic beanstalk environment essentially simplifies provisioning a set of underlying AWS resources to run an application. In terraform you can change the base set of configuration options for this using the setting block. Because a lot of these settings are resources that Infracost already supports (ec2 instances, autoscaling group, cloudwatch, launch configuration, e.t.c.) my preference would be to use this resource fetch the configuration and then delegate pricing to those Infracost resources.

This would mean that all aws.ElasticBeanstalkEnvironment would do is call other resources like aws.Instance to output their cost components to the CLI. This would be more maintainable in the longer term as it would mitigate code drift between resources that are, under the hood, the same.

Let me consult with the team and get back to you.

@lukeadams84
Copy link
Contributor Author

@lukeadams84 thanks again for this. I've had a peek through the code and done some reading. I'm wasn't familiar with elastic beanstalk environments so I appreciate you bringing it to our attention. My initial thoughts though is that we might need to go a different route with this resource than the norm.

My understanding that elastic beanstalk environment essentially simplifies provisioning a set of underlying AWS resources to run an application. In terraform you can change the base set of configuration options for this using the setting block. Because a lot of these settings are resources that Infracost already supports (ec2 instances, autoscaling group, cloudwatch, launch configuration, e.t.c.) my preference would be to use this resource fetch the configuration and then delegate pricing to those Infracost resources.

This would mean that all aws.ElasticBeanstalkEnvironment would do is call other resources like aws.Instance to output their cost components to the CLI. This would be more maintainable in the longer term as it would mitigate code drift between resources that are, under the hood, the same.

Let me consult with the team and get back to you.

Yes, I understand. I think one of the headaches seems to be that the EC2 instances (for example) that elastic beanstalk uses are more constrained than if you were creating an EC2 instance normally. I believe the instances are always dedicated, and only support Linux as an operating system.

I'll have another look at your examples and see what I can work out to use the existing resources.

@hugorut
Copy link
Contributor

hugorut commented Feb 28, 2022

I'd recommend having a peek at eks node group, launch template or neptune cluster snapshot as they do similiar-ish things

@lukeadams84
Copy link
Contributor Author

I'd recommend having a peek at eks node group, launch template or neptune cluster snapshot as they do similiar-ish things

Okay, have updated now. It looks like it covers the bases.

@hugorut
Copy link
Contributor

hugorut commented Mar 2, 2022

@lukeadams84 amazing - I'll take a peek later

Copy link
Contributor

@hugorut hugorut left a comment

Choose a reason for hiding this comment

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

Starting to shape up nicely. There's a few points to resolve before we get this in though.

infracost-usage-example.yml Outdated Show resolved Hide resolved
internal/resources/aws/elastic_beanstalk_environment.go Outdated Show resolved Hide resolved
internal/resources/aws/elastic_beanstalk_environment.go Outdated Show resolved Hide resolved
internal/resources/aws/elastic_beanstalk_environment.go Outdated Show resolved Hide resolved
internal/resources/aws/elastic_beanstalk_environment.go Outdated Show resolved Hide resolved
internal/resources/aws/elastic_beanstalk_environment.go Outdated Show resolved Hide resolved
@lukeadams84
Copy link
Contributor Author

Can you tell I am new to go? :D Ill get on these, thanks for looking at it.

@hugorut
Copy link
Contributor

hugorut commented Mar 2, 2022

@lukeadams84 not at all! It's just a bit of a bizarre resource, you chose a tricky one to start! Ping here if you have any other questions. Also feel free to message me on slack if you have any ad hoc questions that you want to run by me with a quicker response rate

@lukeadams84 lukeadams84 requested a review from hugorut March 3, 2022 16:06
infracost-usage-example.yml Outdated Show resolved Hide resolved
internal/resources/aws/elastic_beanstalk_environment.go Outdated Show resolved Hide resolved
internal/resources/aws/elastic_beanstalk_environment.go Outdated Show resolved Hide resolved
internal/resources/aws/elastic_beanstalk_environment.go Outdated Show resolved Hide resolved
@hugorut
Copy link
Contributor

hugorut commented Mar 4, 2022

@lukeadams84 we're getting closer, just need to fix up these usage params.

@lukeadams84 lukeadams84 requested a review from hugorut March 4, 2022 16:12
Copy link
Contributor

@hugorut hugorut left a comment

Choose a reason for hiding this comment

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

Minor code tweaks, but logic looks solid

Copy link
Contributor

@hugorut hugorut left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@hugorut hugorut merged commit ded58ac into infracost:master Mar 8, 2022
@hugorut
Copy link
Contributor

hugorut commented Mar 8, 2022

@lukeadams84

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.

Resource to support: aws_elastic_beanstalk_environment
2 participants