GithubHelp home page GithubHelp logo

chase439 / jets-demo Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 156 KB

This is a Ruby on Jets demo app utilizing AWS Lambda and other AWS services. http://rubyonjets.com

Ruby 38.94% JavaScript 22.32% SCSS 1.40% HTML 37.34%

jets-demo's Introduction

Jets Project

I used AWS Cloud9 for development and got this project working on 5/6/2021. Deployment was successfully. API endpoints work.

My procedure includes:

  • create an admin role or jets minimal deploy role: https://rubyonjets.com/docs/extras/minimal-deploy-iam/cli/
  • create Cloud9 env
  • config IAM role of Cloud9
    • Stop/edit/start EC2 of cloud9 to use admin IAM role
    • Disable cloud9 managed temporary credentials from its Preferences to use EC2 IAM Role
  • Install and use ruby 2.7 (supported by lambda layers)
  • install latest bundler b/c it was using version 1.
    • verify you have no ~/.bundle/config
  • install jq: sudo yum install jq
  • Create RDS: latest MariaDB, jets-demo, admin password, left everything else default
    • admin, D********
    • test connection: mysql -h $HOST -P 3306 -u admin -p
    • ssl ca = rds-ca-2019; VPC same as EC2
    • Allow remote connection to RDS
    • PASSWORD=`openssl rand -base64 8`
    • APPLICATION=demo
    • HOST=xxxx
    • mysql -h $HOST -u admin --execute="CREATE USER '${APPLICATION}'@'%' IDENTIFIED BY '${PASSWORD}'" -p
      • SHOW GRANTS FOR 'admin'@'%';
      • You can't grant SUPER privilege on RDS, so you can't use the ALL PRIVILEGES shortcut.This is an RDS restriction.
    • mysql -h $HOST -u admin --execute="CREATE DATABASE ${APPLICATION}_development" -p
    • mysql -h $HOST -u admin --execute="USE ${APPLICATION}_development; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, CREATE VIEW, EVENT, TRIGGER, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EXECUTE ON ${APPLICATION}_development.* TO ' ${APPLICATION}'@'%';" -p
    • mysql -h $HOST -u admin --execute="CREATE DATABASE ${APPLICATION}_test" -p
    • mysql -h $HOST -u admin --execute="USE ${APPLICATION}_test; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, CREATE VIEW, EVENT, TRIGGER, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EXECUTE ON demo_test.* TO 'demo'@'%';" -p
  • update .env.development and .env.test to include database credentials
  • touch db/seeds.rb # for jets db:setup
  • Upgrade Node verison
    • Install NVM: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
    • npm install yarn -g
  • add .nvmrc and .ruby-version
  • jets webpacker:install:erb
  • rm app/javascript/packs/hello_erb.js.erb
  • bundle && yarn
  • jets db:setup
  • jets serve --port $PORT # https://docs.aws.amazon.com/cloud9/latest/user-guide/app-preview.html#app-preview-preview-app (8080, 8081, or 8082)
  • Cloud9 > Preview > Preview Running Application
  • Fix gem layer for deploy
    • bundle config path ~/jets-gems/ruby/2.7.0
    • mkdir -p ~/jets-gems/ruby/2.7.0
    • bundle
    • cd ~/jets-gems
    • zip -r demo_gems ruby #=> demo_gems.zip
    • aws s3 cp demo_gems.zip s3://jets-demo-rails # upload zip to s3
    • Create lambda layer and point it to uploaded zip file in S3
    • edit config/application.rb, add gem lambda layer
  • jets deploy
  • jets url # provides url of the lambda endpoint
  • View Log (Cloudwatch) to troubleshoot any app errors. There's a log group for each lambda function.
  • Config Custom Domain Name

jets-demo's People

Contributors

rapidror avatar chase439 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.