Class 64th AWS Project day 3 July 10th
Create one more lambda function
Step1:Need to create below lambda function
Environment variables DB_HOST,DB_NAME,DB_USER, DB_PASS
If you stared with Signup go to loacal singup folder code install the msql pip install pymysql -t.
Create Mysql steps:
Aurora and RDS> Create database
Single(A-Z) DB instance deployment (1 instance)
DB Instance Identifier :Digital-library
Credential Settings >Self managed > admin /admin1234
DB Instance Class >Burstable Classes :db.t4g.micro
Public access :Yes
Click Create database
Step5:
Endpoint :digital-library.c5iyik8mi7ym.eu-west-2.rds.amazonaws.com
User admin
password:admin1234
Database Schema creaion: CREATE DATABASE IF NOT EXISTS digital_library; USE digital_library;
CREATE TABLE IF NOT EXISTS users ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, mobile VARCHAR(20) NOT NULL, email VARCHAR(100) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, gender VARCHAR(10), location VARCHAR(100), image VARCHAR(255) );
CREATE TABLE IF NOT EXISTS books ( id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(255) NOT NULL, author VARCHAR(255), available BOOLEAN DEFAULT TRUE );
CREATE TABLE IF NOT EXISTS history ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT, book_id INT, borrow_date DATETIME, return_date DATETIME, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (book_id) REFERENCES books(id) ON DELETE CASCADE );
INSERT INTO books (title, author, available) VALUES ('Wings of Fire', 'A.P.J. Abdul Kalam', TRUE), ('The Guide', 'R.K. Narayan', TRUE), ('Godan', 'Munshi Premchand', TRUE), ('Train to Pakistan', 'Khushwant Singh', TRUE), ('Ignited Minds', 'A.P.J. Abdul Kalam', TRUE), ('Mahabharata', 'Ved Vyasa', TRUE), ('Python Crash Course', 'Eric Matthes', TRUE), ('Digital Fortress', 'Dan Brown', TRUE), ('You Can Win', 'Shiv Khera', TRUE), ('Zero to One', 'Peter Thiel', TRUE);
Environment variables DB_HOST:digital-library.c5iyik8mi7ym.eu-west-2.rds.amazonaws.com
,DB_NAME=digital_library,DB_USER=admin ,DB_PASS=admin1234
Step6: Give Connection details to the lambda function click save
Step7: add LayerStep9:Every function add the code deploy and add the environment variable all the remaining functions
Step10:
Step11: Create API Gateways
Step14: Select below option for Signup API choose correspinding lambda function create create method
Step21: We missed Integration Input parameter adding Signup Click Save Step22:Signin Integration mapping templated
Step24: Every not required upload lambda function runtime file to All lambda function instead of them you just add the layer for the every lambda function
--Thanks
No comments:
Post a Comment