Skip to content

Instantly share code, notes, and snippets.

@kmkale
kmkale / aws-process-default-sg-security-rules.js
Last active November 1, 2017 01:49
aws-process-default-sg-security-rules
const aws = require('aws-sdk');
const ec2 = new aws.EC2();
const lambda = new aws.Lambda();
exports.handler = (event, context, callback) => {
if (!(event.regions)) {
//lets get the regions
ec2.describeRegions({}, function(regionerr, region_data) {
if (regionerr) {
console.log("Error from ec2.describeRegions: ", regionerr);
@kmkale
kmkale / handler-aws-process-default-sg-security-rules.js
Created November 1, 2017 01:55
handler Function for aws-process-default-sg-security-rules
const aws = require('aws-sdk');
const ec2 = new aws.EC2();
const lambda = new aws.Lambda();
exports.handler = (event, context, callback) => {
if (!(event.regions)) {
//lets get the regions
ec2.describeRegions({}, function(regionerr, region_data) {
if (regionerr) {
console.log("Error from ec2.describeRegions: ", regionerr);
@kmkale
kmkale / invokeLambda-aws-process-default-sg-security-rules.js
Created November 1, 2017 02:13
invokeLambda Function for aws-process-default-sg-security-rules
/**
* Invokes the given lambda function with received invoke_params
* @param {Object} invoke_params object with region and VPC arrays
* @param {String} functionName Name of the Lambda function to invoke
*/
function invokeLambda(invoke_params, functionName, callback) {
console.log("invokeLambda received invoke_params: " + JSON.stringify(invoke_params));
console.log("invokeLambda received functionName: " + functionName);
var params = {
FunctionName: functionName,
@kmkale
kmkale / deleteRulesFromDefaultSG-aws-process-default-sg-security-rules.js
Created November 1, 2017 02:16
deleteRulesFromDefaultSG Function for aws-process-default-sg-security-rules
/**
* This function calls ec2.describeSecurityGroups with a filter of group-name = default
* If it find any ingress or egress rules in the default security group it calls
* ec2.revokeSecurityGroupIngress and ec2.revokeSecurityGroupEgress to remove these rules
* @param {[String} thisregion region to process
* @param {Function} cb callback
*/
function deleteRulesFromDefaultSG(thisregion, cb) {
console.log("in deleteRulesFromDefaultSG processing region: ", thisregion);
var regional_ec2 = new aws.EC2({
@kmkale
kmkale / getAccounts.js
Last active September 29, 2023 11:16
Get Accounts Lambda Stub
/* getAccounts.js
This lambda returns a stubbed response for CDR Get Accounts API
https://consumerdatastandardsaustralia.github.io/standards/#get-accounts
*/
exports.handler = async (event, context) => {
const response = {
statusCode: 200,
body: JSON.stringify({
@kmkale
kmkale / openbanking-mtls-test.yaml
Created September 19, 2020 06:27
Open Banking MTLS Test API
openapi: "3.0.1"
info:
title: "openbanking-mtls-test"
version: "2020-09-19 06:20:03UTC"
servers:
paths:
/v1/banking/accounts:
get:
responses:
default:
@kmkale
kmkale / mtls-lambda-authoriser.py
Last active January 3, 2023 16:08
AWS API Gw mTLS Lambda Authoriser for certificate revocation check with OCSP & CLR
import json
import os
from certvalidator import CertificateValidator, ValidationContext, errors
import boto3
from asn1crypto import pem
'''
Let's load our truststore from s3. Doing this outside of handler function so that this will be loaded only on coldstart.
If the truststore contents change, you need to update the lambda env var 'TRUSTSTORE_FILE_VERSIONID'
with the new files versionId. And also update the same in 'API Gateway > Custom domain names > Domain details > Truststore version' and wait till Status becomes Available.