Skip to content

Instantly share code, notes, and snippets.

View cnunciato's full-sized avatar

Christian Nunciato cnunciato

View GitHub Profile
@cnunciato
cnunciato / index.html
Created July 9, 2019 21:17
Pulumi Design: Colors
<div class="p-8 leading-relaxed bg-white flex items-start">
<div class="w-1/4">
<h1 class="text-xl text-gray-800 font-bold">Brand Base Colors</h1>
<ul class="flex flex-col">
<li class="bg-blue-500 text-blue-100 shadow-md whitespace-pre text-xs leading-relaxed text-xs h-32 w-32 p-2 mr-4 my-2"></li>
<li class="bg-orange-500 text-orange-100 shadow-md whitespace-pre text-xs leading-relaxed text-xs h-32 w-32 p-2 mr-4 my-2"></li>
<li class="bg-green-500 text-green-100 shadow-md whitespace-pre text-xs leading-relaxed text-xs h-32 w-32 p-2 mr-4 my-2"></li>
<li class="bg-purple-500 text-purple-100 shadow-md whitespace-pre text-xs leading-relaxed text-xs h-32 w-32 p-2 mr-4 my-2"></li>
</ul>
</div>
@cnunciato
cnunciato / gif.sh
Created April 22, 2020 00:22
gif.sh
gif() {
if [ ! "$(ffmpeg -version)" ]; then
echo "It looks like ffmpeg isn't installed. Try installing with Homebrew (e.g., brew install ffmpeg)."
return $?
fi
if [ -z $1 ]; then
echo "Usage: "
echo " gif /path/to/source.mov [width in pixels (640 default)] [frames per second (12 default)]"
return 0
var kids = ["Oliver", "Sam", "Rosemary"];
var rooms = ["Living room", "Dining room", "Library"];
rooms.sort(() => Math.random() > 0.5 ? 1 : -1).map((o, i) => ({ [kids[i]]: o }));
@cnunciato
cnunciato / mapbox-style-provider.ts
Created November 1, 2020 22:26
A Pulumi dynamic provider for Mapbox styles.
import * as pulumi from "@pulumi/pulumi";
const mbxClient = require('@mapbox/mapbox-sdk');
const mbxStyles = require('@mapbox/mapbox-sdk/services/styles');
const mbxTilesets = require('@mapbox/mapbox-sdk/services/tilesets');
const config = new pulumi.Config();
let accessToken = config.requireSecret("access_token");
export interface MapboxStyleResourceInputs {
@cnunciato
cnunciato / index.js
Created February 28, 2021 16:51
Get the outputs from a Pulumi stack with a Node.js program
const automation = require("@pulumi/pulumi/x/automation");
async function getStackOutputs(stackName, projectName) {
const stack = await automation.LocalWorkspace.selectStack({
stackName,
projectName,
program: () => {},
});
return await stack.outputs();
}
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
const cluster = new aws.ecs.Cluster("default-cluster");
const lb = new awsx.lb.ApplicationLoadBalancer("nginx-lb", {});
const service = new awsx.ecs.FargateService("my-service", {
cluster: cluster.arn,
desiredCount: 2,
@cnunciato
cnunciato / index.ts
Last active June 21, 2022 20:33
TypeScript Class encapsulating a StaticWebsite
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
/**
* The StaticWebsite class provisions a cloud storage bucket
* and a content-delivery network for it, exposing the name of
* the storage bucket and the CDN URL for later use.
*/
export class StaticWebsite {
private bucket: aws.s3.Bucket;
@cnunciato
cnunciato / index.ts
Last active June 21, 2022 20:33
TypeScript component encapsulating a StaticWebsite
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
interface StaticWebsiteArgs {
domainName: string;
defaultDocument?: string;
}
/**
import * as aws from "@pulumi/aws";
const lambda = new aws.lambda.CallbackFunction("my-function", {
callback: () => {
console.log("Hello, world!");
},
});
export const { id } = lambda;
@cnunciato
cnunciato / index.ts
Created August 26, 2022 22:26
Create an S3 website with Pulumi and CloudFlare DNS (with HTTPS)
import * as aws from "@pulumi/aws";
import * as cloudflare from "@pulumi/cloudflare";
const domain = "pulumibook.info";
const subdomain = "my-awesome-website";
// Make a bucket.
const bucket = new aws.s3.Bucket("my-bucket", {
bucket: `${subdomain}.${domain}`,
acl: aws.s3.CannedAcl.PublicRead,