Skip to content

Instantly share code, notes, and snippets.

View brunopadz's full-sized avatar
🏴

Bruno Padilha brunopadz

🏴
View GitHub Profile
@brunopadz
brunopadz / variables.tf
Created February 21, 2022 21:38
Terraform variable validation
# Using anytrue()
variable "instance_size" {
type = string
description = "RDS Instance Size"
validation {
condition = anytrue([
var.instance_size == "db.t3.micro",
var.instance_size == "db.t3.small",
@brunopadz
brunopadz / consult_template_helm.yaml
Created January 14, 2022 14:58
Consul template inside a Helm Chart
# This example demonstrates how to use Consult templates inside a Helm Chart
# It's kinda useful when using Vault Agent Injector :)
# We basically have to use `s to escape all templating resources
vault.hashicorp.com/agent-inject-template-env: |
{{ `{{ with secret "`}} {{- $.Values.app.env -}}/data/{{ .Values.app.name }} {{`" }}
{{ range $k, $v := .Data.data }}
export {{ $k }}="{{ $v }}"
{{ end }}
{{ end }} `}}
@brunopadz
brunopadz / kong.service
Last active February 14, 2019 23:43
Kong API Gateway systemd config
[Unit]
Description= kong service
After=syslog.target network.target
[Service]
User=root
Group=root
Type=forking
LimitAS=infinity
LimitRSS=infinity
@brunopadz
brunopadz / delete_ec2_snapshots.sh
Last active April 4, 2020 16:12
Delete AWS Snapshots older than 15 days
DT=`date --date "-15 days" +"%Y-%m-%d"`
aws ec2 describe-snapshots --filters Name=description,Values="*OpsAutomator*" --query "Snapshots[?StartTime<='$DT'].{ID:SnapshotId}" | jq -r '.[] .ID' | while read rola; do
aws ec2 delete-snapshot --snapshot-id $rola && echo "ok" $rola || echo "not deleted"
done
@brunopadz
brunopadz / wololo.sh
Created May 15, 2018 18:15
Install awscli then copy files to S3
#!/bin/bash
AWSEXEC=`which aws`
AWSPATH=~/.aws/
PIPEXEC=`which pip`
function InstallAWS(){
if [ -a "$PIPEXEC" ]; then
$PIPEXEC install awscli --user --upgrade
else
@brunopadz
brunopadz / init.sh
Created May 12, 2018 17:23
Use fio command to initialize EBS volumes restored from snapshot
#!/bin/bash
fio --filename=/dev/xvdx --rw=read --bs=1m --iodepth=32 --ioengine=libaio --direct=1 --name=volume-initialize
@brunopadz
brunopadz / copy.sh
Last active April 22, 2018 14:39
Simple shell script to copy files over ssh
FILES=source_dir/*BACKUP*
for f in $FILES
do
echo "Copying $f at `date`" >> copy.log
scp -i key.ppk -p $f user@hostname:/destination_dir
if [ "$?" = 0 ]; then
echo "$f copy has finished at `date`" >> copy.log
else
echo "Error while trying to copy $f" >> error.log
@brunopadz
brunopadz / Jenkinsfile
Created March 20, 2018 01:59 — forked from jonico/Jenkinsfile
Example for a full blown Jenkins pipeline script with multiple stages, input steps, injected credentials, heroku deploy, sonarqube and artifactory integration, multiple Git commit statuses, PR merge vs branch build detection, REST API calls to GitHub deployment API, stage timeouts, stage concurrency constraints, ...
#!groovy
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
/*
Please make sure to add the following environment variables:
HEROKU_PREVIEW=<your heroku preview app>
HEROKU_PREPRODUCTION=<your heroku pre-production app>
HEROKU_PRODUCTION=<your heroku production app>
@brunopadz
brunopadz / sonarqube.service
Created March 14, 2018 13:36
systemd/sonarqube.service
[Unit]
Description=Sonarqube
After=network.target network-online.target
Wants=network-online.target
[Service]
ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
ExecReload=/opt/sonarqube/bin/linux-x86-64/sonar.sh restart
PIDFile=/opt/sonarqube/bin/linux-x86-64/./SonarQube.pid