AWS CodePipeline 整合 Github Enterprise Server

2020-12-08 AWS

AWS CodePipeline 是整合 CI/CD Workflow 的服務,除了 AWS Code family (Codecommit, Codebuild, Codedeploy) 以外,如果用的是 Github, Github Enterprise Server .. 等等 third-party provider 過往都是用 S3 bucket trigger CodePipeline 的方法整合,但 Source 這塊就無法在 CodePipeline 的流程裡。

而 Codestar connection 就是為了解決這個問題,讓 third-party provider 能更完整的整合到 CodePipeline。

What’s Codestar connection ?

Codestar connection 簡明概要就是用來串接 third-party provider 通常是 repository source 像是 Bitbucket, GitHub, GitHub Enterprise Server 等,其運作原理是在 third-party provider 和 AWS Service 之間建立一個 Host 作為中繼,目前 Codestar connection 可以串接的服務有 CodeGuru Reviewer, CodePipeline。

Prepare

在這篇會以 CodePipeline 為範例與 Github Enterprise Server 串接,並且要避免 Source code 可能外流的風險。

  • VPC
  • Github Enterprise Server in Private subnet (without NAT Gateway)

CodePipeline integration Github Enterprise Server with Codestar connection

Codestar connection 位於 Developer Tools -> Settings -> Connections

Codestar Connections 有兩個動作:

  • Host:用於訪問 Github Enterprise Server
  • Connection:設定 Host 與 Github Enterprise Server OAuth2 的驗證流程
  • Create Host and Setup Host

Host 必須要能訪問 Github HTTPS Web,如果 Github Enterprise Server 的 HTTPS 自簽憑證的話則需要將 TLS certificate 填入讓 Host 能通過 SSL 認證。

  • Create Connection integration Github Enterprise Server

Connection 建立時會透過 Host 去訪問 Github Enterprise Server,在這個情境下 Github Enterprise Server 僅有 internal IP,所以在建立 Connection 時網路環境必須要能訪問在 Private Subnet 的 Github Enterprise Server。

如果沒有 Site-to-Site VPN 也能參考「AWS CDK 建立基於 OpenVPN 的 Client VPN Endpoint」快速建立

Codestar connection 會跳轉到 Github Enterprise Web Page 安裝 Github App

Github App 可以安裝在 Personal level 或者 Organization level,這會影響到 CodePipeline 在選擇 Repository 時的權限控管。

當 Connections 串接完成後 Status 會顯示 Available 確認 Codestar connection 串接 Github Enterprise Server 成功。

Create CodePipeline with Github Enterprise

建立 CodePipeline 選 Source provider 為 Github Enterprise Server 時,Connection 就能選到 codestar connection

Repository name 可以直接選到 Github Enterprise Server 內的 repository 就大功告成。

Pricing

Codestar 本身是不計費的,但如果 Host 是建立在 VPC 內,為了實現 internal traffic 所以會在 VPC 建立一個 Endpoint com.amazonaws.us-east-1.codestar-connections.webhooks 作為溝通使用,而這個 VPC Endpoint 依照官方牌照 PrivateLink 計價

References

給 Mr. 沙先生一點建議

彙整

分類

展開全部 | 收合全部

License

訂閱 Mr. 沙先生 的文章

輸入你的 email 用於訂閱