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 support for separate deployments of infra and code #175

Merged
merged 7 commits into from
Aug 20, 2021
Merged

Conversation

anoshi
Copy link
Contributor

@anoshi anoshi commented Jul 15, 2021

Description

Ignores changes to the source code hash of the lambda function code to maintain an idempotent terraform build in cases where the application code (lambda package) deployment is managed by an external pipeline / party.

Because the content of lifecycle ignore_changes lists cannot be dynamically generated, this update simply sets the aws_lambda_function's optional argument source_code_hash to null if the new variable ignore_source_code_hash is set to true.

Motivation and Context

Allow terraform to manage infrastructure components and application developers to manage the application code

Breaking Changes

none

How Has This Been Tested?

  • I have tested this against multiple concurrent calls to the module with and without the ignore_source_code_hash variable specified / set to true

anoshi and others added 3 commits July 15, 2021 10:49
* add ignore_changes_package (source code hash) var

* update CHANGELOG
* add ignore_changes_package (source code hash) var

* update CHANGELOG

* ignore_source_code_hash
@anoshi anoshi changed the title ignore_source_code_hash feat: ignore_source_code_hash Jul 15, 2021
@asiegman
Copy link

This change would be useful for us as well.

@vhsantos
Copy link

We have tested it and its works us expected.

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.

You can deploy any package using local_existing_package argument and then update
it and run terraform apply again to redeploy it.

See this:

create_package = false
local_existing_package = "${path.module}/../fixtures/python3.8-zip/existing_package.zip"

There is no need for extra work unless I am missing something important.

@anoshi
Copy link
Contributor Author

anoshi commented Aug 20, 2021

G'day Anton, love your work. You've contributed a massive amount to Terraform and its uptake. Thank you!

The purpose of this update is for Terraform not to manage the deployed code but only the lambda resource and associated attributes, triggers, etc. This update allows another group (e.g. pure developers) to publish the lambda code package on their own schedule and via a separate pipeline i.e. not through terraform apply, and for Terraform not to track the state of the deployed code package.

I don't believe the module currently supports this type of infrastructure vs code behaviour?

@antonbabenko
Copy link
Member

@anoshi 👍 Thanks for the explanation - I now understand the use case! :)

Let me finish this PR a bit and extend it to work with Lambda Layers also.

@antonbabenko antonbabenko changed the title feat: ignore_source_code_hash feat: Add support for separate deployments of infra and code Aug 20, 2021
@antonbabenko antonbabenko merged commit 508f0d5 into terraform-aws-modules:master Aug 20, 2021
@antonbabenko
Copy link
Member

Thanks for the PR!

v2.10.0 has been just released.

@github-actions
Copy link

github-actions bot commented Nov 9, 2022

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 Nov 9, 2022
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.

None yet

4 participants