Skip to content

Instantly share code, notes, and snippets.

@allenheltondev
allenheltondev / chat.html
Created May 17, 2023 16:53
Momento Chat Client
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Instant Messaging | Momento</title>
<style>
body {
font-family: Inter, sans-serif;
@allenheltondev
allenheltondev / replaceImages.js
Created January 24, 2023 14:25
Update locally referenced images in your blog posts with cloud references in S3
// This script will scan all files in a given directory for locally referenced images. It will take the images, rename them with a standard convention, then upload them to s3 with a 'public-read' ACL. The script will then update the reference to the local image with the link to the version in the cloud.
// If there are any issues during operation, the script will output either a 'skipped-posts.json' file that lists the posts that were not processed or a 'failed-image-uploads.json' file that lists images that failed to upload into S3.
// Arguments for operation
//
// [0] blogPostDirectory - relative path from the root where all blog posts live
// [1] imageDirectory - relative path from the root where all images live
// [2] bucketName - name of the S3 bucket to upload the local images to
// [3] awsProfileName - name of the aws profile on your machine that has access to the S3 bucket
@allenheltondev
allenheltondev / index.js
Last active November 12, 2022 22:30
Generic PATCH Lambda Function With Ops
const { marshall } = require('@aws-sdk/util-dynamodb');
const { DynamoDBClient, UpdateItemCommand } = require('@aws-sdk/client-dynamodb');
const ddb = new DynamoDBClient();
exports.handler = async (event) => {
try {
// Example input
// [
// { "op": "add", "path": "/comment", "value": "This is a nasty gopher" },
@allenheltondev
allenheltondev / openapi.yaml
Created October 5, 2022 12:25
Integrating API Gateway to Amazon Translate
openapi: 3.0.0
info:
title: AWS Service Integration API
version: 1.0.0
paths:
/translations:
post:
requestBody:
required: true
@allenheltondev
allenheltondev / services.json
Created October 4, 2022 16:50
API Gateway Direct Integrations
[
"Amazon MQ",
"AppStream 2.0",
"AppSync",
"AppSync Data Plane",
"Athena",
"Auto Scaling",
"AWS Certificate Manager (ACM)",
"Batch",
"Cloud Directory",
@allenheltondev
allenheltondev / index.js
Created September 21, 2022 12:44
Parameterize Step Function Workflow Definition
const fs = require('fs');
const YAML = require('json-to-pretty-yaml');
const definition = JSON.parse(fs.readFileSync('definition.asl.json'));
const substitutions = [];
parameterizeStates(definition.States, substitutions);
console.log(substitutions)
@allenheltondev
allenheltondev / template.yaml
Created February 25, 2022 13:07
Adding a Global Layer To Your SAM Template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Runtime: nodejs14.x
Architectures:
- arm64
Tracing: Active
Timeout: 3
Handler: index.handler
@allenheltondev
allenheltondev / README.md
Last active March 24, 2021 11:53
Example README with Infrastructure Diagram

My Example Microservice

Description

This is an example README for Gopher Holes Unlimited - a fake business but real API that tracks two things:

  1. Gophers
  2. Holes

Infrastructure

Infrastructure Diagram

@allenheltondev
allenheltondev / ExampleCidrConfiguration.yaml
Created March 2, 2021 12:57
Example IP ranges you can use for configuring a Lambda function with a static IP
Parameters:
VpcCidrBlock:
Type: String
Default: "12.0.0.0/16"
PublicSubnetCidrBlock:
Type: String
Default: "12.0.0.0/24"
PrivateSubnetCidrBlock:
Type: String
Default: "12.0.1.0/24"
@allenheltondev
allenheltondev / consumeMacroCfn.yaml
Last active January 25, 2021 13:50
CloudFormation Macro Example
AWSTemplateFormatVersion: '2010-09-09'
Transform: [AWS::Serverless-2016-10-31, AddSSMParametersMacro]
Description: SAM template for consuming a CloudFormation Macro
Resources:
ExampleWithEnvVarFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: example-with-env-var
Handler: function.handler