Skip to content
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

feat: Add source_code_hash var #509

Conversation

Octogonapus
Copy link

Description

This PR adds a source_code_hash variable which overrides the computed hash using a user-supplied value.

Motivation and Context

This change is needed when you are using a lambda zip which is created by Terraform.
Terraform's plan will pick up the hash from an existing zip file.
If the zip file is recreated at apply time, the hash will change and the plan will become inconsistent, leading to an error like this:

╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for module.foo_lambda.module.lambda.aws_lambda_function.this[0] to include new values learned so far during
│ apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for .source_code_hash: was cty.StringVal("2v4cb4VO4El5iGo7/SQ3bLn/lEcSUJAI8o4FBB8u6w0="), but now
│ cty.StringVal("MXbLA/B/BhPwZpVrpD81N27nytZJJ9lXxylwWW5aL0M=").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

There are lots of issues in the AWS provider like this but I'm not sure if they are caused by this exact use case so I won't link them here.

Breaking Changes

No breaking changes; the source code hash is still computed by default.

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

I tested this in my own project.

@Octogonapus Octogonapus changed the title Add source_code_hash var feat: add source_code_hash var Oct 31, 2023
@Octogonapus Octogonapus changed the title feat: add source_code_hash var feat: Add source_code_hash var Oct 31, 2023
@antonbabenko
Copy link
Member

I don't understand what was the exact problem your PR should fix. Please provide the 100% failing case (code + steps), so that I can verify it.

As of now, I am 99.9% sure that this PR is not necessary.

Related to #396 (probably).

@Octogonapus
Copy link
Author

you are right this can be solved another way

@Octogonapus Octogonapus closed this Nov 5, 2023
@Octogonapus Octogonapus deleted the add_source_code_hash_var branch November 5, 2023 03:47
@Octogonapus Octogonapus restored the add_source_code_hash_var branch November 6, 2023 15:27
Copy link

github-actions bot commented Dec 7, 2023

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants