Skip to content

Instantly share code, notes, and snippets.

View allenmichael's full-sized avatar

Allen-Michael Grobelny allenmichael

  • Amazon Web Services
  • Austin, TX
  • X @amsxbg
View GitHub Profile
@allenmichael
allenmichael / template.yaml
Created February 18, 2019 23:14
Local Library Lambda Layer Template
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: Local Library Lambda Layer
Resources:
PetuniaDep:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: petunia-lib
Description: A bundled local library
module.exports.handler = async (event) => {
console.log(JSON.stringify(event, 2));
return {
statusCode: 200,
body: "Echoing your message: " + event.echo
}
};
module.exports.handler = async (event) => {
console.log(JSON.stringify(event, 2));
return "Echoing your message: " + event.echo;
};
{
"data": "1,2018-03-01 00:01:34,2018-03-01 00:01:43,1,.00,1,N,145,145,2,2.5,0.5,0.5,0,0,0.3,3.8"
}
Import-Module AWSPowerShell.NetCore
$fileOrHost = Read-Host "Read from terminal[1] or file[2] (1 or 2)?"
if ("1", "2" -notcontains $fileOrHost ) {
$fileOrHost = "1"
}
$text = ""
if ($fileOrHost -eq "1") {
$text = Read-Host "Enter text to be redacted."
$results = Get-Content -Path './transcribe/results.json' | ConvertFrom-Json
$items = $results.results.items
# only works on macOS
Start-Process afplay -ArgumentList @('./transcribe/cropped_podcast.mp3') -NoNewWindow
$counter = 1
foreach ($item in $items) {
if ($item.end_time -lt $counter) {
if ($item.alternatives[0].content -eq '.') {
write-host -NoNewline $item.alternatives[0].content
const AWS = require('aws-sdk');
module.exports.handler = async (event) => {
console.log(JSON.stringify(event, 2));
const { send, connectionId } = getSocketContext(event);
await send(
JSON.stringify(
{

Streaming API Gateway input to Kinesis Firehose to S3

This CloudFormation template creates an API Gateway that will pass all JSON data sent as a PUT request to Kinesis Firehose which in turn deposits the data into S3.

Retrieve the API Gateway URL after CloudFormation deployment

aws cloudformation describe-stacks --stack-name <STACK_NAME> --query Stacks[].Outputs[].[OutputKey,OutputValue]

Test the endpoint

curl -X PUT -H 'Content-Type: application/json' -d '{"event":"sent"}' https://xd8tc7fim2.execute-api.us-east-1.amazonaws.com/prod

@allenmichael
allenmichael / WorkflowExecuteHandler.java
Last active September 5, 2019 20:46
A template for setting up a SparkFlows File Watcher using S3, Secrets Manager, SQS, and Lambda
package com.sf.handler;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
import com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
import com.amazonaws.services.secretsmanager.*;
import com.amazonaws.services.secretsmanager.model.*;
public class WorkflowExecuteHandler implements RequestHandler<SQSEvent, Void>{
@allenmichael
allenmichael / eks-basic.yaml
Last active October 9, 2019 18:36
Gremlin GameDay Starter
AWSTemplateFormatVersion: "2010-09-09"
Description: >-
This template creates a Multi-AZ, multi-subnet VPC infrastructure with managed NAT
gateways in the public subnet for each Availability Zone. You can also create additional
private subnets with dedicated custom network access control lists (ACLs). If you
deploy the Quick Start in a region that doesn't support NAT gateways, NAT instances
are deployed instead. **WARNING** This template creates AWS resources. You will
be billed for the AWS resources used if you create a stack from this template. QS(0027)
Resources:
##### START VPC RESOURCES #####