Code Monkey home page Code Monkey logo

deployer's Introduction

Securing DevOps's deployer

A simple API that receives webhook notifications, runs tests and trigger deployments.

Get your own copy

To try out the code in this repository, first create a fork in your own github account.

Replace the namespace

Now before you do anything, edit the file main.go and replace securingdevops with your dockerhub username on line 50.

if hookData.Repository.Namespace != `securingdevops` {
		httpError(w, http.StatusUnauthorized, "Invalid namespace")
		return
}

If your dockerhub username is bobkelso, then the code should read

if hookData.Repository.Namespace != `bobkelso` {
		httpError(w, http.StatusUnauthorized, "Invalid namespace")
		return
}

When the deployer processes a webhook notification, it makes sure the notification comes from a trusted dockerhub user. You certainly don't want to leave that blank, otherwise anyone could send webhook notifications to your deployer and trigger new deployments.

Set your own environment

Next, still in main.go, replace the following code with your own, taken from the invoicer's elastic beanstalk environment your created previously.

	params := &elasticbeanstalk.UpdateEnvironmentInput{
		ApplicationName: aws.String("invoicer201707071231"),
		EnvironmentId:   aws.String("e-y8ubep55hp"),
		VersionLabel:    aws.String("invoicer-api"),
}

My notes:

For deployer to be able to update invoicer environment it needs aws access keys. Adding following to the config.yml should work: (For this the input environment variables are added to circleci configuration; similar to DOCKER_USER and DOCKER_PASS)

mkdir -p ~/.aws echo "[default]" > ~/.aws/credentials echo "aws_access_key_id = ${AWS_ACCESS_KEY_ID}" >> ~/.aws/credentials echo "aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}" >> ~/.aws/credentials

echo "[default]" > ~/.aws/config echo "region = ap-south-1" > ~/.aws/config echo "output = json" > ~/.aws/config

Flow:

  1. Changes in the deployer. finish circleci.
  2. deploy to aws - ./create_ebs_env.sh (can try to combine 1 and 2)
  3. changes to invoicer github - dockerhub - deployer activated to check AWS infra through webhook
  4. If all ok - invoicer is deployed by the deployer.
  • Ideally only 1 and 3 should be manual check deployer aws logs to check if the invoicer deployed ok.
  • ideally deployer is steady and changes are happening in the inoiver.

CIRCLE_TOKEN: ad009b26f5e8f109aa1e754d3ecca7ff38da1dc0

Connect to EC2 ssh -i /c/Saumya_back/Explorations/security/SecDevOps_example/SSHKey.pem [email protected]

Run a command in a running container runs bash : sudo docker ps -a | awk '{print $NF}' | tail -n 1 sudo docker exec -it elastic_jang bash

debugging 5-security-group.sh changed go testAndDeploy and output to $rundir/out1 instead of in the deploymentTest directory and then it passed. even though pineapple script showed a failure. overall it still passed.

deployer's People

Contributors

saumc avatar jvehent 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.