How to deploy mongodb on EC2 using API? - node.js

For a project in node.js i want to deploy mongodb instance on amazon ec2 using amazon api or something like that, is it possible? i found nothing about that.
Thanks for the time

You have many options:
vagrant with the aws provider
terraform as mentioned
cloudformation
using AWSCLI (and userdata): $ aws ec2 run-instances help

Related

Define AWS credentials in nodejs deployment on EC2

I need guidance regarding using AWS-SDK credentials in production nodejs app.
What is the possible way of doing this? I researched about it that always use shared credentials files for aws credentials using that link. "https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/loading-node-credentials-shared.html"
So I'm confused about the way. Do I need to create that file in that Linux path specified in that link in VM of EC2?
I made a new IAM role for S3 and allocate it to a specific EC2 instance but through code how can I be able to access S3 services. I deployed my app and it's still giving me access denied error on accessing S3 service.
Do I still need to include credentials file as discussed in like given above? And Do I still need to initialize S3?
const s3 = new aws.S3({
accessKeyId,
secretKey,
bucketRegion,
});
Please guide me that how can I deploy nodejs app without affecting AWS services.
Following the AWS Well Architected Framework the best solution would be to assign a role with your required permissions to the EC2 instance that you are going to use.
You should strive from adding credentials to the application directly as they are not needed in most of the cases.
Please take a look at IAM roles for Amazon EC2 as how does AWS guides to achieving that.

Download files from s3 to ec2 instance using Azure DevOps (AWS ToolKit)

I am trying to download files from s3 to ec2 instance in Azure DevOps by using AWS CLI in Build Pipeline. I am able to get the download logs but the data is not downloaded on my ec2 instance.
Same command works while executing from EC2 instance. It doesn't give me any error from DevOps but I do not see the data moved to my instance.
Thanks for your help.
You could refer to this ticket:
The AWS CLI calls the AWS API. The APIs for Amazon S3 do not have the ability to interact with the operating system on an Amazon EC2 instance.
So when you run the same command in the EC2 instance, it could work as expected. But it doesn't work in Azure Devops Pipeline.
You could try to use the aws cli send-command to send the aws s3 cp command to the EC2 instance.
Here is an example:

Migrate Centos AWS image to Azure VM

We have the AWS centos system and we have our software installed on it. Now we want to move this EC2 instance to Azure. What is the process and best way approach that we can follow.
Any Document or article will help.
Azure has a guide for this specifically
https://learn.microsoft.com/en-us/azure/site-recovery/migrate-tutorial-aws-azure

Google cloud - nodejs with mongodb setup

I am trying to setup a nodeJS app environment with mongoDB cluster all deployed in Google cloud. I have created a mongoDB cluster as given in Google Cloud documentation. But after this I could not find any documentation on how to get that working with nodeJS environment.
Is there any documentation or tutorial for end to end Google Cloud setup?
Try the "MEAN" stack from Bitnami from the Cloud Launcher: is a on-click-deploy solution for Mongo/Express/Angular/Node.
This is good to getting started, when you know how the stack works you can opt for docker images for Mongo and Node and deploy that on Kubernetes to get a fully-managed cluster env.

One off commands on Amazon Beanstalk

I just deployed my first application on amazon beanstalk and am stuck with one seemingly simple issue.
I have node.js scripts that I use to i.e.: migrate the DB schema or populate the RDS with generated sample data. For heroku apps I simply use
heroku run <statement>
Is there an equivalent of that amazon beanstalk? Whats a good workflow for that?
It looks like the only solution is using good old ssh to connect to the instances(s) and run the statements there. Caveat is that you will need to first create Key Pair first in the EC2 Dashboard and refer to that key when you create the amazon beanstalk environment, you can't create a key pair when you create a amazon beanstalk environment.

Resources