I was learning terraform and was asked to provision it for CI/CD pipeline at gitlab. My doubt is that ,
Let's say a lambda function is already running/live. How can I provision it using terraform ? Should I use data block to consume the running aws lambda? Or this isn't how it works ! I am not sure how can we do this. I searched the docs which isn't supporting this use case.
So with the Lambda function that is already running, basically here you have two use cases:
terraform import aws_lambda_function.my_lambda existing_lambda_function_name
Note: Please note that the my_lambda function is your terraform block of code that is defining the exact Lambda that is already running, this is to match the existing resource with your code Terraform, to then be added to the state. I hope that it is clear
data "aws_lambda_function" "existing_lambda" {
function_name = var.function_name
}
And somewhere else in your code you can use it as follows:
function_name = data.aws_lambda_function.existing_lambda
I hope this was helpful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With