{"id":3864,"date":"2021-02-04T10:48:56","date_gmt":"2021-02-04T09:48:56","guid":{"rendered":"http:\/\/miro.borodziuk.eu\/?p=3864"},"modified":"2021-05-16T14:00:22","modified_gmt":"2021-05-16T12:00:22","slug":"codebuild","status":"publish","type":"post","link":"http:\/\/miro.borodziuk.eu\/index.php\/2021\/02\/04\/codebuild\/","title":{"rendered":"CodeBuild"},"content":{"rendered":"<p><!--more--><\/p>\n<ul>\n<li>Fully managed build service<\/li>\n<li>Alternative to other build tools such as Jenkins<\/li>\n<li>Continuous scaling (no servers to manage or provision \u2013 no build queue)<\/li>\n<li>Pay for usage: the time it takes to complete the builds<\/li>\n<li>Leverages Docker under the hood for reproducible builds<\/li>\n<li>Possibility to extend capabilities leveraging our own base Docker images<\/li>\n<li>Secure: Integration with KMS for encryption of build artifacts, IAM for build<br \/>\npermissions, and VPC for network security, CloudTrail for API calls logging<\/li>\n<li>Source Code from GitHub \/ CodeCommit \/ CodePipeline \/ S3\u2026<\/li>\n<li>Build instructions can be defined in code (<code>buildspec.yml<\/code> file)<\/li>\n<li>Output logs to Amazon S3 &amp; AWS CloudWatch Logs<\/li>\n<li>Metrics to monitor CodeBuild statistics<\/li>\n<li>Use CloudWatch Events to detect failed builds and trigger notifications<\/li>\n<li>Use CloudWatch Alarms to notify if you need \u201cthresholds\u201d for failures<\/li>\n<li>CloudWatch Events \/ AWS Lambda as a Glue<\/li>\n<li>SNS notifications<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">First build<\/span><\/p>\n<p>In CodeCommit we have <code>index.html<\/code> file with <em>&#8220;congratulations&#8221;<\/em> word. We will test whether or not the <code>index.html<\/code> file has this word. To create a build:<\/p>\n<p><code>CodeBuild -&gt; Create build project -&gt; ProjectName (MyWebAppCodeBuildMaster) -&gt; Source provider (AWS CodeCommit) -&gt; Repositorry (my-webpage) -&gt; Reference type (Branch) -&gt; Branch (master) -&gt; Environment -&gt; Environment image (Managed image) -&gt; Operating system (Amazon Linux 2) -&gt; Runtime (standard) -&gt; Image (****-standard 1.0) -&gt; Service Role (New service role) -&gt; Role name (codebuild-&gt;MyWebAppCodeBuild-service-role) -&gt; Build specifications -&gt; Use a buildspec file -&gt; Create build project<\/code><\/p>\n<p>Because in CodeCommit we have <code>buildspec.yml<\/code> file we don&#8217;t need to fill Buildspec section.<\/p>\n<p>Now we should start a build:<\/p>\n<p><code>Start build<\/code> -&gt;<\/p>\n<p>Build will use docker container and <code>buildspecfile.yml<\/code> from CodeCommit <em>my-webpage<\/em> repository.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3875\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild01.jpg\" alt=\"\" width=\"1522\" height=\"804\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild01.jpg 1522w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild01-300x158.jpg 300w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild01-1024x541.jpg 1024w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild01-768x406.jpg 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>We can click <code><span class=\"dx-LogTab__header__text\" data-spec=\"dx-LogTab__header__text\">View entire log<\/span><\/code> to view the entire log in cloudwatch.<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">Buildspec.yml file<\/span><\/p>\n<pre class=\"lang:default decode:true\">version: 0.2\r\nphases:\r\n  install:\r\n    runtime-versions:\r\n      nodejs: 10\r\n    commands:\r\n     - echo \"installing something\"\r\n  pre_build:\r\n    commands:\r\n    - echo \"we are in the pre build phase\"\r\n  build:\r\n    commands:\r\n    - echo \"we are in the build block\"\r\n    - echo \"we will run some tests\"\r\n    - grep -Fq \"Congratulations\" index.html\r\n  post_build:\r\n    commands:\r\n    - echo \"we are in the post build phase\"\r\n<\/pre>\n<p>This buildspec.yml check if in the index.html file is &#8220;Congratulations&#8221; word.<\/p>\n<p>We can change this word in the index.html file and Commit changes:<\/p>\n<p><code>CodeCommit -&gt; Repositories -&gt; my-webpage -&gt; index.html -&gt; Edit -&gt; Author name -&gt; Commit changes<\/code><\/p>\n<p>and then:<\/p>\n<p><code>Developer Tools -&gt; CodeBuild -&gt; Build projects -&gt; MyWebAppCodeBuildMaster -&gt; Start build<\/code><\/p>\n<p>And the build will fail:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3878\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild02.jpg\" alt=\"\" width=\"1530\" height=\"802\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild02.jpg 1530w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild02-300x157.jpg 300w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild02-1024x537.jpg 1024w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild02-768x403.jpg 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3882 size-full\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild03-1.jpg\" alt=\"\" width=\"1080\" height=\"475\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild03-1.jpg 1080w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild03-1-300x132.jpg 300w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild03-1-1024x450.jpg 1024w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild03-1-768x338.jpg 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">Docker<\/span><\/p>\n<p>To use docker images we can use <code>buildspec.yml<\/code> file from refenrences sample:<\/p>\n<pre class=\"lang:default decode:true\">version: 0.2\r\n\r\nphases:\r\n  pre_build:\r\n    commands:\r\n    - echo Logging in to Amazon ECR...\r\n    - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com\r\n\r\n  build:\r\n    commands:\r\n    - echo Build started on `date`\r\n    - echo Building the Docker image...\r\n    - docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .\r\n    - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com\/$IMAGE_REPO_NAME:$IMAGE_TAG\r\n\r\n  post_build:\r\n    commands:\r\n    - echo Build completed on `date`\r\n    - echo Pushing the Docker image...\r\n    - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com\/$IMAGE_REPO_NAME:$IMAGE_TAG<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">Environment variables &amp; Parameter Store<br \/>\n<\/span><\/p>\n<p>Let&#8217;s modify our first simple<code> buildspec.yml<\/code> file:<\/p>\n<pre class=\"lang:default decode:true\">version: 0.2\r\nphases:\r\n  install:\r\n    runtime-versions:\r\n      nodejs: 10\r\n    commands:\r\n     - printenv\r\n     - echo \"installing something\"\r\n  pre_build:\r\n    commands:\r\n    - echo \"we are in the pre build phase\"\r\n  build:\r\n    commands:\r\n    - echo \"we are in the build block\"\r\n    - echo \"we will run some tests\"\r\n    - grep -Fq \"Congratulations\" index.html\r\n  post_build:\r\n    commands:\r\n    - echo \"we are in the post build phase\"\r\n<\/pre>\n<p>Next we must commit changes in<\/p>\n<p><code>CodeCommit -&gt; author name -&gt; Email address -&gt; Commit changes<\/code><\/p>\n<p>And also we must change index.html file and put Congratulations word in:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3885\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild04.jpg\" alt=\"\" width=\"616\" height=\"586\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild04.jpg 616w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild04-300x285.jpg 300w\" sizes=\"(max-width: 616px) 100vw, 616px\" \/><\/p>\n<p>Next we must commit changes in<\/p>\n<p><code>CodeCommit -&gt; author name -&gt; Email address -&gt; Commit changes<\/code><\/p>\n<p>Then in CodeBuild we must build the project again.<\/p>\n<p>After this changes all the environment variables should be printed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3886\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild05.jpg\" alt=\"\" width=\"883\" height=\"378\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild05.jpg 883w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild05-300x128.jpg 300w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild05-768x329.jpg 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>We can change the environment variables\u00a0 directly in the buuildspec.yml file <code class=\"yaml hljs\"><\/code><\/p>\n<pre class=\"lang:default decode:true\">env:\r\n  shell:     shell-tag\r\n  variables:\r\n    key: \"value\"\r\n    key: \"value\"\r\n  parameter-store:\r\n    key: \"value\"\r\n    key: \"value\"\r\n  exported-variables:\r\n  -variable\r\n  -variable<\/pre>\n<p>or directly in the console wile lounching buil project:<\/p>\n<p><code>Build project with overrides -&gt;<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3891 size-full\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild08.jpg\" alt=\"\" width=\"577\" height=\"230\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild08.jpg 577w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild08-300x120.jpg 300w\" sizes=\"(max-width: 577px) 100vw, 577px\" \/><\/p>\n<p>But variables changed in the buildpec.yml file and in console will be visible.<\/p>\n<p>If we want to have unvisible variable we should use Parameter Store.<\/p>\n<div class=\"awsui-breadcrumb\"><code><span class=\"awsui-breadcrumb-link-text\">AWS Systems Manager -&gt; <\/span><span class=\"awsui-breadcrumb-link-text\">Parameter Store -&gt; <\/span><span class=\"awsui-breadcrumb-link-text\">Create parameter<\/span><\/code><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3890\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild07.jpg\" alt=\"\" width=\"563\" height=\"838\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild07.jpg 563w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild07-202x300.jpg 202w\" sizes=\"(max-width: 563px) 100vw, 563px\" \/><\/div>\n<p><code>Create Paremeter<\/code><\/p>\n<p>Now in console we use:\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3892\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild09.jpg\" alt=\"\" width=\"717\" height=\"339\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild09.jpg 717w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild09-300x142.jpg 300w\" sizes=\"(max-width: 717px) 100vw, 717px\" \/><\/p>\n<p>To use parameters from Parameter Store a role <code>codebuild-MyWebAppCodeBuild-service-role<\/code> should have attached <code>AmazonSSMReadOnlyAccess<\/code>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3894\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild10.jpg\" alt=\"\" width=\"726\" height=\"630\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild10.jpg 726w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild10-300x260.jpg 300w\" sizes=\"(max-width: 726px) 100vw, 726px\" \/><\/p>\n<p>After build the project we can&#8217;t see the DB_PASSWORD variable in the log:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3896\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild11.jpg\" alt=\"\" width=\"567\" height=\"283\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild11.jpg 567w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild11-300x150.jpg 300w\" sizes=\"(max-width: 567px) 100vw, 567px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">Artifacts and S3<\/span><\/p>\n<p>Artifact is the build output. Let&#8217;s modify the buildspec file:<\/p>\n<pre class=\"lang:default decode:true\">version: 0.2\r\n\r\nphases:\r\n  install:\r\n    runtime-versions:\r\n    nodejs: 10\r\n    commands:\r\n    - printenv\r\n    - echo \"installing something\"\r\n  \r\n  pre_build:\r\n    commands:\r\n    - echo \"we are in the pre build phase\"\r\n  build:\r\n    commands:\r\n    - echo \"we are in the build block\"\r\n    - echo \"we will run some tests\"\r\n    - grep -Fq \"Congratulations\" index.html\r\n  post_build:\r\n    commands:\r\n    - echo \"we are in the post build phase\"\r\n\r\nartifacts:\r\n  files:\r\n  - '**\/*'\r\n  name: my-webapp-artifacts<\/pre>\n<p>and commit changes in CodeCommit.<\/p>\n<p>First we need to create a bucket for artifacts:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3898\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild12.jpg\" alt=\"\" width=\"814\" height=\"478\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild12.jpg 814w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild12-300x176.jpg 300w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild12-768x451.jpg 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>If we want we can use default encryption for this bucket or encrypt the artifacts after the build proces.<\/p>\n<p>Now edit the artifacts section in CodeBuild project:<\/p>\n<p><code>Developer Tools -&gt; CodeBuild -&gt; Build projects -&gt; MyWebAppCodeBuildMaster -&gt;\u00a0 Edit Artifacts<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3900 size-full\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild13-1.jpg\" alt=\"\" width=\"707\" height=\"781\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild13-1.jpg 707w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild13-1-272x300.jpg 272w\" sizes=\"(max-width: 707px) 100vw, 707px\" \/><\/p>\n<p>As we see the CodeBuild will create a role to access to the S3 bucket.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3904 size-full\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild14-1.jpg\" alt=\"\" width=\"809\" height=\"476\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild14-1.jpg 809w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild14-1-300x177.jpg 300w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild14-1-768x452.jpg 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>Now we can run the build project. After building we see in the log that artifacts were succesfully upploaded to the cicd-miro-devops bucket:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3906\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild15.jpg\" alt=\"\" width=\"738\" height=\"196\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild15.jpg 738w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild15-300x80.jpg 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/p>\n<p>S3 bucket:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3907\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild16.jpg\" alt=\"\" width=\"942\" height=\"398\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild16.jpg 942w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild16-300x127.jpg 300w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild16-768x324.jpg 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">CloudWatch Events &amp; CloudWatch Logs<\/span><\/p>\n<p>If we want to run build project in the sheduled way we can use CloudWatch Events:<\/p>\n<p><code>Cloudwatch -&gt; Events -&gt; Rules -&gt; Create rule<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3909\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild17.jpg\" alt=\"\" width=\"1009\" height=\"595\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild17.jpg 1009w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild17-300x177.jpg 300w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild17-768x453.jpg 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>Project ARN we can take from Build details:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3911\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild18.jpg\" alt=\"\" width=\"673\" height=\"533\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild18.jpg 673w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild18-300x238.jpg 300w\" sizes=\"(max-width: 673px) 100vw, 673px\" \/><\/p>\n<p><code>Configure details -&gt;<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3913\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild19.jpg\" alt=\"\" width=\"727\" height=\"284\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild19.jpg 727w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild19-300x117.jpg 300w\" sizes=\"(max-width: 727px) 100vw, 727px\" \/><\/p>\n<p><code>Create rule -&gt;<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3914\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild20.jpg\" alt=\"\" width=\"720\" height=\"557\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild20.jpg 720w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild20-300x232.jpg 300w\" sizes=\"(max-width: 720px) 100vw, 720px\" \/><\/p>\n<p>Also we can configure CloudWatch Events to react if something happen while build is runing, for example build has been failed or state changed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3915\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild21.jpg\" alt=\"\" width=\"754\" height=\"806\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild21.jpg 754w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/CodeBuuild21-281x300.jpg 281w\" sizes=\"(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">Validating AWS CodeCommit Pull Requests<\/span><\/p>\n<p>We can validate CodeCommit pull request by sing CloudWatch Events, CodeBuild and Lembda. There is great article abut it at AWS DevOps Blog:<\/p>\n<p><a href=\"https:\/\/aws.amazon.com\/blogs\/devops\/validating-aws-codecommit-pull-requests-with-aws-codebuild-and-aws-lambda\/\">https:\/\/aws.amazon.com\/blogs\/devops\/validating-aws-codecommit-pull-requests-with-aws-codebuild-and-aws-lambda\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>References<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/docs.aws.amazon.com\/codebuild\/latest\/userguide\/build-spec-ref.html\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/docs.aws.amazon.com\/codebuild\/latest\/userguide\/build-spec-ref.html<\/a><\/li>\n<li><a href=\"https:\/\/docs.aws.amazon.com\/codebuild\/latest\/userguide\/samples.html\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/docs.aws.amazon.com\/codebuild\/latest\/userguide\/samples.html<\/a><\/li>\n<li><a href=\"https:\/\/docs.aws.amazon.com\/codebuild\/latest\/userguide\/sample-docker.html\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/docs.aws.amazon.com\/codebuild\/latest\/userguide\/sample-docker.html<\/a><\/li>\n<li><a href=\"https:\/\/aws.amazon.com\/blogs\/devops\/validating-aws-codecommit-pull-requests-with-aws-codebuild-and-aws-lambda\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/aws.amazon.com\/blogs\/devops\/validating-aws-codecommit-pull-requests-with-aws-codebuild-and-aws-lambda\/<\/a><\/li>\n<li><a href=\"https:\/\/docs.aws.amazon.com\/codebuild\/latest\/userguide\/build-env-ref-env-vars.html\">https:\/\/docs.aws.amazon.com\/codebuild\/latest\/userguide\/build-env-ref-env-vars.html<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":3865,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[88],"tags":[],"_links":{"self":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts\/3864"}],"collection":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/comments?post=3864"}],"version-history":[{"count":29,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts\/3864\/revisions"}],"predecessor-version":[{"id":3977,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts\/3864\/revisions\/3977"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/media\/3865"}],"wp:attachment":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/media?parent=3864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/categories?post=3864"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/tags?post=3864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}