Skip to content

Instantly share code, notes, and snippets.

View cnunciato's full-sized avatar

Christian Nunciato cnunciato

View GitHub Profile
@cnunciato
cnunciato / function.sh
Created June 15, 2024 15:21
Switch between Hugo versions
use_hugo() {
local VERSION="$1"
local TARFILE="hugo_${VERSION}_darwin-universal.tar.gz"
local TEMP_DIR="${HOME}/Downloads/hugo_temp"
local DESTFILE="${TEMP_DIR}/$TARFILE"
mkdir -p "$TEMP_DIR"
curl -L -o "$DESTFILE" "https://github.com/gohugoio/hugo/releases/download/v${VERSION}/${TARFILE}" && \
tar -xzvf "$DESTFILE" -C "$TEMP_DIR" && \
sudo mv "${TEMP_DIR}/hugo" "/usr/local/bin/" && \
@cnunciato
cnunciato / __main__.py
Last active June 4, 2024 15:49
Calling `pulumi.export` from within an `apply`
from some_module import make_bucket
# Call a function to make a bucket.
make_bucket()
#!/bin/bash
tokens=(
aws:lambda/function:Function
aws:s3/bucket:Bucket
aws:iam/role:Role
aws:ec2/instance:Instance
aws:rds/instance:Instance
aws:ec2/securityGroup:SecurityGroup
aws:ec2/vpc:Vpc
@cnunciato
cnunciato / helper.sh
Created January 4, 2024 23:08
pulumi new helper
pnew() {
local project_template="$1"
local project_home="${HOME}/Projects/dev/pulumi"
local project_name="${1}-$(head -n 4096 /dev/urandom | openssl sha1 | awk "{print \$2}" | cut -c1-7)"
local project_dir="${project_home}/${project_name}"
mkdir -p "$project_dir" && cd "$project_dir"
pulumi new "$project_template"
}
@cnunciato
cnunciato / Pulumi.yaml
Created October 28, 2023 15:32
A Pulumi program as a Gist
name: ${PROJECT}
description: ${DESCRIPTION}
runtime:
name: nodejs
options:
typescript: false
template:
description: A minimal AWS JavaScript Pulumi program
important: true
config:
@cnunciato
cnunciato / main.go
Last active January 12, 2023 19:59
Converting a pulumi.IDOutput to a string and using it in a lookup function
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
➜ depth .
.
├ fmt
├ github.com/pulumi/pulumi-azure-native-sdk/resources
├ context
├ fmt
├ os
├ reflect
├ regexp
├ strconv
@cnunciato
cnunciato / Pulumi.yaml
Last active December 9, 2022 01:38
Hello! I'm a publicly accessible Pulumi project template.
# Configure project names and descriptions with values obtained from `pulumi new`.
name: ${PROJECT}
description: ${DESCRIPTION}
runtime: yaml
# Define the template's configuration settings.
template:
description: A simple static website on Amazon S3
config:
aws:region:
@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,
import * as aws from "@pulumi/aws";
const lambda = new aws.lambda.CallbackFunction("my-function", {
callback: () => {
console.log("Hello, world!");
},
});
export const { id } = lambda;