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
---
apiVersion: v1
kind: Namespace
metadata:
name: sock-shop
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: carts-db
AWSTemplateFormatVersion: "2010-09-09"
Description: >-
EKS for us-east-1 with Kubernetes Object deployment support.
Resources:
##### START VPC RESOURCES #####
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
InstanceTenancy: default
  • Best place to get started
  • https://eksworkshop.com/
  • Talk Minikube
  • Talk Play with Kubernetes
  • https://labs.play-with-k8s.com/
  • EKS Service Role
  • Create EKS Cluster (with same user who will use kubectl)
  • Talk about IAM and K8s RBAC
  • What is kubectl?
  • Use AWS CLI to update kubeconfig
apiVersion: v1
kind: Namespace
metadata:
name: gremlin
@allenmichael
allenmichael / Program.cs
Created October 1, 2019 19:06
SQSConsumer
using System;
using System.Threading.Tasks;
using Amazon.SQS;
using Amazon.SQS.Model;
using Newtonsoft.Json;
using SQSConsumer.Models;
using Amazon.SimpleSystemsManagement;
using Amazon.SimpleSystemsManagement.Model;
using System.Collections.Generic;
using Amazon.DynamoDBv2.DataModel;
@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 #####
@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>{

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

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(
{
$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