-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Terraform tracks changes in your infrastructure based on the resources you define in your configuration files. Even if you only modify the README file in your repository, if you are using Terraform's remote state management and have version control configured to trigger Terraform runs on any changes, it will reapply the entire configuration.
Here are some possible reasons why Terraform might be updating the aws_lambda_layer_version
and aws_lambda_function
resources:
-
Dependencies: The Lambda function might depend on the changes you made, even if it's not directly related to the README file. If any resource the Lambda function relies on changes, Terraform will update it as well.
-
Source Code Hashes: Terraform uses source code hashes to determine if the Lambda function's source code has changed. Even if you only changed the README, if the source code hash changes (for instance, due to the zip file including timestamps or metadata), Terraform will consider it a change and update the Lambda function.
-
Remote State Changes: If your Terraform state is stored remotely (e.g., in an S3 bucket), and your pipeline triggers a Terraform run on any change in the repository, Terraform will compare the remote state with the current configuration, detecting changes and updating resources as necessary.
To minimize unintended updates, you can:
- Refine your triggering mechanism in the pipeline to only execute Terraform when necessary, perhaps by excluding changes to certain files.
- Review your dependencies to ensure they are properly defined. If a resource depends on external factors that shouldn't affect its configuration, consider isolating or decoupling those dependencies.
- Double-check your Terraform state management strategy to ensure it aligns with your workflow and requirements.
By carefully managing your Terraform workflow and understanding its behavior, you can reduce the likelihood of unexpected updates.