GithubHelp home page GithubHelp logo

ssts-alg / aws-codebuild-badges Goto Github PK

View Code? Open in Web Editor NEW

This project forked from btorun/aws-codebuild-badges

0.0 0.0 0.0 153 KB

Create CodeBuild badges using AWS Lambda and CloudWatch

License: MIT License

JavaScript 100.00%

aws-codebuild-badges's Introduction

aws-codebuild-badges

Build Status Dependencies Dev Dependencies

Introduction

AWS CodeBuild already has badges for builds however this sample code is helpful to learn the basics of AWS Lambda, CodeBuild & CloudWatch. Adapted from jSherz's code

Setup AWS

  1. Create S3 bucket
    • Make sure bucket has public access
    • e.g. bucket name: my-codebuild-badges
  2. Create Lambda function
    • Pick Author from scratch
    • Name update-build-badges
    • Runtime Node.js 8.10
    • Role Create a custom role
    • On new page, View Policy Document > Edit
    {
         "Version": "2012-10-17",
         "Statement": [
             {
                 "Effect": "Allow",
                 "Action": [
                     "logs:CreateLogGroup",
                     "logs:CreateLogStream",
                     "logs:PutLogEvents"
                 ],
                 "Resource": "arn:aws:logs:*:*:*"
             },
             {
                 "Sid": "AllowBadges",
                 "Effect": "Allow",
                 "Action": [
                     "s3:PutObject",
                     "s3:PutObjectAcl"
                 ],
                 "Resource": [
                     "arn:aws:s3:::my-codebuild-badges/*"
                 ]
             }
         ]
     }
    • Go back to previous page after saving your custom role and click Create Function
    • If you would like to modify the code, check development section below otherwise download the latest version here
    • Upload code to your function and set environment variable BUCKET=my-codebuild-badges
  3. Create CloudWatch event/trigger
    • Events > Rules > Create Rule
    • Service Name CodeBuild
    • Event Type CodeBuild Build State Change
    • Add target > Lambda function and select your lambda function
  4. Trigger your build and you will see a new svg file under s3://my-codebuild-badges with your CodeBuild project name.

Development

Modify the code as you wish and create a zip bundle:

$ npm install
// modify the code
$ npm run zip

index.zip will be generated in project's root. This file can be uploaded to AWS Lambda.

aws-codebuild-badges's People

Contributors

btorun avatar dependabot-preview[bot] avatar dependabot-support avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.