简体   繁体   English

AWS CodeDeploy与GitLab的集成

[英]AWS CodeDeploy integration with GitLab

I have set up two EC2 instances in a private subnet behind a NAT. 我已经在NAT后面的专用子网中设置了两个EC2实例。 The instances are both in a AutoScalling group. 这些实例都在一个AutoScalling组中。 I want to integrate CodeDeploy with my repository from GitLab. 我想将CodeDeploy与来自GitLab的存储库集成。

All I can think of now is running a script on the BeforeInstall hook of the appspec.yml file. 我现在能想到的就是在appspec.yml文件的BeforeInstall挂钩上运行脚本。

Is there another way to do this? 还有另一种方法吗?

GitLab doesn't implements a direct integration with AWS services, but you can work around that. GitLab不会与AWS服务实现直接集成,但是您可以解决此问题。 You can do something like what you described, and implement all the installation/distribution/auth logic, but then you aren't really getting much from CodeDeploy. 您可以执行您所描述的操作,并实现所有的安装/分发/身份验证逻辑,但是从CodeDeploy中获得的好处并不多。 What you should do depends on what you are trying to achieve. 您应该做什么取决于您要实现的目标。

Automatic deployment on push : You can get automatic deployments on commit to GitLab if you bridge their WebHooks with something that can authenticate to AWS. 推送时自动部署 :如果您将WebHooks与可以向AWS进行身份验证的内容联系起来,则可以在提交到GitLab时进行自动部署。 That might look like: 可能看起来像:

  1. Web Hook in GitLab that sends a push request to a Jenkins server you control. GitLab中的Web Hook,它将推送请求发送到您控制的Jenkins服务器。
  2. The Jenkins server uses the Git plugin to pull the source. Jenkins服务器使用Git插件提取源代码。
  3. The Jenkins server runs your build and test steps. Jenkins服务器将运行您的构建和测试步骤。
  4. The Jenkins server uses the CodeDeploy plugin to upload the build artifacts to S3 and create a deployment. Jenkins服务器使用CodeDeploy插件将构建工件上传到S3并创建部署。

If you want to have manual deployments, you could do the same as above but manually trigger the Jenkins build. 如果您要进行手动部署,则可以执行与上述相同的操作,但是手动触发Jenkins构建。

Deploy manually only : Do the following when you want to deploy: 仅手动部署:要部署时,请执行以下操作:

  1. Use git to checkout the commit you want to deploy. 使用git签出要部署的提交。
  2. Run your build and test locally. 运行构建并在本地测试。
  3. Execute the AWS CLI deploy push command to upload your build artifacts to S3. 执行AWS CLI deploy push命令将您的构建工件上传到S3。
  4. Create a deployment in CodeDeploy using the bundle uploaded. 使用上载的捆绑包在CodeDeploy中创建部署。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM