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 control to use timestamp to trigger the package creation or not (useful for CI/CD) #521

Merged
merged 5 commits into from
Jan 14, 2024

Conversation

samuel-phan
Copy link
Contributor

Description

Add a variable trigger_on_package_timestamp (boolean - defaults to true) to whether use timestamp to trigger the package creation or not.

Motivation and Context

Problem

  1. Use the lambda module to create a lambda. Run terraform apply. The lambda is created.
  2. Delete the builds directory (to simulate a CICD job with an empty environment).
  3. Run terraform plan again, it will detect a drift because the timestamp has changed.

One solution was to add the variable recreate_missing_package = false, but when the CICD job (without any builds directory) runs terraform apply will face this error:

│ Error: Provider produced inconsistent final plan
│
│ When expanding the plan for module.foo_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("cqn6fMnsZk+KB1YcvY+mV9lVQvKZ7T7n+vpBjv/qg3s="), but now
│ cty.StringVal("mM6yOCDC4GsOEw8Sqyb7t1aZPQqbwu/g27igFYoF6ko=").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Solution

Add a variable trigger_on_package_timestamp (boolean - defaults to true) to whether use timestamp to trigger the package creation or not.

Fix #396

Breaking Changes

None.

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 have added an example/simple-cicd with a test.sh inside to run the test scenario.

@samuel-phan samuel-phan changed the title fix: add var.trigger_on_package_timestamp fix: Add var.trigger_on_package_timestamp Dec 13, 2023
Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions bot added the stale label Jan 13, 2024
@samuel-phan
Copy link
Contributor Author

@antonbabenko Would you have some time to take a look at this PR please? 🙇

@github-actions github-actions bot removed the stale label Jan 14, 2024
@antonbabenko antonbabenko changed the title fix: Add var.trigger_on_package_timestamp feat: Add control to use timestamp to trigger the package creation or not (useful for CI/CD) Jan 14, 2024
Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work with this PR and test.sh in particular - it helped a lot!

@antonbabenko antonbabenko merged commit 57dbfc1 into terraform-aws-modules:master Jan 14, 2024
29 checks passed
antonbabenko pushed a commit that referenced this pull request Jan 14, 2024
## [6.7.0](v6.6.0...v6.7.0) (2024-01-14)

### Features

* Add control to use timestamp to trigger the package creation or not (useful for CI/CD) ([#521](#521)) ([57dbfc1](57dbfc1))
@antonbabenko
Copy link
Member

This PR is included in version 6.7.0 🎉

Copy link

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 Feb 14, 2024
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.

Availability to disable timestamp for lambda package
2 participants