Skip to content

Instantly share code, notes, and snippets.

@Bharathkumarraju
Bharathkumarraju / get_programmatic_access.sh
Last active August 15, 2019 23:00
Use MFA token to authenticate access to AWS resources through the AWS CLI
#!/bin/bash
set -o pipefail
usage() {
echo 'Usage:
source ./script.sh <IAM_USERNAME> <MFA_CODE> <ACCOUNT_ID> <PROFILE_NAME>
Requires:
* jq
* aws cli
* PROFILE_NAME is default when you do 'aws configure' at first
@Bharathkumarraju
Bharathkumarraju / Database.tf
Created September 9, 2019 02:53
Terraform - Create database password securely and store in remote-state
provider "aws" {
region = var.aws_region
profile = var.aws_profile
}
terraform {
backend "s3" {
bucket = "bharaths-terraform-up-and-running"
key = "development/data-stores/mysql/terraform.tfstate"
#!/bin/bash
aws ecr describe-repositories | jq -r '.repositories[].repositoryName'
@Bharathkumarraju
Bharathkumarraju / Dockerfile
Created October 1, 2019 03:51 — forked from duduribeiro/Dockerfile
Dockerfile 2
# dump build stage
FROM postgres:11-alpine as dumper
COPY test_dump.sql /docker-entrypoint-initdb.d/
RUN ["sed", "-i", "s/exec \"$@\"/echo \"skipping...\"/", "/usr/local/bin/docker-entrypoint.sh"]
ENV PG_USER=postgres
ENV PGDATA=/data
@Bharathkumarraju
Bharathkumarraju / networking.tf
Created October 1, 2019 03:52 — forked from duduribeiro/networking.tf
Terraform staging - networking.tf
module "networking" {
source = "../modules/networking"
environment = "${var.environment}"
vpc_cidr = "${var.vpc_cidr}"
public_subnet_cidr = "${var.public_subnet_cidr}"
private_subnet_cidr = "${var.private_subnet_cidr}"
region = "${var.region}"
availability_zone = "${var.availability_zone}"
key_name = "${var.key_name}"
}
jobs:
should_run:
name: should run the next job
runs-on: ubuntu-latest
steps:
- name: check if vb is the commiter
if: github.event.pusher.name != 'vibou'
run: exit 1 # the job fails if not vibou
perform_action:
name: should run the next job
@Bharathkumarraju
Bharathkumarraju / list_all_k8s_resources.sh
Last active May 19, 2020 03:05
List all available api resources in all namespaces in kubernetes cluster
#! /bin/bash
ALL_RESOURCES=$(kubectl api-resources | awk 'NR>1' | awk '{print $1}' | xargs echo)
for i in $ALL_RESOURCES
do
echo -e "$i\n------------------------------------------------------------------"
kubectl get $i --all-namespaces
echo -e "\n"
done
{
"Statement": [
{
"Sid": "PackerSecurityGroupAccess",
"Action": [
"ec2:CreateSecurityGroup",
"ec2:DeleteSecurityGroup",
"ec2:DescribeSecurityGroups",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:RevokeSecurityGroupIngress"
ARG ALPINE_VERSION=3.11
FROM alpine:${ALPINE_VERSION}
# packages version
ARG PACKER_VERSION=1.6.0
# PARAMETERS
ARG PACKER_URL="https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_secret_key": "{{env `AWS_SECRET_KEY`}}",
"aws_instance_type": "{{env `AWS_INSTANCE_TYPE`}}",
"aws_ami_name": "{{env `AWS_AMI_NAME`}}",
"aws_region": "{{env `AWS_REGION`}}",
"aws_ami_filter_name": "{{env `AWS_AMI_FILTER_NAME`}}",
"aws_base_ami_owner": "{{env `AWS_BASE_AMI_OWNER`}}"
},