Warm tip: This article is reproduced from stackoverflow.com, please click
amazon-ec2 amazon-web-services bitbucket-aws-code-deploy

Deploy Node.js application from Bit Bucket repository to AWS EC2 instance with the help of AWS Code

发布于 2020-03-27 10:20:43

I have angular application and the back end was on node.js. Now I want to deploy the application to AWS EC2 instance from bitbucket repository using bit bucket pipeline and AWS Code Deploy.

When I am trying to install AWS code deploy agent in EC2 instance I am getting forbidden error.(403 error code)

It is a permission issue and I am missing some configure related permission.

I am trying to deploy it with the help of AWS Code Deploy by following the below article.

https://levelup.gitconnected.com/set-up-a-continuous-delivery-pipeline-from-bitbucket-to-aws-ec2-using-aws-code-deploy-a9777a3cbcad

I am getting an error when I am trying to install AWS code deploy agent in EC2 instance.

ubuntu@ip-10-245-1-43:~$ wget https://aws-codedeploy-bitbucket-us-east-1.s3.us-east-1.amazonaws.com/latest/install
--2019-07-03 13:14:17--  https://aws-codedeploy-bitbucket-us-east-1.s3.us-east-1.amazonaws.com/latest/install
Resolving aws-codedeploy-bitbucket-us-east-1.s3.us-east-1.amazonaws.com (aws-codedeploy-bitbucket-us-east-1.s3.us-east-1.amazonaws.com)... 52.216.130.237
Connecting to aws-codedeploy-bitbucket-us-east-1.s3.us-east-1.amazonaws.com (aws-codedeploy-bitbucket-us-east-1.s3.us-east-1.amazonaws.com)|52.216.130.237|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2019-07-03 13:14:17 ERROR 403: Forbidden.

I tried to run the bitbucket-pipeline.yml file and getting the below error:

 --env=COMMAND="upload" \
   --env=S3_BUCKET="$S3_BUCKET" \
   --env=VERSION_LABEL="my-app-1.0.0" \
   --env=ZIP_FILE="application.zip" \
   --add-host="host.docker.internal:$BITBUCKET_DOCKER_HOST_INTERNAL" \
   bitbucketpipelines/aws-code-deploy:0.2.5
Unable to find image 'bitbucketpipelines/aws-code-deploy:0.2.5' locally
0.2.5: Pulling from bitbucketpipelines/aws-code-deploy
c67f3896b22c: Pulling fs layer
410e0473b28d: Pulling fs layer
935eaadc5887: Pulling fs layer
7e21295cc8c2: Pulling fs layer
3073cb4153c5: Pulling fs layer
7e21295cc8c2: Waiting
3073cb4153c5: Waiting
c67f3896b22c: Verifying Checksum
c67f3896b22c: Download complete
935eaadc5887: Download complete
7e21295cc8c2: Verifying Checksum
7e21295cc8c2: Download complete
3073cb4153c5: Verifying Checksum
3073cb4153c5: Download complete
c67f3896b22c: Pull complete
410e0473b28d: Verifying Checksum
410e0473b28d: Download complete
410e0473b28d: Pull complete
935eaadc5887: Pull complete
7e21295cc8c2: Pull complete
3073cb4153c5: Pull complete
Digest: sha256:afc573f273389097401321945c6d2f7c0436a8807917ebcc20b53bdff64be9d0
Status: Downloaded newer image for bitbucketpipelines/aws-code-deploy:0.2.5
INFO: Uploading application.zip to S3.
aws s3 cp application.zip s3://CodeDeployApplication-codedeploy-deployment/my-app-1.0.0
✖ Failed to upload application.zip to S3.

Appreciate your help.

Questioner
stumbler
Viewed
72
stumbler 2019-07-07 03:07

Finally I found some solution for the error I am getting in bit-bucket pipeline. I did some mistake to set up the environment variables in bit-bucket. Previously I kept application name and s3 bucket name different. After some finding I put the same name for both and application was successfully uploaded to AWS s3 storage.

Thank you all.