Skip to content

Instantly share code, notes, and snippets.

View arehmandev's full-sized avatar
🎯
Focusing

Abdul Rehman arehmandev

🎯
Focusing
  • Capgemini
  • London, UK
View GitHub Profile
@arehmandev
arehmandev / main.tf
Created August 12, 2021 06:45
Nested surfacing dict
locals {
input = {
"projects" : {
"another" : {
"accounts" : [
"one",
"two"
]
},
"test" : {
@arehmandev
arehmandev / main.tf
Created August 11, 2021 01:10
example of tf map manipulation
locals {
virtual_machines = {
"test-services1" = {
vm_instance_group = "instance-group-services"
},
"test-services2" = {
vm_instance_group = "instance-group-services"
},
"test-cpu" = {
variable "subnets" {
type = list(any)
default = ["subnet-a", "subnet-b", "subnet-c"]
}
variable "instances" {
default = {
TEST1 = {
sg = ["example1"]
@arehmandev
arehmandev / Terraform nested for loop
Last active May 26, 2023 20:29
Terraform nested for loop for_each
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
map_output = {
"1-a-4-d" = {
"1" = "1"
"2" = "a"
"3" = "4"
"4" = "d"
}
# Pull in existing VPC
data "aws_vpc" "selected" {
id = var.vpc_id
}
# Subnet ids data source lookup allows multiple subnets to be provided
data "aws_subnet_ids" "private" {
vpc_id = data.aws_vpc.selected.id
filter {
package main
import "fmt"
func main() {
intslice := [][]int{[]int{1}, []int{2}}
// Grow
for index, value := range intslice {
@arehmandev
arehmandev / openvpn_gen.py
Created October 21, 2019 11:59 — forked from Justasic/openvpn_gen.py
This is a python script to generate client OpenVPN configuration files. This is based mostly on the easyrsa script and is much simpler to understand.
import os
import socket
from OpenSSL import crypto, SSL
# OpenVPN is fairly simple since it works on OpenSSL. The OpenVPN server contains
# a root certificate authority that can sign sub-certificates. The certificates
# have very little or no information on who they belong to besides a filename
# and any required information. Everything else is omitted or blank.
# The client certificate and private key are inserted into the .ovpn file
# which contains some settins as well and the entire thing is then ready for
@arehmandev
arehmandev / nginx.conf
Created October 14, 2019 19:24
Nginx transparent proxy
events {
worker_connections 1024;
}
http {
# google's DNS server
resolver 8.8.8.8;
resolver_timeout 5s;
server {
# proxy server port
@arehmandev
arehmandev / manage-openvpn-nopass.sh
Last active September 5, 2019 11:23
No pass when using -a
#!/bin/bash
#
# Copyright (c) 2013 Nyr. Released under the MIT License.
# Copyright (c) 2019 Fabrice Triboix
set -eu
###################
# Parse arguments #
@arehmandev
arehmandev / .zshrc
Last active August 19, 2019 14:26
terraform aliases
function tfinit () {
if [ -z "${1}" ]; then
terraform init
else
terraform init -backend-config=${1}
fi
}
function tfplan () {
if [ -z "${1}" ]; then