Terraform: guide with Resource Creation Order When Using Provider-Specific Lifecycle Meta-Arguments
Quick question that's been bugging me - I'm experiencing problems with resource creation order in my Terraform configuration when using lifecycle meta-arguments, specifically `create_before_destroy`. I have a scenario where I need to replace an existing AWS Lambda function with a new one, but I also want to ensure that the new function is fully created and ready before the old one is destroyed. My current configuration looks like this: ```hcl resource "aws_lambda_function" "example" { function_name = "my_lambda_function" s3_bucket = "my_bucket" s3_key = "lambda/my_lambda.zip" handler = "index.handler" runtime = "nodejs14.x" lifecycle { create_before_destroy = true } } ``` However, when I run `terraform apply`, I get the following behavior: ``` behavior: Invalid function configuration on main.tf line 1: 1: resource "aws_lambda_function" "example" { Inconsistent function configuration: The new function and the existing function do not share the same memory size or timeout. ``` I've tried adjusting the memory size and timeout in the resource block, but the behavior continues. I also verified that there are no conflicting settings in my variables. Additionally, I attempted to use `depends_on` to explicitly set the dependency order, but it didn’t resolve the scenario. Here's how I defined the `depends_on`: ```hcl resource "aws_lambda_function" "example" { # ... other configurations ... depends_on = [aws_iam_role.lambda_exec_role] } ``` I'm using Terraform version 1.4.5 and the AWS provider version 5.0.0. Can someone explain why this behavior is occurring and how I can ensure that the new Lambda function is created before the old one is destroyed? Any insights or best practices would be greatly appreciated! I'm working on a REST API that needs to handle this. Is this even possible?