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) Adds Lambda provisioned concurrency #2281

Merged
merged 4 commits into from
Feb 20, 2023

Conversation

robh007
Copy link
Contributor

@robh007 robh007 commented Feb 7, 2023

Adds new resource aws_lambda_provisioned_concurrency_config to support provisioned concurrency in lambda. I think there's potentially more that can be done to merge with aws_lambda_function. I did try to use the references logic within the code but couldn't get it to work. This resource provides 2 cost components, duration & concurrency.

Closes more of #2138

@aliscott aliscott self-requested a review February 8, 2023 09:19
@aliscott aliscott self-assigned this Feb 8, 2023
Copy link
Member

@aliscott aliscott left a comment

Choose a reason for hiding this comment

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

Hi @robh007 thanks this looks excellent. I had a look through the pricing and agree with this approach and not using the references.

In the AWS calculator I'm also seeing $2 'Requests' charge for the example you have in the tests, so it looks like we need another cost component for that.
Screenshot 2023-02-10 at 11 54 30

@robh007
Copy link
Contributor Author

robh007 commented Feb 10, 2023

Hi @robh007 thanks this looks excellent. I had a look through the pricing and agree with this approach and not using the references.

In the AWS calculator I'm also seeing $2 'Requests' charge for the example you have in the tests, so it looks like we need another cost component for that. Screenshot 2023-02-10 at 11 54 30

Hi @aliscott,

Yes that cost component is requests, the requests are needed to generate the Duration cost component. I can add that in no problem. I probably need to document something somewhere, because if you had something like this in your code.

resource "aws_lambda_provisioned_concurrency_config" "without_usage" {
  function_name                     = aws_lambda_function.name
  provisioned_concurrent_executions = 100
  qualifier                         = 1
}

resource "aws_lambda_function" "lambda" {
  function_name = "lambda_function_name"
  role          = "arn:aws:lambda:us-east-1:account-id:resource-id"
  handler       = "exports.test"
  filename      = "function.zip"
  runtime       = "nodejs12.x"
}

With these usage parameters

  aws_lambda_function.my_function:
    monthly_requests: 10000000 # Monthly requests to the Lambda function.
    request_duration_ms: 350 # Average duration of each request in milliseconds.
  
  aws_lambda_provisioned_concurrency_config.my_config:
    monthly_duration_hrs: 730 # Number of hours in a month that provisioned concurrency will be enabled.
    request_duration_ms: 350 # Average duration of each request in milliseconds during the enabled period.
    monthly_requests: 10000000 # Number of requests sent to the function during the enabled period.
    architecture: arm64 # Architecture of the Lambda function.
    memory_mb: 512 # Memory size of the Lambda function.

The estimates for requests are duplicated, I think that's why I wanted to use something with the reference. It probably just needs to highlight the differences somewhere for now. I could use the usage parameters supplied & do some calculation between the lambda_function request & the provisioned concurrency request? Thoughts?

Copy link
Member

@aliscott aliscott left a comment

Choose a reason for hiding this comment

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

Sorry for the delay @robh007. This looks great, thanks!

@aliscott aliscott merged commit cadd5d8 into infracost:master Feb 20, 2023
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.

None yet

2 participants