This article summarizes the verification of "Jets", a serverless framework made by Ruby. The environment is Windows 10, but I am using WSL (Debian) because Jets does not work on Windows.
The purpose of this time is to guarantee the operation of DynamoDB table design and data access design.
List the commands executed when the environment was actually built.
WSL Install WSL (Ubuntu or Debian) from the Windows Store.
sudo apt update
sudo apt upgrade
sudo apt install -y make gcc libssl-dev libreadline-dev zlib1g-dev git curl wget unzip
Ruby See the Ruby part of the article below https://qiita.com/ksh-fthr/items/64a4e86c8bad08322c94#3-rbenv-%E3%82%92%E5%85%A5%E3%82%8C%E3%82%88%E3%81%86
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
~/.rbenv/bin/rbenv init
vi .bashrc
source ~/.bashrc
rbenv install -l
rbenv install 2.6.6
rbenv rehash
rbenv global 2.6.6
ruby -v
Jets https://qiita.com/gotchane/items/fd3c1e54f7bdaa4ab813
sudo apt install -y nodejs npm
sudo npm install -g yarn
gem install jets
jets new project name
dynamodb local https://symfoware.blog.fc2.com/blog-entry-2207.html
sudo apt install openjdk-11-jre
wget https://s3-ap-northeast-1.amazonaws.com/dynamodb-local-tokyo/dynamodb_local_latest.tar.gz
mkdir dynamodb
tar zxf dynamodb_local_latest.tar.gz -C ./dynamodb
cd dynamodb/
java -D"java.library.path=./DynamoDBLocal_lib" -jar DynamoDBLocal.jar -sharedDb
dynamodb-admin https://www.npmjs.com/package/dynamodb-admin
npm install -g dynamodb-admin
export DYNAMO_ENDPOINT=http://localhost:8000
dynamodb-admin
aws-cli https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/install-cliv2-linux.html
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
/usr/local/bin/aws --version
aws configure
→ Appropriate key in CUI,set id(test_id, test_key etc.)
aws dynamodb list-tables --endpoint-url http://localhost:8000
→ Check connection
Environment construction is over
The following articles were very helpful in verifying Jets, which has little information. https://qiita.com/gotchane/items/fd3c1e54f7bdaa4ab813 https://qiita.com/gotchane/items/d998b49dcaa31fe286b9 https://qiita.com/gotchane/items/b412295bee48ba827715
--Changed table_namespace in config/dynamodb.yml --table_namespace: ○○○○ (project name, etc.)
--Created by dynamodb-admin --It is necessary to create the model described later. --For how to create a table with dynamodb-admin, please refer to the previously written this article. --Created by Jets migration - https://rubyonjets.com/reference/jets-dynamodb-generate/ --Example: jets dynamodb: generate create_users --partition-key user_id: string --sort-key delete_flg: number
When creating a table with dyanamodb-admin, create a model of the created table with the following contents. Example: When the Users table is created, create the "user.rb" file under app/models.
class model name(User etc.) < Dynomite::Item
end
--Execute "jets c" in the project directory to start the console -Create a query by referring to dynomite
create_user = User.new(user_id: "test1_name", user_name: "test1", user_email: "[email protected]", delete_flg: 0)
create_user.replace
User.find(user_id:"test1_name", delete_flg:0)
--As described in the section on creating a table, Jets migration, in which a migration file is created, is ideal for creating a table. However, with the current amount of Jets information, an appropriate method for setting GSI and LSI could not be found at once. ――It is best to set GSI and LSI based on the data access design, but it may be necessary to change it depending on the situation. In that case, if you use dynamod b-admin, you need to recreate the table. --The Jets file running on WSL was operated with VScode started on Windows. --Please refer to here etc. for the procedure such as installing RemoteWSL.
I couldn't test the migration with a mysql2 gem error in my environment. I solved it with the following command.
gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'
Official: https://rubyonjets.com/ https://qiita.com/gotchane/items/fd3c1e54f7bdaa4ab813 https://qiita.com/gotchane/items/d998b49dcaa31fe286b9 https://qiita.com/gotchane/items/b412295bee48ba827715
Since Ruby on Jets was created by AWS container HERO, an AWS specialist with only about 5 people in the world, I felt that it was highly reliable and functional. However, since it is currently maintained by almost one person, it is necessary to carefully judge the application to the production environment. If you are interested, please see the following article. https://qiita.com/gotchane/items/02b9c539bfaf3a69d76e
We would like to thank @gotchane for compiling many Jets articles.
Recommended Posts