Skip to content

Instantly share code, notes, and snippets.

View lukehoban's full-sized avatar

Luke Hoban lukehoban

View GitHub Profile
@lukehoban
lukehoban / index.ts
Last active February 24, 2023 15:31
Simple Aurora Serverless + Lambda VPC example with Pulumi
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import * as random from "@pulumi/random";
// Construct a VPC
const vpc = new awsx.ec2.Vpc("vpc");
// Create an Aurora Serverless MySQL database
const dbsubnet = new aws.rds.SubnetGroup("dbsubnet", {
@lukehoban
lukehoban / index.ts
Created June 20, 2019 00:25
Passing credentials to a Pulumi dynamic provider
import * as splunk from "./splunk"
async function getSecretValue(): Promise<string> {
return "abcd"
}
getSecretValue().then(secret => {
splunk.setAuth(secret);
new splunk.SavedSearch("foo", {});
});
@lukehoban
lukehoban / waitForJob.ts
Last active May 17, 2024 16:23
Pulumi program which waits on Jobs during a Kubernetes deployment
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
import * as k8sOutput from "@pulumi/kubernetes/types/output";
import * as k8sapi from 'kubernetes-client';
const job = new k8s.batch.v1.Job("job", {
spec: {
template: {
spec: {
containers: [{
@lukehoban
lukehoban / lambda_test.go
Created February 25, 2020 06:19
Untyped Lambda Calculus, Chruch Numerals, Y Combinator in Golang
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
type V func(v V) V
@lukehoban
lukehoban / __main__.py
Last active May 19, 2023 05:31
Pulumi without variables
import pulumi
import pulumi_aws as aws
from typing import Optional, Dict, Tuple
import asyncio
all_resources: Dict[Tuple[str, str], pulumi.Resource] = {}
def transform(args: pulumi.ResourceTransformationArgs) -> Optional[pulumi.ResourceTransformationResult]:
all_resources[(args.name, args.type_)] = args.resource
return None # do not actually modify the resource
@lukehoban
lukehoban / index.ts
Created May 19, 2023 06:42
Pulumi Self-Hosted Cloud - Simple Kubernetes Deployment
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
import * as command from "@pulumi/command";
class ServiceDeployment extends pulumi.ComponentResource {
internalEndpoint: pulumi.Output<string>;
externalEndpoint?: pulumi.Output<string>;
service: k8s.core.v1.Service;
constructor(name: string, args: { name: string, image: string, replicas?: number, env?: Record<string, pulumi.Input<string>>, ports?: { port: number }[], loadBalancer?: boolean, volumes?: { name: string, mountPath: string, secret: k8s.core.v1.Secret }[] }, opts?: pulumi.ComponentResourceOptions) {
super("selfhosted:ServiceDeployment", name, {}, opts);