Skip to content

Instantly share code, notes, and snippets.

View naturalett's full-sized avatar

Lidor Ettinger naturalett

View GitHub Profile
@naturalett
naturalett / terragrunt.hcl
Created September 22, 2022 22:07
terragrunt/modules/vpc/terragrunt.hcl
terraform {
source = "tfr:///terraform-aws-modules/vpc/aws?version=3.14.2"
}
@naturalett
naturalett / custom-values.yaml
Created January 12, 2022 08:31
airflow custom values
########################################
## CONFIG | Airflow Configs
########################################
airflow:
extraPipPackages:
- "datadog==0.42.0"
- "apache-airflow[statsd]"
config:
AIRFLOW__METRICS__STATSD_ON: true
AIRFLOW__METRICS__STATSD_HOST: "localhost"
@naturalett
naturalett / ccloudexporterWithDatadog.yml
Created May 24, 2020 22:01
ccloudexporter with datadog
version: '3.1'
services:
ccloud_exporter:
ports:
- 2112:2112
image: dabz/ccloudexporter
environment:
CCLOUD_USER: ${CCLOUD_USER}
CCLOUD_PASSWORD: ${CCLOUD_PASSWORD}
command: -cluster ${CCLOUD_CLUSTER}
'''Example code of the SecretManager class'''
class SecretManager(object):
def __init__(self, serviceName, environment, awsRegion="us-east-1", filepath=""):
try:
self.SERVICE_NAME = serviceName.lower()
self.ENVIRONMENT = environment.lower()
self.FILEPATH = filepath
self.ssm = self.initSSM(awsRegion)
self.CREDENTIAL_KEY_PREFIX = "cred"
'''Example code of the SecretManagerTest class'''
import unittest, os.path
from os.path import dirname, abspath
import SecretManager
class SecretManagerTest(unittest.TestCase):
SERVICE_NAME = "helloWorld"
ENVIRONMENT = "test"
FILEPATH = os.path.join(dirname(dirname(abspath(os.path.dirname( __file__ )))), 'ssm.json')
@naturalett
naturalett / buildGithubCheckPipeline.groovy
Created March 24, 2020 15:17
buildGithubCheckPipeline
def check_runs = new com.functions.buildGithubCheckScript()
pipeline {
agent {
kubernetes {
label "GitHub-Check-Runs-${UUID.randomUUID().toString().substring(0,8)}"
defaultContainer 'jnlp'
}
}
stages {
@naturalett
naturalett / buildGithubCheckScript.groovy
Created March 17, 2020 22:50
buildGithubCheckScript
@Grab(group='io.jsonwebtoken', module='jjwt', version='0.4')
import sun.net.www.protocol.https.HttpsURLConnectionImpl
import java.text.SimpleDateFormat
import java.lang.reflect.*
import java.util.*
import java.nio.charset.StandardCharsets
import java.io.*
import javax.crypto.KeyGenerator
import java.security.*
import groovy.json.*
// Custom HTTP request method
def setRequestMethod(HttpURLConnection c, String requestMethod) {
try {
final Object target;
if (c instanceof HttpsURLConnectionImpl) {
final Field delegate = HttpsURLConnectionImpl.class.getDeclaredField("delegate");
delegate.setAccessible(true);
target = delegate.get(c);
} else {
target = c;
@naturalett
naturalett / getRSAPrivateKey.groovy
Created February 23, 2020 23:05
getRSAPrivateKey
def getRSAPrivateKey(privateKey) {
try {
String privateKeyPEM = readFile privateKey
privateKeyPEM = privateKeyPEM.replace("-----BEGIN CERTIFICATE-----\n", "");
privateKeyPEM = privateKeyPEM.replace("-----END CERTIFICATE-----", "");
byte[] encoded = Base64.decodeBase64(privateKeyPEM);
KeyFactory kf = KeyFactory.getInstance("RSA");
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded);
RSAPrivateKey privKey = (RSAPrivateKey) kf.generatePrivate(keySpec);
@naturalett
naturalett / buildGithubCheck.groovy
Created February 23, 2020 22:52
buildGithubCheck
def buildGithubCheck(repository, commitID, privateKey, status, checkName) {
def currentTime = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'")
def checkName_run_id
jsonWebToken = getJsonWebToken(privateKey)
getStatusCode = validateAuth(jsonWebToken)
if (!(getStatusCode in [200,201])) {
error "Authentication request failed, status code: ${getStatusCode}"
}
token = getToken(jsonWebToken)