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 #261

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.tf_next.module.statics_deploy.module.deploy_trigger.aws_lambda_function.this[0] will be created
  + resource "aws_lambda_function" "this" {
      ...
      + filename                       = "/Users/aluc/projects/terraform-aws-next-js/examples/complete/.terraform/modules/tf_next.statics_deploy.lambda_content/download/@millihq/terraform-next-deploy-trigger/dist.zip"
      ...

  # module.tf_next.module.proxy.module.edge_proxy.aws_lambda_function.this[0] will be created
  + resource "aws_lambda_function" "this" {
      ...
      + filename                       = "/Users/aluc/projects/terraform-aws-next-js/examples/complete/.terraform/modules/tf_next.proxy.proxy_package/download/@millihq/terraform-next-proxy/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.tf_next.aws_lambda_function.this["__NEXT_PAGE_LAMBDA_0"] will be created
  + resource "aws_lambda_function" "this" {
      ...
      + filename                       = "./.next-tf/lambdas/__NEXT_PAGE_LAMBDA_0.zip"
      ...

  # module.tf_next.module.statics_deploy.module.deploy_trigger.aws_lambda_function.this[0] will be created
  + resource "aws_lambda_function" "this" {
      ...
      + filename                       = ".terraform/modules/tf_next.statics_deploy.lambda_content/download/@millihq/terraform-next-deploy-trigger/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.
@ofhouse ofhouse merged commit c064db3 into milliHQ:main Jan 23, 2022
@ofhouse ofhouse added this to the Next Iteration milestone Jan 23, 2022
@b6pzeusbc54tvhw5jgpyw8pwz2x6gs b6pzeusbc54tvhw5jgpyw8pwz2x6gs deleted the use-relative-path-from-download-npm-module branch January 23, 2022 16:22
@ofhouse
Copy link
Member

ofhouse commented Jan 23, 2022

This has now been released in v0.11.2.

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