在 AWS Code Deploy 的帮助下将 Node.js 个应用程序从 Bit Bucket 存储库部署到 AWS EC2 实例

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

我有 angular 应用程序,后端在 node.js 上。现在我想使用 bit bucket pipeline 和 AWS Code Deploy 将应用程序从 bitbucket 存储库部署到 AWS EC2 实例。

当我尝试在 EC2 实例中安装 AWS 代码部署代理时出现禁止错误。(403 错误代码)

这是一个权限问题,我缺少一些与配置相关的权限。

我正在按照以下文章尝试借助 AWS Code Deploy 来部署它。

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

我尝试在 EC2 实例中安装 AWS 代码部署代理时遇到错误。

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.

我尝试 运行 bitbucket-pipeline.yml 文件并收到以下错误:

 --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.

感谢您的帮助。

最后,我找到了解决 bit-bucket 管道中出现的错误的方法。 我在 bit-bucket 中设置环境变量时犯了一些错误。 以前我保持应用程序名称和 s3 存储桶名称不同。 经过一些发现后,我为两者输入了相同的名称,应用程序已成功上传到 AWS s3 存储。

谢谢大家