Skip to content

Instantly share code, notes, and snippets.

View jcbagtas's full-sized avatar
💭
IaC <3 DevOps

JC Bagtas jcbagtas

💭
IaC <3 DevOps
View GitHub Profile
@jcbagtas
jcbagtas / aws-s3-public-by-tag.json
Created January 28, 2023 07:57
AWS S3 public read based on object tag
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Statement1",
"Principal": {
"AWS": "*"
},
"Effect": "Allow",
"Action": [
@jcbagtas
jcbagtas / config.sh
Created February 19, 2021 05:21
Configuration-Baseline
# workstation-ks.cfg
# version 1.0.1 2012-03-15
# Copyright 2010,2011,2012 Red Hat Inc., Durham, North Carolina.
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
@jcbagtas
jcbagtas / confset.pl
Last active February 18, 2021 08:20
perl confset.pl ./some.cf "key = value" or perl confset.pl ./some.conf "key=value"
#!/usr/bin/perl
use strict;
my $scriptname = $0;
my $separator = '=';
my $whitespace = 0;
my @files = ();
my @namevalues = ();
@jcbagtas
jcbagtas / banner-creator.sh
Created November 27, 2020 07:58
Create a Bannered Text that demands attention.
## EMBED THIS FUNCTION INSIDE YOUR BASH FILE
banner () {
case $3 in
RED)COLOR='\033[0;31m'
;;CYAN)COLOR='\033[0;36m'
;;GREEN)COLOR='\033[0;32m'
;;LGREEN)COLOR='\033[1;32m'
;;PURPLE)COLOR='\033[0;35m'
;;BROWN)COLOR='\033[0;33m'
@jcbagtas
jcbagtas / az-loations.md
Created September 14, 2020 03:25
Azure Region List Location
az account list-locations -o table
DisplayName Latitude Longitude Name
East Asia 22.267 114.188 eastasia
Southeast Asia 1.283 103.833 southeastasia
Central US 41.5908 -93.6208 centralus
East US 37.3719 -79.8164 eastus
@jcbagtas
jcbagtas / install-az-extensions.md
Created August 27, 2020 15:55
Install AZ Extensions

How to Install Azure CLI Extensions

Personal Note on how to install Azure CLI Extension or AZ Extensions

References

List of Azure Extensions

az extension add --name [extension]
@jcbagtas
jcbagtas / slack.sh
Created May 2, 2020 11:31 — forked from andkirby/slack.sh
Shell/Bash script for sending slack messages.
#!/usr/bin/env bash
####################################################################################
# Slack Bash console script for sending messages.
####################################################################################
# Installation
# $ curl -s https://gist.githubusercontent.com/andkirby/67a774513215d7ba06384186dd441d9e/raw --output /usr/bin/slack
# $ chmod +x /usr/bin/slack
####################################################################################
# USAGE
# Send message to slack channel/user
@jcbagtas
jcbagtas / terraform.tf
Created April 14, 2020 13:28
Merge a variable List of Maps in Terraform 0.12
# This gist mimics the supposed behavior of
# variable = merge(someListOfMaps[*].parameters...)
# or
# policy_parameters = merge(data.azurerm_policy_definition.d_policy_definitions[*].parameters...)
locals {
policy_parameters = [
for key,value in data.azurerm_policy_definition.d_policy_definitions:
{
parameters = jsondecode(value.parameters)
cat access_log | awk '{print $8}' | sort -n | uniq -c | sort -nr | head -20
@jcbagtas
jcbagtas / list-my-files.js
Last active March 24, 2018 16:19
Node JS script to list AWS S3 Objects inside an S3 Bucket
exports.handler = (event, context, callback) => {
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
var inputObj = event.queryStringParameters ? event.queryStringParameters : event;
var Bucket = inputObj.Bucket = inputObj.Bucket!==undefined ? inputObj.Bucket : null;
var Prefix = inputObj.Prefix = inputObj.Prefix!==undefined ? inputObj.Prefix : null;
var params = {Prefix,Bucket};
s3.listObjects(params, function(err, data) {
if (err){
callback({status:false,message:err},null);