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

fix: use relative path as lambda function local package path #98

Conversation

b6pzeusbc54tvhw5jgpyw8pwz2x6gs
Copy link
Contributor

@b6pzeusbc54tvhw5jgpyw8pwz2x6gs b6pzeusbc54tvhw5jgpyw8pwz2x6gs commented Jan 18, 2022

To avoid unintentional state changes when working in multiple environments,
Use relative path as lambda function local package path.

Before:

  # module.next_image_optimizer.module.image_optimizer.aws_lambda_function.this[0] will be created
  + resource "aws_lambda_function" "this" {
      ...
      + filename                       = "/Users/aluc/projects/terraform-aws-next-js-image-optimization/examples/with-existing-cloudfront/.terraform/modules/next_image_optimizer.lambda_content/download/@millihq/tf-next-image-optimization/dist.zip"
      ...

As seen in Before, if the filename is set to an absolute path, the username is included, and the lambda function is updated even if it is the same source in another user's environment.

After:

  # module.next_image_optimizer.module.image_optimizer.aws_lambda_function.this[0] will be created
  + resource "aws_lambda_function" "this" {
      ...
      + filename                       = ".terraform/modules/next_image_optimizer.lambda_content/download/@millihq/tf-next-image-optimization/dist.zip"
      ...

In After, setting the relative path based on cwd, update is attempted only when the actual source code is changed.

PR of other related projects:

to avoid unintentional state changes when working in multiple environments.
Copy link
Member

@ofhouse ofhouse left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ofhouse ofhouse merged commit b8c15c9 into milliHQ:main Jan 22, 2022
@b6pzeusbc54tvhw5jgpyw8pwz2x6gs b6pzeusbc54tvhw5jgpyw8pwz2x6gs deleted the use-relative-path-from-download-npm-module branch January 22, 2022 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants