terraform-cloudfront-auth icon indicating copy to clipboard operation
terraform-cloudfront-auth copied to clipboard

What are the prerequisites on the local machine?

Open couling opened this issue 1 year ago • 1 comments

I don't see any discussion in the README of what the prerequisites are on the local machine for running this. I've installed node with brew install node. But on my mac I'm still getting an error on one of the null resources:

│ Error: local-exec provisioner error
│ 
│   with module.cloudfront_auth.null_resource.build_lambda,
│   on .terraform/modules/cloudfront_auth/main.tf line 38, in resource "null_resource" "build_lambda":
│   38:   provisioner "local-exec" {
│ 
│ Error running command 'cd build/cloudfront-auth-master && node build/build.js --AUTH_VENDOR='google' --CLOUDFRONT_DISTRIBUTION='blog.couling.uk'
│ --CLIENT_ID='xxx' --CLIENT_SECRET='xxx' --REDIRECT_URI='https://example.com/callback' --SESSION_DURATION='1' --AUTHZ="1"
│ --HD="example.com"': exit status 1. Output: node:internal/modules/cjs/loader:1093
│   throw err;
│   ^
│ 
│ Error: Cannot find module 'shelljs'
│ Require stack:
│ - /Users/philip/Documents/Development/scratch/biket/build/cloudfront-auth-master/build/build.js
│     at Module._resolveFilename (node:internal/modules/cjs/loader:1090:15)
│     at Module._load (node:internal/modules/cjs/loader:934:27)
│     at Module.require (node:internal/modules/cjs/loader:1157:19)
│     at require (node:internal/modules/helpers:119:18)
│     at Object.<anonymous> (/Users/philip/Documents/Development/scratch/biket/build/cloudfront-auth-master/build/build.js:1:15)
│     at Module._compile (node:internal/modules/cjs/loader:1275:14)
│     at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
│     at Module.load (node:internal/modules/cjs/loader:1133:32)
│     at Module._load (node:internal/modules/cjs/loader:972:12)
│     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
│   code: 'MODULE_NOT_FOUND',
│   requireStack: [
│     '/Users/philip/Documents/Development/scratch/biket/build/cloudfront-auth-master/build/build.js'
│   ]
│ }
│ 
│ Node.js v19.8.1
│ 
╵

couling avatar Mar 21 '23 14:03 couling

Even after using npm install -g to install:

shelljs
prompt
axios
colors
ramda
minimist

And setting the environment variable: NODE_PATH=/usr/local/lib/node_modules...

Terraform will apply. But then I get an error suggesting the lambda is failing. Running a test, the lambda says:

Runtime.ImportModuleError: Error: Cannot find module 'jsonwebtoken'"

And I can confirm that no nodejs dependencies were packaged inside the lambda.

At this point I'm totally stuck.

couling avatar Mar 21 '23 16:03 couling