-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Breaking change on data source aws_lambda_function introduced in version 2.0.0 #8782
Comments
aws_lambda_function
introduced in version 2.0.0
@bflad If there's interest in fixing this and keep the old behaviour, I may try to work on a PR. |
In order to associate a lambda functions with a CloudFront distribution as Lambda@Edge, it is required to provide a version number. I would be interested to retrieve the latest fixed version number of a given lambda.
|
I ran into this today, and I found a workaround for my setup. It works as I reapply an alias when I deploy new versions. You can then lookup the version number using
Therefore you can use an external data source to run the command:
|
Interesting thoughts @grahamlyus , by doing that it is needed to update the alias manually after each deploy then? It sort of replicates the |
@flosch-hb Yes, it requires updating the alias after each deploy. In my case I deploy the lambda in question separate from my terraform setup via claudiajs which has a |
If you need to get the latest version number, you can now fetch the version behind an alias (e.g. an alias called data "aws_lambda_alias" "latest" {
function_name = "my-lambda-at-edge"
name = "latest"
} You can then use data "aws_lambda_function" "lambda" {
function_name = "my-lambda-at-edge"
qualifier = data.aws_lambda_alias.latest.function_version
} |
Thanks @rprieto for this workaround. Unfortunately, I tried your approach but I still get the |
Hi, apologies using the alias might not work. Fetching the Lambda as above works for me, using |
Thanks @rprieto, I still get $LATEST using |
So the workaround I did was to ensure that Hope this helps someone! |
Lambda created from terraform with publish=true. recieved arn with number use this Did you know where to change the parameter corresponding to publish=true of terraform in Lambda created from AWS GUI? |
If you are using the AWS Console @eretica you will need to create the lambda in You can check out the doco here https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html In Terraform you need to make sure that your region is set to us-east-1 and have |
@rprieto I tried your suggested approach: data "aws_lambda_alias" "latest" {
function_name = "my-lambda-at-edge"
name = "latest"
}
data "aws_lambda_function" "latest-lambda"{
function_name = "my-lambda-at-edge"
qualifier = data.aws_lambda_alias.latest.function_version
} My use in my CloudFront distribution definition: lambda_function_association {
event_type = "viewer-request"
lambda_arn = data.aws_lambda_function.latest-lambda.qualified_arn
} When I do
Do you actually publish the lambda as it sounds like @brucedvgw does? I don't control or access this lambda so I'm still trying to find a way to get the latest lambda version and apply that to my cloudfront distribution. |
Yes I had to publish the function (publish=true) and maintain a manual alias called |
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Terraform Version
Terraform:
0.10.8
Terraform AWS provider:
2.11.0
Affected Resource(s)
aws_lambda_function
Terraform Configuration Files
Expected Behavior
qualified_arn
should be qualified by the latest version number instead of$LATEST
Actual Behavior
qualified_arn
is qualified with$LATEST
References
The breaking change has been introduced in the PR #7663 which has been merged into the provider version
2.0.0
.The
dataSourceAwsLambdaFunctionRead()
implementation switched from usingresourceAwsLambdaFunctionRead()
(defined inresource_aws_lambda_function.go
) to a new (de-coupled) implementation.The
resourceAwsLambdaFunctionRead()
implementation has support to fetch the latest version number in casequalifierExistance
is falsy (see code here), while the new one doesn't have it.Questions, please:
The text was updated successfully, but these errors were encountered: