Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

525
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda