Skip to content

Commit

Permalink
Removing homebrew and nvm.sh (#3)
Browse files Browse the repository at this point in the history
* Removing homebrew and nvm.sh

Removing the local usage of homebrew and sourcing nvm.sh as this is
outside of the scope of Terraform.

When using the module the environment should be setup to have nvm and
enable the use of it. This is enough to allow building in other
environments and build systems like Jenkins or Atlantis.

* Revert "Removing homebrew and nvm.sh"

This reverts commit 45a4f7a.

* Remove homebrew and trust nvm is available.

Removing homebrew as that is platform specific and trusting nvm is
available to set the nodejs version.

NVM is being used with the -s flag during initial install to ensure it
works on Alpine Linux which has to have custom nodejs versions compiled
due to the libc difference.

This is going to cause the module to take longer to run.

Co-authored-by: Rob Lazzurs <[email protected]>
  • Loading branch information
lazzurs and lazzurs authored Jun 30, 2020
1 parent 805d144 commit 8b28e4b
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,7 @@
resource "null_resource" "provision_nodejs" {
provisioner "local-exec" {
command = <<EOF
if [ ! $(brew list nvm 2>/dev/null) ]; then
brew install nvm &&\
cat <<END >> ~/.bash_profile
export NVM_DIR="$HOME/.nvm"
[ -s "`brew --prefix nvm`/nvm.sh" ] && . "`brew --prefix nvm`/nvm.sh" # This loads nvm
[ -s "`brew --prefix nvm`/etc/bash_completion.d/nvm" ] && . "`brew --prefix nvm`/etc/bash_completion.d/nvm" # This loads nvm bash_completion
END
. ~/.bash_profile 2>/dev/null
else
. `brew --prefix nvm`/nvm.sh 2>/dev/null
fi
nvm install ${var.nodejs_version} &&\
nvm install -s ${var.nodejs_version} &&\
nvm use ${var.nodejs_version}
EOF
}
Expand All @@ -40,7 +29,6 @@ if [ ! -d "build" ]; then
unzip -q cloudfront-auth-${var.cloudfront_auth_brach}.zip -d build/
mkdir build/cloudfront-auth-${var.cloudfront_auth_brach}/distributions
. $(brew --prefix nvm)/nvm.sh 2>/dev/null
nvm use ${var.nodejs_version}
cp ${data.local_file.build-js.filename} build/cloudfront-auth-${var.cloudfront_auth_brach}/build/build.js&&\
cd build/cloudfront-auth-${var.cloudfront_auth_brach} && npm i minimist shelljs && npm install && cd build && npm install
Expand Down Expand Up @@ -70,7 +58,6 @@ resource "null_resource" "build_lambda" {

provisioner "local-exec" {
command = <<EOF
. $(brew --prefix nvm)/nvm.sh 2>/dev/null
nvm use ${var.nodejs_version}&&\
cd build/cloudfront-auth-${var.cloudfront_auth_brach} && node build/build.js --AUTH_VENDOR=${var.auth_vendor} --CLOUDFRONT_DISTRIBUTION=${var.cloudfront_distribution} --CLIENT_ID=${var.client_id} --CLIENT_SECRET=${var.client_secret == "" ? "none" : var.client_secret} --BASE_URL=${var.base_uri} --REDIRECT_URI=${var.redirect_uri} --HD=${var.hd} --SESSION_DURATION=${var.session_duration} --AUTHZ=${var.authz} --GITHUB_ORGANIZATION=${var.github_organization}
EOF
Expand Down

0 comments on commit 8b28e4b

Please sign in to comment.