Questions tagged with Microservices

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

Hi team, we are working in accelerator account AWS ASEA, that has no outbound connectivity we can not connect to internet to download anything (libraries, ....) the VPC is private only. our task is to fetch data from twitter and do - twitter data processing - sentiment Analysis .. we would like to know **if there is a way to achieve this when our account doesn't have outbound(internet) connectivity**? could you please advice best practices/architecture to do this scenarios (twitter data processing, sentiment Analysis) ? Thank you
1
answers
0
votes
16
views
Jess
asked 2 days ago
I am trying to create new connection for a new api destination for an EventBridge rule. The api destination is to a service hosted in AWS. I am trying to setup Oauth Client Credentials. I am trying to re-use credentials that are in the AWS Secrets Manager. I keep getting the following error: Invalid target fields. Complete all required fields for the new connection correctly. I am not being told what field is incorrect. Is there a way to know which connection field is wrong? Is trying to re-use credentials in the secrets manager possible?
0
answers
0
votes
16
views
asked 2 days ago
Login request was received, the username and password were correctly extracted from the request body, and a user with ID 1 was found in the database. The form still 504 fails eventually. my index.js, db.js, users.js, and login.html all seem fine. I'm on Lightsail so unfortunately I've had to use SQL Workbench this whole time. Not sure if there's an issue with the Lightsail to DB communication? It's been a pain to try to figure out Lightsail with the 'module' stuff like databases. users.js : ``` const connection = require('./db'); const bcrypt = require('bcrypt'); const saltRounds = 10; class User { constructor(id, username, password, email, createdAt, updatedAt) { this.id = id; this.username = username; this.password = password; this.email = email; this.createdAt = createdAt; this.updatedAt = updatedAt; } static create(username, password, email) { const now = new Date().toISOString(); const sql = `INSERT INTO loginserver (username, password, email, created_at, updated_at) VALUES (?, ?, ?, ?, ?)`; bcrypt.hash(password, saltRounds, (err, hash) => { if (err) { console.error('Error hashing password:', err); return; } const values = [username, hash, email, now, now]; connection.query(sql, values, (err, result) => { if (err) { console.error('Error creating user:', err); return; } console.log('User created with ID', result.insertId); const user = new User(result.insertId, username, hash, email, now, now); return user; }); }); } static getByUsername(username) { const sql = `SELECT * FROM loginserver WHERE username = ?`; connection.query(sql, [username], (err, results) => { if (err) { console.error('Error getting user by username:', err); return; } if (results.length === 0) { console.log('User not found'); return null; } const { id, username, password, email, created_at, updated_at } = results[0]; console.log('User found with ID', id); const user = new User(id, username, password, email, created_at, updated_at); return user; }); } checkPassword(password) { return new Promise((resolve, reject) => { bcrypt.compare(password, this.password, (err, isMatch) => { if (err) { console.error('Error checking password:', err); reject(err); } else { resolve(isMatch); } }); }); } update() { const now = new Date().toISOString(); const sql = `UPDATE loginserver SET username = ?, password = ?, email = ?, updated_at = ? WHERE id = ?`; const values = [this.username, this.password, this.email, now, this.id]; connection.query(sql, values, (err) => { if (err) { console.error('Error updating user:', err); return; } console.log('User updated with ID', this.id); this.updatedAt = now; return this; }); } delete() { const sql = `DELETE FROM loginserver WHERE id = ?`; connection.query(sql, [this.id], (err) => { if (err) { console.error('Error deleting user:', err); return; } console.log('User deleted with ID', this.id); return; }); } } module.exports = User; ``` index.js : ``` const express = require('express'); const https = require('https'); const socketIO = require('socket.io'); const path = require('path'); const fs = require('fs'); const mysql = require('mysql'); const User = require('./server/users'); const bodyParser = require('body-parser'); const app = express(); const server = https.createServer({ key: fs.readFileSync('/etc/letsencrypt/live/ispeedrun.tv/privkey.pem'), cert: fs.readFileSync('/etc/letsencrypt/live/ispeedrun.tv/fullchain.pem') }, app); const io = socketIO(server); // Add this before the routes app.use((req, res, next) => { console.log('Request received'); next(); }); app.use(express.static(path.join(__dirname, 'views', 'public'))); app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); app.get('/', (req, res) => { res.sendFile(path.join(__dirname, 'views', 'index.html')); }); app.get('/live', (req, res) => { res.sendFile(path.join(__dirname, 'views', 'live.html')); }); const connection = mysql.createConnection({ host: 'ls-7f5846c26112d5a110aa9ce17f20838297ce7c51.cdnunzehdfq0.us-east-2.rds.amazonaws.com', port: '3306', user: 'dbmasteruser', password: '', database: '' }); connection.connect((err) => { if (err) { console.error('Failed to connect to MySQL:', err); return; } console.log('Connected to MySQL database'); }); io.on('connection', (socket) => { console.log('WebSocket connection established'); socket.on('message', (msg) => { console.log('message: ' + msg); io.emit('message', msg); }); socket.on('disconnect', () => { console.log('WebSocket connection closed'); }); }); // add this route to handle form submission app.post('/login', (req, res) => { console.log('Received login request'); console.log('Login request received:', req.body); // Log the received request const { username, password } = req.body; User.getByUsername(username, (err, user) => { if (err) { console.error('Error getting user:', err); res.status(500).send('Internal server error'); return; } if (!user) { res.status(401).send('Invalid username or password'); return; } user.checkPassword(password, (err, isMatch) => { if (err) { console.error('Error checking password:', err); res.status(500).send('Internal server error'); return; } if (!isMatch) { res.status(401).send('Invalid username or password'); return; } res.status(200).send(); // Send a 200 status code to indicate a successful login }); }); }); // Add this after the routes app.use((req, res, next) => { console.log('Response sent'); next(); }); const PORT = process.env.PORT || 6611; server.listen(PORT, () => { console.log(`Server running on port ${PORT}`); }); ``` login.html : ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>iSpeedrun.TV - Login</title> <link rel="stylesheet" href="styles.css"> <style> /* Keep the same styles as index.html */ .main-container { display: flex; flex-direction: row; } .video-container { width: 1280px; height: 720px; margin-right: 20px; } .video-container iframe { width: 100%; height: 100%; } .sidebar { width: 300px; height: 720px; display: flex; flex-direction: column; justify-content: space-between; } .sidebar-item { display: flex; align-items: center; padding: 10px; background-color: #222; color: #fff; font-size: 14px; } .sidebar-item img { width: 60px; height: 60px; margin-right: 10px; } header { display: flex; justify-content: space-between; align-items: center; background-color: #222; color: #fff; padding: 10px; } nav ul { display: flex; list-style: none; padding: 0; margin: 0; } nav li { margin-right: 20px; } nav a { color: #fff; text-decoration: none; font-weight: bold; font-size: 16px; text-transform: uppercase; } nav a:hover { color: #ff0000; } .login-container { background-color: #fff; padding: 40px; border-radius: 10px; width: 70%; margin: 20px auto; box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); } .login-container label { font-size: 20px; margin-bottom: 20px; } .login-container input[type="text"], .login-container input[type="password"] { width: 100%; height: 40px; margin-bottom: 30px; padding: 10px; font-size: 16px; border-radius: 5px; border: none; box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.3); } .login-container button[type="submit"] { display: block; width: 100%; height: 50px; background-color: #e74c3c; color: #fff; border: none; border-radius: 5px; font-size: 18px; cursor: pointer; transition: background-color 0.2s; } .login-container button[type="submit"]:hover { background-color: #c0392b; } #message { font-size: 18px; color: red; margin-bottom: 15px; } </style> </head> <body> <header> <h1>iSpeedrun.TV - Login</h1> <nav> <ul> <li><a href="index.html">Home</a></li> <li><a href="livestream.html">Live Streams</a></li> <li><a href="about.html">About Us</a></li> <li><a href="contact.html">Contact</a></li> <li><a href="login.html">Login</a></li> </ul> </nav> </header> <main class="main-container"> <div class="sidebar"> <div class="sidebar-item"> <img src="https://via.placeholder.com/60x60.png?text=User+1" alt="User 1"> <p>User 1</p> </div> <div class="sidebar-item"> <img src="https://via.placeholder.com/60x60.png?text=User+2" alt="User 2"> <p>User 2</p> </div> <div class="sidebar-item"> <img src="https://via.placeholder.com/60x60.png?text=User+3" alt="User 3"> <p>User 3</p> </div> <div class="sidebar-item"> <img src="https://via.placeholder.com/60x60.png?text=User+4" alt="User 4"> <p>User 4</p> </div> </div> <div class="video-container"> <form class="login-container" action="/login" method="post" id="login-form"> <label for="username">Username:</label> <input type="text" id="username" name="username"> <label for="password">Password:</label> <input type="password" id="password" name="password"> <div id="message"></div> <button type="submit">Login</button> </form> </div> </main> <script> const form = document.getElementById('login-form'); const message = document.getElementById('message'); form.addEventListener('submit', async function(event) { console.log('Form submitted'); event.preventDefault(); // Prevent the form from submitting normally const username = document.getElementById('username').value; const password = document.getElementById('password').value; try { console.log('Sending request to server'); const response = await fetch('/login', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ username, password }), }); console.log('Server responded with status:', response.status); if (response.status === 200) { localStorage.setItem('loggedIn', 'true'); window.location.href = 'index.html'; } else { const error = await response.json(); message.textContent = error.message; } } catch (error) { console.error('Error:', error); message.textContent = 'An error occurred. Please try again.'; } }); </script> </body> </html> ```
0
answers
0
votes
14
views
asked 4 days ago
Hi, Is there a way to get the AWS Lambda Function URL string (or the bits to construct it) programmatically from the running instance of the Lambda itself? I tried the below options and neither of them had the necessary URL: 1. checked the input object in `handleRequest(Object input, Context context)` 2. checked the items in `System.getenv()` Thanks
2
answers
0
votes
30
views
asked 4 days ago
Let us say, I have 2 API gateways in 1 single project, is there any option to deploy multiple API gateways at once ? Or we have to manually deploy each API Gateway ? What is the best CICD option for this use case ?
1
answers
0
votes
20
views
Ashwin
asked 4 days ago
I need to use **LookupEvents** API provied by Cloudtrial to periodically fetch events. Initially I set a **StartTime **parameter to something initially, and fetched all events. The after some time when I fetch, I specify the **StartTime **as recent event's **EventTime **from previous fetch + 1 second. Can I use this? Or will I miss any events? If so, can I get any suggestions while also avoiding duplicate events.
1
answers
0
votes
6
views
asked 4 days ago
Hallo guys, I'm writing to you in hope to get a help on a problem I'm facing, so basically I created a spring boot rest API for my app and I used AWS Elasticbeanstalk to deploy, now when I try to upload a file to my S3 bucket using the rest API, I'm facing an error saying that the body of my request is too large, even for some image files not larger than 1MB. So please how can I solve that issues. Here's the error part of the logs of the app: 2023/03/21 05:12:26 [error] 2736#2736: *56 client intended to send too large body: 3527163 bytes, client: ..., server: , request: "POST /mobile/create_post HTTP/1.1", host: "..."
1
answers
0
votes
28
views
asked 5 days ago
Hi AWS, I am looking to build an electric vehicle app and further deploy it on AWS. What factors are to be considered to develop one mobile app with backend architecture to efficient and best practices for e.g when you zoom in or zoom out with your fingers what is and how best we can design that mobile arch and using AWS and mobile app development - For e.g. How many api calls needed for zoom out and zoom in - Any caching can be used - How to design this with best efficient architecture for mobile app and on Aws cloud - Latitude and longitude - If we have to depend on 3rd party provides how best we can design this and what factors to go wider and what questions to ask - Building similar Lyft like mobile app, the concept and architecture design and efficient solution and questions to ask are first deliverable we are looking for. Please suggest.
1
answers
0
votes
16
views
profile picture
asked 6 days ago
Let us say, I want to do versioning of APIs both for internal usage (client app) lambdas as well as for exposing some set of APIs (lambdas) for a third-party system. Before even starting to version, I want to enquire whether there is possibility of having multiple API Gateways for the same ? One for managing and deploying the internal APIs and another for deploying the APIs to expose to third-party system without cloud-front. Or can single API gateway can manage both flows ? What is the best method to manage this ? Any suggestion / approach would be appreciated.
2
answers
0
votes
64
views
Ashwin
asked 6 days ago
Hi there, I am currently struggling to communicate between my lightsail container instances. In one container i have a React app, the other a java spring boot backend. I can curl commands from my local to the backend api and i get a success response, but when i try to do this programatically within the front end, the same call fails. The documentation is super unclear around this point, can anyone guide me in the right direction? I have tried using the public domain of the container, the private, with and without the open port. None of this has worked, and it's always unable to resolve the domain. ![ERROR](/media/postImages/original/IMsHMIzGvlREKLGU7foFAmOA)
1
answers
0
votes
18
views
asked 7 days ago
Hi, I am deploying a lambda function that utilizes the NLTK packages for preprocessing text. For the application to work I need to download the stop words, punkt and wordnet libraries. I have deployed using a docker image and SAM cli. When the function runs on AWS, I get a series of errors when trying to access the NLTK libraries. The first error I got was that '/home/sbx_user1051/' cannot be edited. After reading solutions on stack over flow, I was pointed in the direction of needing to store the NLTK libraries in the /tmp/ directory because that is the only directory that can be modified. Now, after redeploying the image with the changes to the code, I have the files stored in temp, but the lambda function does not search for that file when trying to access the stop words. It still tries to search for the file in these directories: - '/home/sbx_user1051/nltk_data' - '/var/lang/nltk_data' - '/var/lang/share/nltk_data' - '/var/lang/lib/nltk_data' - '/usr/share/nltk_data' - '/usr/local/share/nltk_data' - '/usr/lib/nltk_data' - '/usr/local/lib/nltk_data' What should I do about importing the NLTK libraries needed when running this function on aws lambda?
0
answers
0
votes
17
views
Tyler
asked 9 days ago
Hi team, I followed this [blog](https://aws.amazon.com/blogs/security/extend-aws-iam-roles-to-workloads-outside-of-aws-with-iam-roles-anywhere/) to use IAM role for a workload outside AWS in my case I want a Pipeline running in Azure devops to push an image into amazon ECR for example following the blog I was able to generate credentials from the IAM role and hit AWS s3 but I'm not sure how this is applicable for a workload running in azure for example what are the steps to follow to make a Pipeline in Azure assume an IAM role in AWS and push images to ECR I don't know how to apply the IAM role anywhere principle in Azure is there AWS docs /blog explaining the steps? Thank you!
1
answers
0
votes
35
views
Jess
asked 9 days ago