GithubHelp home page GithubHelp logo

imranxpress / aws-codepipeline-custom-action Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws-samples/aws-codepipeline-custom-action

0.0 0.0 0.0 786 KB

Amazon EC2 build environments with AWS CodePipeline and custom actions

License: MIT No Attribution

Python 100.00%

aws-codepipeline-custom-action's Introduction

Amazon EC2 build environments with AWS CodePipeline and custom actions

This repository provides serverless implementation of AWS CodePipeline custom actions.

The rationale behind this implementation is described in Building Windows containers with AWS CodePipeline and custom actions.

Arhitecture

Architecture

  1. An Amazon CloudWatch Event triggers an AWS Lambda function when a custom CodePipeline action is to be executed.
  2. The Lambda function retrieves the action's build properties (AMI, instance type, etc.) from CodePipeline, along with location of the input artifacts in the Amazon S3 bucket.
  3. The Lambda function starts a Step Functions state machine that carries out the build job execution, passing all the gathered information as input payload.
  4. The Step Functions flow acquires an Amazon EC2 instance according to the provided properties, waits until the instance is up and running, and starts an AWS Systems Manager command. The Step Functions flow is also responsible for handling all the errors during build job execution and releasing the Amazon EC2 instance once the Systems Manager command execution is complete.
  5. The Systems Manager command runs on an Amazon EC2 instance, downloads CodePipeline input artifacts from the Amazon S3 bucket, unzips them, executes the build script, and uploads any output artifacts to the CodePipeline-provided Amazon S3 bucket.
  6. Polling Lambda updates the state of the custom action in CodePipeline once it detects that the Step Function flow is completed.

Deployment

First, package and upload necessary resources (deployment package for lambda functions). Specify S3 bucket name.

aws cloudformation package --template-file template.yml --output-template-file deployment.yml --s3-bucket {deployment-bucket}

Deploy the stack using the following command:

aws cloudformation deploy --template-file deployment.yml --capabilities CAPABILITY_NAMED_IAM --stack-name {stack-name} --parameter-overrides CustomActionProviderVersion={custom-action-version}

Note that you need to provide the following parameters:

  • {stack-name} - CloudFormation stack name
  • {custom-action-version} - version of the custom action (1, 2, 3, etc.). Each deployment of the custom action has to have a distinct version number.

Configuration

Once CloudFormation stack is deployed, you can add the custom action to your CI/CD pipelines either via AWS Console or CloudFormation. See AWS CodePipeline for Windows Server containers for an example of using custom actions for building Windows Server containers.

Environment variables available to the build scripts

Variable Name Example Description
PipelineArn arn:aws:codepipeline:eu-west-1:111111111111:windows-container-cicd-pipeline The Amazon Resource Name (ARN) of the pipeline.
PipelineName windows-container-cicd-pipeline The name of the pipeline.
PipelineExecutionId ced4b2c3-d4ee-4767-885d-30d45b94bfdf The execution ID of the pipeline.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

aws-codepipeline-custom-action's People

Contributors

kolomied avatar dasiths avatar amazon-auto 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.