Skip to content

Instantly share code, notes, and snippets.

@yasinai
yasinai / jenkins-git-backup.sh
Created November 21, 2017 08:16 — forked from abayer/jenkins-git-backup.sh
Example of a script for backing up Jenkins config in git.
#!/bin/bash
#
# Copies certain kinds of known files and directories from a given Jenkins master directory
# into a git repo, removing any old ones, adds 'em, commits 'em, pushes 'em.
#
set -ex
if [ $# -ne 2 ]; then
echo usage: $0 root_dir jenkins_master
@yasinai
yasinai / jenkins-decrypt.groovy
Created November 26, 2017 12:06 — forked from tuxfight3r/jenkins-decrypt.groovy
Decrypting Jenkins Password
#To Decrypt Jenkins Password from credentials.xml
#<username>jenkins</username>
#<passphrase>your-sercret-hash-S0SKVKUuFfUfrY3UhhUC3J</passphrase>
#go to the jenkins url
http://jenkins-host/script
#In the console paste the script
hashed_pw='your-sercret-hash-S0SKVKUuFfUfrY3UhhUC3J'
@yasinai
yasinai / gist:ce3d25808c026423ffe7a54487eafc9f
Created December 13, 2017 09:46 — forked from kabronkline/gist:6581453
PowerShell SVN Checkout / Export
# SVN Export Script
#
# Given an SVN URL and local directory path, this script copies all files from
# SVN into the specified local directory.
#
# Uses SharpSVN DLL v1.7002.1998 (Documentation : http://docs.sharpsvn.net/current/)
#
# Takes two command line arguments, an SVN URL and a local directory path.
param ([string]$svnUrl = $(read-host "Please specify the path to SVN"),
[string]$svnLocalPath = $(read-host "Please specify the local path"),
@yasinai
yasinai / augeas.ps1
Created December 21, 2017 06:54 — forked from spuder/augeas.ps1
Powershell replace single xml line
# Based on this script https://ask.puppetlabs.com/question/4749/augeas-or-alternative-xml-modification-on-windows/
# I had to flip the logic if $node.NodeType -ne 'Element' to get it to work properly
[CmdletBinding()]
param (
[string] $filename = $(throw "filename is a required parameter"),
[string] $xpath = $(throw "xpath is a required parameter"),
[string] $value = $(throw "value is a required parameter")
)
@yasinai
yasinai / xpath-example.ps1
Created December 21, 2017 06:54 — forked from jpoehls/xpath-example.ps1
Use XPath to update XML using PowerShell
function Edit-XmlNodes {
param (
[xml] $doc = $(throw "doc is a required parameter"),
[string] $xpath = $(throw "xpath is a required parameter"),
[string] $value = $(throw "value is a required parameter"),
[bool] $condition = $true
)
if ($condition -eq $true) {
$nodes = $doc.SelectNodes($xpath)
@yasinai
yasinai / Timeout.ps1
Created January 14, 2018 13:57 — forked from lazywinadmin/Timeout.ps1
Timeout in powershell
#requires -Version 2
$maximumRuntimeSeconds = 3
$process = Start-Process -FilePath powershell.exe -ArgumentList '-Command Start-Sleep -Seconds 4' -PassThru
try
{
$process | Wait-Process -Timeout $maximumRuntimeSeconds -ErrorAction Stop
Write-Warning -Message 'Process successfully completed within timeout.'
@yasinai
yasinai / changesets.groovy
Created March 7, 2018 08:32 — forked from lsjostro/changesets.groovy
Jenkinsfile: build only changed files
#!groovy
@NonCPS
def getACIChangeSets() {
def aci = []
currentBuild.rawBuild.getChangeSets().each { cs ->
cs.getItems().each { item ->
item.getAffectedFiles().each { f ->
if (f.path.endsWith(".yml")) {
aci << f.path
}
@yasinai
yasinai / pom-advance-snapshots.sh
Created March 27, 2018 14:35 — forked from swthomas55/pom-advance-snapshots.sh
Manage POM versions in multi-module Maven projects
#! /bin/sh
#
# Usage: pom-advance-snapshots.sh
#
# Update the version of every POM to the next patch version, append the git branch name and SNAPSHOT
# unless the POM already has a SNAPSHOT version.
#
# Thus, version 1.3.4 becomes 1.3.5-branch-SNAPSHOT.
#
# Requires xmlstarlet and maven versions plugin. Invokes maven as "mvn".
@yasinai
yasinai / prometheus
Created January 8, 2019 16:45 — forked from JoergM/prometheus
Prometheus init file for RHEL 5 or 6
#!/bin/bash
#
# /etc/rc.d/init.d/prometheus
#
# Prometheus monitoring server
#
# chkconfig: 2345 20 80 Read
# description: Prometheus monitoring server
# processname: prometheus

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.