Skip to content

Instantly share code, notes, and snippets.

View lavk7's full-sized avatar

Lav Khanna lavk7

View GitHub Profile
@lavk7
lavk7 / ecs.sh
Created October 18, 2020 08:19
list-cluster-by-tag
aws ecs describe-clusters --cluster `aws ecs list-clusters --query 'clusterArns[]' --output text` --include TAGS --query 'clusters[?contains(tags[].value, `MY_TAG_VALUE`)].clusterName' --output text
@lavk7
lavk7 / gitlab_to_ecr.sh
Created September 15, 2020 06:31
GITLAB_TO_ECR
#!/usr/bin/env bash
set -ex
GITLAB_REGISTRY="XXXXXX"
GITLAB_URL="XXXXX"
AWS_REGION="XXXX"
PROFILE="XXXX"
AWS_ACCOUNT="XXXXXXX"
ECR_ARN=XXXXX
@lavk7
lavk7 / declarative.groovy
Created August 28, 2020 03:39
Parallel stages #jenkins #pipeline
pipeline {
agent none
stages {
stage('Run Tests') {
parallel {
stage('Test On Windows') {
agent {
label "windows"
}
steps {
@lavk7
lavk7 / regeg.groovy
Created August 27, 2020 01:22
jenkins_match_regex
def matchers = ["develop", "master", "0.0.1", "release-0.0.1", "hotfix-0.0.1", "test"]
pipeline {
stages {
stage("test"){
allOf{
expression {
matchers.each{
match ->
if (! match ==~ /^(develop)$|^(master)$|^(\d+\.\d+\.\d+)$|^(release-\d+\.\d+\.\d+)$|^(hotfix-\d+\.\d+\.\d+)$/){
@lavk7
lavk7 / withCredentials Example
Created August 20, 2020 02:24
Jenkins Snippet With Credentials
withCredentials([
usernamePassword(credentialsId: argoConfig['credentialsId'], usernameVariable: "ARGO_USR", passwordVariable: "ARGO_PW"),
usernamePassword(credentialsId: gitConfig['credentialsId'], usernameVariable: "GIT_USR", passwordVariable: "GIT_PW")
]){
}
@lavk7
lavk7 / find.sh
Created August 19, 2020 02:42
[Find Regex] #find #linux #shell
find . \( -name "*.msa" -o -name "*.lambda" -o -name "*.front" \) | xargs basename | sed -E 's/(.*)\.(msa|lambda|front)/\1/g'
@lavk7
lavk7 / ami.tf
Created August 11, 2020 10:07
latestAmi #aws #terraform
data "aws_ami" "amazon-linux-2" {
most_recent = true
owners = ["amazon"]
name_regex = "^amzn2-ami-hvm.*-ebs"
filter {
name = "architecture"
values = ["x86_64"]
}
}
@lavk7
lavk7 / role.json
Created August 11, 2020 08:59
assume role #aws #role
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""