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 Lambda) Service: AWSLambdaInternal; Status Code: 404; Error Code: ProvisionedConcurrencyConfigNotFoundException #29992

Closed
golesmn opened this issue Apr 29, 2024 · 6 comments
Labels
@aws-cdk/aws-config Related to AWS Config @aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@golesmn
Copy link

golesmn commented Apr 29, 2024

Describe the bug

We have some Lambda functions with scheduled auto-scaling in our sandbox environment. We use auto-scaling to scale down the provisioned concurrency to 0 outside of office hours. However, when we try to update the stack outside of office hours, the update fails due to insufficient provisioned concurrency.
image

If we check the provisioned concurrency outside office hours using cli its the result

image

Expected Behavior

Deploy the stack successfully.

Current Behavior

Lambda provisioned concurrency not set and deployment failed.

Reproduction Steps

  • Make a scalable target for a lambda
  • Set the scheduled provisioned concurrency and set min and max to 0 for first schedule and 1 for other schedule.
  • Let the first schedule run and make sure the current provisioned concurrency is 0
  • Deploy

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.133.0

Framework Version

No response

Node.js Version

16

OS

linux

Language

Python

Language Version

Python3.9

Other information

No response

@golesmn golesmn added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 29, 2024
@github-actions github-actions bot added the @aws-cdk/aws-config Related to AWS Config label Apr 29, 2024
@golesmn golesmn changed the title No Provisioned Concurrency Config found for this function (Service: AWSLambdaInternal; Status Code: 404; Error Code: ProvisionedConcurrencyConfigNotFoundException (AWS Lambda) Service: AWSLambdaInternal; Status Code: 404; Error Code: ProvisionedConcurrencyConfigNotFoundException Apr 29, 2024
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Apr 29, 2024
@pahud
Copy link
Contributor

pahud commented Apr 29, 2024

Thank you for your report.

Can you share full minimal code snippets that represents this issue so we could see more details about your CDK code?

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p2 and removed needs-triage This issue or PR still needs to be triaged. labels Apr 29, 2024
@golesmn
Copy link
Author

golesmn commented Apr 30, 2024

@pahud

def lambda_alias(
    scope: Construct,
    function_name: str,
    function: aws_lambda.Function,
    removal_policy: RemovalPolicy,
    concurrent_execution_value: int,
    scheduled_autoscaling_configs: dict[str, Any],
    autoscaling: bool,
) -> aws_lambda.Alias:
    current_version = function.current_version
    alias = aws_lambda.Alias(
        scope=scope,
        id=f"{function_name}FunctionAlias",
        alias_name=get_alias_name(function_name),
        version=current_version,
        provisioned_concurrent_executions=concurrent_execution_value,
    )
    alias.apply_removal_policy(removal_policy)

    if autoscaling:
        scaling_target = aws_applicationautoscaling.ScalableTarget(
            scope=scope,
            id=f"{function_name}ScalableTarget",
            service_namespace=aws_applicationautoscaling.ServiceNamespace.LAMBDA,
            min_capacity=0,
            max_capacity=concurrent_execution_value,
            resource_id=f"function:{function_name}:{get_alias_name(function_name)}",
            scalable_dimension="lambda:function:ProvisionedConcurrency",
        )
        scaling_target.node.add_dependency(alias)

        scaling_down_starting_hour = str(
            scheduled_autoscaling_configs.get("scaleInStartingHour")
        )
        scaling_down_ending_hour = str(
            scheduled_autoscaling_configs.get("scaleInEndingHour")
        )

        night_schedule = aws_applicationautoscaling.Schedule.cron(
            hour=scaling_down_starting_hour, minute="0"
        )
        scaling_target.scale_on_schedule(
            id=f"{function_name}ScheduledDownScaling",
            schedule=night_schedule,
            max_capacity=0,
            min_capacity=0,
            time_zone=TimeZone.EUROPE_BERLIN,
        )
        morning_schedule = aws_applicationautoscaling.Schedule.cron(
            hour=scaling_down_ending_hour,
            minute="45",
        )
        scaling_target.scale_on_schedule(
            id=f"{function_name}ScheduledUpScaling",
            schedule=morning_schedule,
            min_capacity=concurrent_execution_value,
            max_capacity=concurrent_execution_value,
            time_zone=TimeZone.EUROPE_BERLIN,
        )

    return alias

here concurrent_execution_value is 0 for night schedule and > 1 for morning schedule.

@nmussy
Copy link
Contributor

nmussy commented Apr 30, 2024

ProvisionedConcurrencyConfigNotFoundException seems like a CloudFormation error, and I'm not sure there's a lot that should be done in the CDK code base for this specific use-case. What you should be able to do is use custom resources to update the concurrency on the fly, scaling up the capacity before the update and lowering it after it's done

@golesmn
Copy link
Author

golesmn commented Apr 30, 2024

@nmussy

ProvisionedConcurrencyConfigNotFoundException seems like a CloudFormation error, and I'm not sure there's a lot that should be done in the CDK code base for this specific use-case. What you should be able to do is use custom resources to update the concurrency on the fly, scaling up the capacity before the update and lowering it after it's done

Yeah we were thinking the same. But I was looking if we could do it without scaling up before deployment. But it seems we can't :)

@golesmn golesmn closed this as completed Apr 30, 2024
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@nmussy
Copy link
Contributor

nmussy commented Apr 30, 2024

@nmussy

ProvisionedConcurrencyConfigNotFoundException seems like a CloudFormation error, and I'm not sure there's a lot that should be done in the CDK code base for this specific use-case. What you should be able to do is use custom resources to update the concurrency on the fly, scaling up the capacity before the update and lowering it after it's done

Yeah we were thinking the same. But I was looking if we could do it without scaling up before deployment. But it seems we can't :)

Yeah, it's one of those unfortunate things with CloudFormation. When you do come up with the solution, feel free to leave it here in case someone stumbles on the same issue in the future 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-config Related to AWS Config @aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants