Skip to content

Instantly share code, notes, and snippets.

@sofyan-ahmad
Created October 21, 2018 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sofyan-ahmad/d93cc1ee8e512f624b9310b32e5ec2a9 to your computer and use it in GitHub Desktop.
Save sofyan-ahmad/d93cc1ee8e512f624b9310b32e5ec2a9 to your computer and use it in GitHub Desktop.
AWS Elasticbeasnstalk NodeJS 10.x and Yarn
# file: .ebextensions/01-yarn.config
commands:
01_create_npmrc:
# run this command from /tmp directory
cwd: /tmp
command: 'sudo touch /tmp/.npmrc \
| sudo echo \
"//registry.npmjs.org/:_authToken=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k NPM_TOKEN)" \
| sudo tee /tmp/.npmrc'
02_remove_clean_and_install_latest_nodejs:
# run this command from /tmp directory
cwd: /tmp
test: '[ -f /usr/bin/node ] && echo "remove previouse node"'
command: 'sudo yum remove -y nodejs | sudo rm /etc/yum.repos.d/nodesource*'
03_node_get:
# run this command from /tmp directory
cwd: /tmp
# flag -y for no-interaction installation
command: 'sudo curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -'
04_node_install:
# run this command from /tmp directory
cwd: /tmp
command: 'sudo yum -y install nodejs'
05_yarn_get:
# run this command from /tmp directory
cwd: /tmp
# don't run the command if yarn is already installed (file /usr/bin/yarn exists)
test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
command: 'sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo'
06_yarn_install:
# run this command from /tmp directory
cwd: /tmp
test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
command: 'sudo yum -y install yarn'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment