Skip to content

Instantly share code, notes, and snippets.

@rshettynj
rshettynj / gist:aa120ee1e33179bd91dbb95dead646ac
Created April 25, 2025 18:11
bitbucket access token use.
https://bitbucket.org/rshettynj/workspace/snippets/y7MMny
https://github.com/rshettynj/import_sg_terragrunt/
Read the README.
Any questions, happy to discuss.
@rshettynj
rshettynj / gist:e03e2cdec1fe67366c146b2659aed868
Last active March 26, 2025 21:39
Importing ec2 resource to terraform using terragrunt
Here is the code layout for terragrunt.
├── backend.tf
├── ec2
│   └── terragrunt.hcl
├── fifo
│   ├── sqs_fifo
│   │   └── terragrunt.hcl
│   ├── sqs_fifo2
│   │   └── terragrunt.hcl
│   └── terragrunt.hcl
apiService
clusterRole
clusterRoleBinding
configmap
controllerRevision
cronJob
customResourceDefinition
daemonSet
deployment
event
@rshettynj
rshettynj / gist:78853a02c53d854d0b1432537501e42d
Last active June 8, 2022 01:46
Python parallel function execution
def function1(mydict):
print(mydict)
def function2(mydict):
print(mydict)
from multiprocessing import Process
#create and pass dictionary data to two functions..
gdict = {"one": 1, "two": 2, "ten": "last" }
p1 = Process(target=function1, args=(gdict,))
Audience: DevOps who wants to use JSON input parameters in the Spinnaker.
Why use JSON input?
JSON simplifies storing large number of key/values data in one place. Spinnkaer as such supports simple string, list and map. It takes some time to get the JSON input working correctly with Spinnaker SPEL language. This document will help you with easy reference.
Example JSON data:
{ "awsregions": { "NV": "us-east-1", "OH": "us-east-2", "FR": "eu-central-1" } }
@rshettynj
rshettynj / gist:6b0915d4225138a8843eeede9aa1bc90
Last active November 24, 2020 21:59
Preparing cloudtrail for AWS events
Requirement: Enable a workflow in AWS to "Run a precreated ECS task" when a particular "s3 bucket" is updated with an object
(PutObject operation.)
In simple terms, we want ECS task to run when we put an object to s3 bucket.
Pre-requisites:
1. Cloudtrail configuration:
@rshettynj
rshettynj / gist:c49868a45d7a9208d56465637326c20d
Last active October 12, 2021 15:01
Writing OPA rules for JSON files
How to create custom polices as a rule in OPA (Open Policy Agent)?
Requirement:
In DevOPs Practice, you may want to make sure the JSON input files are adhering certain company standards. You need to have a way to
apply such custom polciies as a rule or set of rules and trigger against the JSON file.
You will then fail or pass the JSON in your pipeline based on the status of the policy check.
Scenarios where JSON files needs to be validated:
1. JSON linting //Basic formatting and Syntax checks.
2. Sematic checks and business logic checks.
@rshettynj
rshettynj / gist:ac96f92deda5e12b8195d1e9d1d97f6f
Last active October 9, 2020 15:03
AWS Lambda: How to list items using Marker
Some AWS resources require you to use "Marker" in order to "list" lot of resources in a service. Usuallly AWS presets the number of items
to return when API call is made. It may be 50 for listing Lambda functions in your account. If you need to more (all) functions, usually
AWS provides (returns) a Marker when API call is made. This Marker needs to be sent in the subsequent API requests so they recognise
the request is continuation of the previous call and provide the next set of new results.
example: if you have lambdas called lambda1, lambda2, lambda3 upto lamba120.
In the first call, you get lambda1 to lambda50. Next call with Marker returns lambda51 to lambda100 and next call returns lambda101 to
lambda120 and subsequent calls returns nothing.
@rshettynj
rshettynj / gist:28153481dd16679e6d7677239b2f8bef
Created June 12, 2020 16:59
Using AWS Codeartifact with Codebuild
What is Codeartifact?
AWS Codeartifact is newly release fully managed service for storing packages/artifacts. You can store Maven, Python and
few other package types.
Storing such packages and later using it in builds ensures that you are using an authenticated package that someone tested and
pushed to the codeartifactory and not any random package/unapproved packages you download from Internet.
packages are stored in "domain" and "repository" format. You can have multiple domains and each domain can multiple repositories
in your account.