Skip to content

Instantly share code, notes, and snippets.

View mrajani's full-sized avatar

Mahesh Rajani mrajani

  • San Francisco Bay Area
  • 09:58 (UTC -07:00)
View GitHub Profile
@mrajani
mrajani / aws_credentials.tf
Last active September 24, 2025 16:38
Take shell env AWS credentials and save it to file for Scripting
provider "local" {}
# Grab values from environment variables
variable "aws_access_key_id" {
type = string
default = "" # picked up from env if set
}
variable "aws_secret_access_key" {
type = string
#!/bin/bash
# Collection of Repos for learning Terraform, Vault, Ansible, etc. etc.
mkdir repos && cd repos
git clone https://github.com/linuxacademy/content-deploying-to-aws-ansible-terraform.git
git clone https://github.com/hashicorp/vault-guides
git clone https://github.com/hashicorp/terraform-aws-vault
git clone https://github.com/hashicorp/terraform-aws-consul
git clone https://github.com/linuxacademy/content-devops-monitoring-app.git
git clone https://github.com/dmahler/ansible-template.git
git clone https://github.com/do-community/ansible-playbooks.git
#!/bin/bash
puttygen mykey.ppk -O private-openssh -o mykey.pem
#!/bin/bash
az login
az account list-locations | tee az_locations.json
cat az_locations.json | jq '.[] | "\(.name): \(.displayName)"'
@mrajani
mrajani / gather_facts_from_azure_vm_metadata.yaml
Last active September 8, 2021 11:46 — forked from DevoKun/gather_facts_from_azure_vm_metadata.yaml
Ansible Gather Facts from Azure VM Metadata
---
- hosts: localhost
pre_tasks:
- name: "apt install curl"
apt:
name: curl
state: latest
when: ansible_os_family == "Debian"
#region Ensure the WinRm service is running
Set-Service -Name "WinRM" -StartupType Automatic
Start-Service -Name "WinRM"
#endregion
#region Enable PS remoting
if (-not (Get-PSSessionConfiguration) -or (-not (Get-ChildItem WSMan:\localhost\Listener))) {
Enable-PSRemoting -SkipNetworkProfileCheck -Force
}
#endregion
@mrajani
mrajani / InstallChocolateyPackages.ps1
Created March 11, 2021 15:57 — forked from ddieppa/InstallChocolateyPackages.ps1
My "must" chocolatey packages
function main {
Update-Windows-Configuration
Install-Utils
Install-Browsers
Install-Fonts
@mrajani
mrajani / lambda_setup.sh
Created December 29, 2020 01:33
Lambda setup
#!/bin/bash
# Source https://github.com/aws-samples/aws-lambda-ddns-function
aws iam create-policy --policy-name ddns-lambda-policy --policy-document file://ddns-pol.json
aws iam create-role --role-name ddns-lambda-role --assume-role-policy-document file://ddns-trust.json
aws iam attach-role-policy --role-name ddns-lambda-role \
--policy-arn arn:aws:iam::164033467123:policy/ddns-lambda-policy
aws lambda create-function --function-name ddns_lambda --runtime python3.8 \
@mrajani
mrajani / userdata.sh
Last active October 21, 2020 23:58
Ec2 Userdata
#!/bin/bash
yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service
export HOSTNAME=$(curl http://169.254.169.254/latest/meta-data/public-hostname)
export PUBLIC_IPV4=$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
echo Hello World from $HOSTNAME, with IP Address: $PUBLIC_IPV4 > /var/www/html/index.html