Skip to content

Instantly share code, notes, and snippets.

View mlabouardy's full-sized avatar
☁️
Subscribe to my newsletter ➡️ https://devopsbulletin.com

LABOUARDY Mohamed mlabouardy

☁️
Subscribe to my newsletter ➡️ https://devopsbulletin.com
View GitHub Profile
@mlabouardy
mlabouardy / handler.js
Last active January 21, 2019 19:01
Ship Kinesis events to Logstash
const Zlib = require('zlib');
const Logstash = require('logstash-client');
const lambdaVersion = function (logStream) {
let start = logStream.indexOf('[');
let end = logStream.indexOf(']');
return logStream.substring(start+1, end);
}
exports.handler = async (event, context) => {
@mlabouardy
mlabouardy / logstash.conf
Last active January 21, 2019 18:59
Expost Gelf and UDP inputs
input {
udp {
type => lambda
port => 7000
}
gelf {
type => docker
port => 5000
}
@mlabouardy
mlabouardy / trust-policy.json
Created January 20, 2019 11:37
CloudWatch Logs Trust policy
{
"Statement": {
"Effect": "Allow",
"Principal": { "Service": "logs.AWS_REGION.amazonaws.com" },
"Action": "sts:AssumeRole"
}
}
@mlabouardy
mlabouardy / policy.json
Created January 20, 2019 11:36
Allow CloudWatch to stream logs to Kinesis
{
"Statement": [
{
"Effect": "Allow",
"Action": "kinesis:PutRecord",
"Resource": "arn:aws:kinesis:AWS_REGION:ACOUNT_ID:stream/cloudwatch-logs"
},
{
"Effect": "Allow",
"Action": "iam:PassRole",
@mlabouardy
mlabouardy / kinesis-stream.json
Created January 20, 2019 11:09
Kinesis Data Stream input event
{
"Records": [
{
"kinesis": {
"partitionKey": "partitionKey-03",
"kinesisSchemaVersion": "1.0",
"data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=",
"sequenceNumber": "49545115243490985018280067714973144582180062593244200961",
"approximateArrivalTimestamp": 1428537600
},
@mlabouardy
mlabouardy / execution-role.json
Created January 20, 2019 11:07
Execution role for Kinesis consumer
{
"roleName": "LogsConsumerRole",
"policies": [
{
"document": {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
@mlabouardy
mlabouardy / create-kinesis-stream.sh
Created January 20, 2019 10:26
Create Kinesis Data Stream
aws kinesis create-stream --stream-name cloudwatch-logs --shard-count 10
@mlabouardy
mlabouardy / repository.groovy
Created January 5, 2019 13:35
Create Docker hosted repository on Nexus with Groovy script
import org.sonatype.nexus.blobstore.api.BlobStoreManager;
import org.sonatype.nexus.repository.storage.WritePolicy;
repository.createDockerHosted('mlabouardy', 5000, 443, BlobStoreManager.DEFAULT_BLOBSTORE_NAME, true, true, WritePolicy.ALLOW)
@mlabouardy
mlabouardy / setup.sh
Created January 5, 2019 13:34
Install Nexus on Centos
#!/bin/bash
NEXUS_USERNAME="admin"
NEXUS_PASSWORD="admin123"
echo "Install Java JDK 8"
yum update -y
yum install -y java-1.8.0-openjdk wget
echo "Install Nexus OSS"
@mlabouardy
mlabouardy / template.json
Created January 5, 2019 13:34
Packer template to bake Nexus GCP image
{
"variables" : {
"zone" : "YOUR ZONE",
"project" : "YOUR PROJECT ID",
"source_image" : "centos-7-v20181210",
"ssh_username" : "packer",
"credentials_path" : "PATH/account.json"
},
"builders" : [
{