Skip to content

Instantly share code, notes, and snippets.

View skorfmann's full-sized avatar

Sebastian Korfmann skorfmann

View GitHub Profile
@skorfmann
skorfmann / Readme.md
Last active November 27, 2023 00:39
Private Api Gateway in CDK.

Private API Gateway with the AWS CDK

  • Lambda
  • Private Api Gateway
  • VPC Endpoint

NB: In order to access the Api Gateway through the public DNS of the VPC endpoint, a curl request has to have the api id as header. See also here

curl -i -H "x-apigw-api-id: " https://vpce-.execute-api..vpce.amazonaws.com/
/**
* Post-synthesis function to configure AWS provider for LocalStack
*/
exports.postSynth = function(config) {
const endpoint = "http://localhost:4566";
const services = [
"apigateway", "apigatewayv2", "cloudformation", "cloudwatch", "dynamodb", "ec2", "es",
"elasticache", "firehose", "iam", "kinesis", "lambda", "rds", "redshift", "route53",
"secretsmanager", "ses", "sns", "sqs", "ssm", "stepfunctions", "sts"

Both things have been introduced recently, and let you access even private ec2 instances

  1. Without VPN
  2. No open SSH port
  3. Authentication / Authorization is fully delegated to IAM
# Assumes valid AWS Credentials in ENV

MoneyMoney CSV Export with Apple Script and Automator

  • adjust set accounts to {"IBAN 1", "IBAN 2"}
  • replace yourPassword with your MoneyMoney password
  • replace /your/local/path/ with your actual target path
  • set the time range set yesterday to (today - (1 * days))

Load this file in Automator and get fully automated exports.

import ecs = require('@aws-cdk/aws-ecs');
import { DockerImageAsset } from '@aws-cdk/aws-ecr-assets';
import path = require('path')
export interface FooFargateProps {
}
export class FooFargate extends cdk.Construct {
constructor(scope: cdk.Construct, id: string, props: FooFargateProps = {}) {
@skorfmann
skorfmann / event-proxy-lambda.js
Last active September 2, 2022 12:09
AWS CDK EventBridge -> AppSync Subscriptions Proxy
const AWS = require('aws-sdk')
const appsync = require('aws-appsync');
const gql = require('graphql-tag');
require('cross-fetch/polyfill');
exports.handler = async function(event) {
const graphqlClient = new appsync.AWSAppSyncClient({
url: process.env.APPSYNC_ENDPOINT_URL,
region: process.env.AWS_REGION,
auth: {
import { Credentials } from "@aws-amplify/core";
import { AuthOptions, createAuthLink } from "aws-appsync-auth-link";
import { createSubscriptionHandshakeLink } from "aws-appsync-subscription-link";
import {
ApolloClient, ApolloLink, HttpLink, InMemoryCache
} from "@apollo/client/core"
import gql from 'graphql-tag';
global.WebSocket = require('ws');
@skorfmann
skorfmann / custom-data-source.ts
Last active July 8, 2021 13:54
A custom data source for cdktf without generics
import { Construct, Node, } from "constructs";
import { Resource, TerraformResource, TerraformAsset, AssetType } from 'cdktf';
import * as fs from "fs";
import * as path from 'path'
import { DataExternal } from "@cdktf/provider-external"
export interface CustomDataSourceConfig {
code(input: any): Promise<any>
inputs: any;
dependsOn?: TerraformResource[];
@skorfmann
skorfmann / README.md
Last active May 3, 2021 08:59
An example for a custom provider leveraging https://github.com/lukekaalim/terraform-plugin-node-SDK/ This
@skorfmann
skorfmann / custom-data-source.ts
Last active February 3, 2021 11:05
This uses the external Terraform provider (https://registry.terraform.io/providers/hashicorp/external) to build ad hoc data sources for cdktf.
import { Construct, } from "constructs";
import { Resource, TerraformResource } from 'cdktf';
import * as fs from "fs";
import * as path from 'path'
import { DataExternal } from "../.gen/providers/external"
export interface CustomDataSourceConfig<Inputs, Outputs> {
code(input: Inputs): Promise<Outputs>
inputs: Inputs;
dependsOn?: TerraformResource[];