Skip to content

Instantly share code, notes, and snippets.

View davidmukiibi's full-sized avatar
💭
Working with DevOps work, one container at a time.

David Mukiibi davidmukiibi

💭
Working with DevOps work, one container at a time.
  • https://github.com/pluto-tv
  • Kenya
View GitHub Profile
def create_bucket(self, bucket_name, region=None):
speak_output = ""
try:
s3_client.create_bucket(Bucket=bucket_name)
except ClientError as e:
logging.error(e)
if e.response['Error']['Code'] == "BucketAlreadyExists":
speak_output = "The requested bucket name is either not available, already \
exists or not unique to AWS, please select a different name and try again."
return False
@davidmukiibi
davidmukiibi / setup_k6.sh
Last active December 4, 2019 15:49
This bash script only installs k6
#!/bin/bash
set -ex
install_k6() {
apt-get update
apt-get install dirmngr --install-recommends
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
echo "deb https://dl.bintray.com/loadimpact/deb stable main" | sudo tee -a /etc/apt/sources.list
apt-get update
@davidmukiibi
davidmukiibi / Jenkinsfile
Last active December 4, 2019 18:32
Jenkinsfile with permit.sh and revoke.sh scripts
pipeline {
agent any
environment {
K6_API_TOKEN=credentials("K6_API_TOKEN")
}
stages {
stage('Performance Testing') {
steps {
echo 'Running K6 performance tests...'
@davidmukiibi
davidmukiibi / permit.sh
Created December 3, 2019 03:27
script to grant circleci ci ingress access to system behind aws firewall
#!/bin/bash
set -ex
public_ip_address=$(curl -q http://checkip.amazonaws.com)
/root/bin/aws ec2 authorize-security-group-ingress --group-id sg-006b570caa40214f1 --ip-permissions "[{\"IpProtocol\": \"tcp\", \"FromPort\": 443, \"ToPort\": 443, \"IpRanges\": [{\"CidrIp\": \"${public_ip_address}/32\"}]}]"
@davidmukiibi
davidmukiibi / setup.sh
Last active December 4, 2019 15:43
bash scrip to install k6 and aws cli and configure aws cli
#!/bin/bash
set -ex
update_cache() {
apt-get update
}
install_aws_cli() {
apt-get install curl unzip python2.7 python-pip -y
@davidmukiibi
davidmukiibi / revoke.sh
Created December 3, 2019 03:21
bash Script to revoke ingress access for circleci
#!/bin/bash
set -ex
public_ip_address=$(curl -q http://checkip.amazonaws.com)
/root/bin/aws ec2 revoke-security-group-ingress --group-id sg-006b570caa40214f1 --ip-permissions "[{\"IpProtocol\": \"tcp\", \"FromPort\": 443, \"ToPort\": 443, \"IpRanges\": [{\"CidrIp\": \"${public_ip_address}/32\"}]}]"
@davidmukiibi
davidmukiibi / config.yml
Created December 3, 2019 03:13
circleci configuration with firewall system test
default: &defaults
parallelism: 1
docker:
- image: ubuntu:latest
setup: &setup
run:
name: Installing aws cli and setting it up
command: |
chmod 777 setup.sh
pipeline {
agent any
stages {
stage('Performance Testing') {
steps {
echo 'Running K6 performance tests...'
sh 'sudo chmod +x setup.sh'
sh 'sudo ./setup.sh'
sh 'k6 run tests/test.js'
echo 'Completed Running K6 performance tests!'
## How do we enable Firewall? If we add the bash scripts as
## https://github.com/loadimpact/k6-circleci-example/tree/master/aws
## will the following works?
make_scripts_executable: &make_scripts_executable
run:
name: making scripts executable
command: |
chmod +x ./authorize_aws_security_group.sh
chmod +x ./revoke_aws_security_group.sh
default: &defaults
parallelism: 1
docker:
- image: loadimpact/k6:latest
k6_performance_tests: &k6_performance_tests
run:
name: Running Load Tests Using K6
command: |
k6 cloud tests/cloud-test.js