Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

530
Vistas
How to create an AWS app that uses MongoDb for database?

I'm trying to move an existing node.js express app from Heroku to AWS. The app uses MongoDB for the database. The problem is aws EB (Elastic Beanstalk) doesn't natively support no-sql databases (I understand that I need to use a VPC and am able to connect a VPC to MongoDB). I'm a little confused with setup both on the app's code (how the config files should be written/if any backend changes that might be needed), and how it should be setup in AWS. Is there a better option for this? Right now eb deploy fails and the logs don't seem helpful. Any advice is greatly appreciated.

config.yml

branch-defaults:
  Master:
    environment: Testproject-env
environment-defaults:
  Testproject-env:
    branch: null
    repository: null
global:
  application_name: test-project
  default_ec2_keyname: null
  default_platform: Node.js
  default_region: us-east-2
  include_git_submodules: true
  instance_profile: null
  platform_name: null
  platform_version: null
  profile: eb-cli
  sc: git
  workspace_type: Application

nodecommand.config

option_settings:
  aws:elasticbeanstalk:container:nodejs:
    NodeCommand: "npm start"

app.js

const express = require("express");
const mongoose = require('mongoose');
const users = require('./routes/api/users');
const bodyParser = require('body-parser');
const passport = require('passport');
const path = require('path')

const app = express();

if (process.env.NODE_ENV === 'production') {
    app.use(express.static('frontend/build'));
    app.get('/', (req, res) => {
        res.sendFile(path.resolve(__dirname, 'frontend', 'build', 'index.html'));
    })
}

const db = require('./config/keys_dev').mongoURI;
mongoose
    .connect(db, { useNewUrlParser: true })
    .then(() => console.log("Connected to MongoDB successfully"))
    .catch(err => console.log(err));

app.use(passport.initialize());
require('./config/passport')(passport);

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

app.use('/api/users', users);

const port = process.env.PORT || 5000;

app.listen(port, () => console.log(`Server is running on port ${port}`));
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Would suggest to consider using Amazon Document DB instead for this use-case. Amazon Document DB offers a MongoDB compatible engine so we don't have to make any code-changes when migrating MongoDB applications in AWS except for connection string updates.

What makes using Amazon Document DB really interesting for this migration use-case is that you could take advantage of AWS Data Migration Service (DMS) to pull your existing dataset from the old MongoDB to Amazon Document DB with little effort. Here is a starter guide to migrating data from MongoDB to Document DB.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda