Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

I want to deploy NodeJS code to ec2 instance

prateek
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 20, 2024

I have project in bitbucket that I want to deploy to ec2 instance in AWS . Here are the details :

1. I already have 1.2.3.4 ip address machine which hosts nodejs code , I have to manually ssh into this machine , do git pull origin main and then restart pm2 command 

2. I want to do #1 on every main branch commit . 

2 answers

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 22, 2024

Hi Prateek and welcome to the community!

You can use Bitbucket Pipelines for deployments. Since you want to deploy on every commit to main branch, you can use a pipeline that runs on the main branch:

You will need to set up SSH keys in Pipelines and the server for the connection:

You can then either use the ssh-run pipe to connect to your server via SSH and run commands:

Or, alternatively, you can use an SSH command in the yml file directly, if the steps' build container has an SSH client installed.

Please keep in mind that the server you want to connect to needs to have a public IP address so that Pipelines can reach it.

You could also run Pipelines builds with a self-hosted runner on a server of yours. We offer runners for Linux, Windows and Macos:

Please feel free to reach out if you have any questions.

Kind regards,
Theodora

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 25, 2024

Hi @prateek . In addition to @Theodora Boudale answer also you could try this pipe:

Deploy a new service configuration

script:
  - pipe: atlassian/aws-ecs-deploy:1.12.2
    variables:
      AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
      AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
      AWS_DEFAULT_REGION: 'us-east-1'
      CLUSTER_NAME: 'my-ecs-cluster'
      SERVICE_NAME: 'my-ecs-service'
      TASK_DEFINITION: 'task-definition.json'

Regards, Igor

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events