gpt4 book ai didi

amazon-web-services - AWS Terraform Lambda 预置并发

转载 作者:行者123 更新时间:2023-12-04 15:02:19 24 4
gpt4 key购买 nike

我正在尝试获得预配置的并发性以使用我的 API 网关支持的 Lambda 函数。
以下配置不起作用,AWS 似乎完全忽略了预配置的并发性并且会冷启动。

resource "aws_lambda_function" "user_history" {
publish = true
filename = "../distribution/target/distribution/user-history.jar"
function_name = "user-history_${var.user}_${terraform.workspace}"
role = aws_iam_role.lambda.arn
source_code_hash = filebase64sha256("../distribution/target/distribution/user-history.jar")
runtime = "java11"
timeout = 240
memory_size = 512
}

resource "aws_api_gateway_integration" "user_history" {
rest_api_id = aws_api_gateway_rest_api.vnm_api.id
resource_id = aws_api_gateway_resource.user_history.id
http_method = aws_api_gateway_method.user_history.http_method
integration_http_method = "POST"
type = "AWS_PROXY"
uri = aws_lambda_function.user_history.invoke_arn
}

resource "aws_lambda_provisioned_concurrency_config" "user_history_provisioning" {
function_name = aws_lambda_function.user_history.function_name
provisioned_concurrent_executions = 2
count = var.provisioning == true ? 1 : 0
qualifier = aws_lambda_function.user_history.version
}
认为它可能与未指定的版本有关我尝试按照此处接受的答案添加配置: Terraform - what is the URI to invoke lambda via alias?
resource "aws_lambda_alias" "user_history_alias"{
name = "user_history_version"
description = "Versioned alias"
function_name = aws_lambda_function.user_history.arn
function_version = aws_lambda_function.user_history.version
}

data "aws_lambda_function" "user_history" {
function_name = aws_lambda_function.user_history.function_name
qualifier = "user_history_version"
}

resource "aws_api_gateway_integration" "user_history" {
uri = aws_lambda_function.user_history.user_history_version.invoke_arn
}
但现在我收到一个错误,指出 This object has no argument, nested block, or exported attribute named "user_history_version"有谁知道如何让我的预配置并发工作?

最佳答案

您走在正确的轨道上 - 如果您使用不合格的 lambda arn,则在 $LATEST 处引用该版本,而您的预配并发使用最新发布的版本。
您可以通过引用别名 ARN ( aws_lambda_alias. user_history_alias.arn ) 来解决您的问题,或者,如果您不需要其他别名,请引用 aws_lambda_function.user_history.qualified_arn ,这将是最新发布的版本。

关于amazon-web-services - AWS Terraform Lambda 预置并发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66763336/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com