AWS pipeline¶
- Fully Managed
- Built for Scale
- Integrate with AWS services
- Secure
AWS CodeCommit¶
AWS CodeCommit is a secure, highly scalable, managed source control service that hosts private Git repositories. It makes it easy for teams to securely collaborate on code with contributions encrypted in transit and at rest. CodeCommit eliminates the need for you to manage your own source control system or worry about scaling its infrastructure. You can use CodeCommit to store anything from code to binaries. It supports the standard functionality of Git, so it works seamlessly with your existing Git-based tools.
- AWS Git Service
Developer -> AWS CodeCommit -> Build Image -> Testing -> Deploy
AWS CodeBuild¶
AWS CodeBuild is a fully managed continuous integration service that compiles source code, runs tests, and produces software packages that are ready to deploy. With CodeBuild, you don’t need to provision, manage, and scale your own build servers. CodeBuild scales continuously and processes multiple builds concurrently, so your builds are not left waiting in a queue. You can get started quickly by using prepackaged build environments, or you can create custom build environments that use your own build tools. With CodeBuild, you are charged by the minute for the compute resources you use.
- AWS CI service
- Similar to jenkins
- Scales automatically
Developer -> Code Repo -> AWS CodeBuild -> Testing -> Deploy
AWS CodePipeline¶
AWS CodePipeline is a fully managed continuous delivery service that helps you automate your release pipelines for fast and reliable application and infrastructure updates. CodePipeline automates the build, test, and deploy phases of your release process every time there is a code change, based on the release model you define. This enables you to rapidly and reliably deliver features and updates. You can easily integrate AWS CodePipeline with third-party services such as GitHub or with your own custom plugin.
- Build, test and deploy phase
- Orchestrate all the components of CodeCommit and CodeBuild
- Rapid Delivery
- Fully Managed
- Easy integration with AWS and Third Party Tools
Demo 1 - CodeCommit + CodeBuild¶
Developer -> CodeCommit -> AWS CodeCommit -> AWS ECR -> AWS EKS
IAM and Setup¶
-
Create kubectl role
- Go to IAM
- Roles
- Create Role
- Another AWS account
- Put your account ID (aws sts get-caller-identity)
- Create Policy
- Select Json
- Copy content from kubectl_role_policy.json
- set a name for the policy (kubectlrolepolicy)
- Create Policy
- Select the policy you just created
- Give the Role Name: EKSKubectl
- Create Role
- Copy Role ARN (arn:aws:iam::111111111111:role/EKSKubectl)
-
Create IAM roles via cloudformation
- Go to Cloudformation
- Create Stack (With New resources)
- Create template in Designer
- Click Template (bottom of the screen)
- Paste content from IAM-roles-cloudformation.yaml into new.template
- Click the Cloud with a arrow up in the top left corner to save the stack
- Next
- Add Stack Name (ekscicdiamstack)
- Edit KubectlRoleName with the RoleName in Step1 (EKSKubectl)
- Create Stack (next / next / I acknowledge that AWS CloudFormation might create IAM resources.)
- Go to Resources
-
Copy CodeBuildServiceRole and CodePipelineServiceRole
- ekscicdiamstack-CodeBuildServiceRole-YUCQXI16WBXO
- ekscicdiamstack-CodePipelineServiceRole-V9KJVHS5HEYT
-
Edit configmap
- kubectl edit -n kube-system configmap/aws-auth
Set pipeline¶
CodeCommit¶
- Create Repo
- Upload files
ECR¶
- Create ECR Repo
- 111111111111.dkr.ecr.eu-central-1.amazonaws.com/aws-pipeline
CodePipeline¶
- Create pipeline
- Name: eks-workshop-pipeline
- Existing service role
- seclect role created in step 12.2 (ekscicdiamstack-CodePipelineServiceRole-V9KJVHS5HEYT)
- Source
- AWS CodeCommit
- Fill the information with the aws-pipeline repo
- Build Provider -> AWS CodeBuild
- Create Project
- Set Name
- Select Operating System (ubuntu)
- Runtime -> Standard
- Image -> Latest available
- Enable Privileged
- Service role
- Existing service role step 12.1 (ekscicdiamstack-CodeBuildServiceRole-YUCQXI16WBXO)
- Environment variables
REPOSITORY_URI=111111111111.dkr.ecr.eu-west-1.amazonaws.com/aws-pipeline-repo
REPOSITORY_NAME=aws-pipeline
REPOSITORY_BRANCH=main
EKS_CLUSTER_NAME=EKS-Workshop
EKS_KUBECTL_ROLE_ARN=arn:aws:iam::111111111111:role/EKSKubectl
- Single build
- Skip deploy stage
- Create pipeline
Demo 2 - CodeCommit + CodeBuild + Lambda¶
https://github.com/aws-samples/aws-kube-codesuite