Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View metaskills's full-sized avatar
🐙
Being Inkcellent to Each Other

Ken Collins metaskills

🐙
Being Inkcellent to Each Other
View GitHub Profile

Learning more about Lambda Amazon Linux images:

$ cat /etc/os-release | grep LIKE
ID_LIKE="centos rhel fedora"
$ rpm -E %{rhel}
7
$ cat /proc/version
Linux version 5.4.0-1074-azure (buildd@lcy02-amd64-065) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #77~18.04.1-Ubuntu SMP Wed Mar 30 15:36:02 UTC 2022
@metaskills
metaskills / rollbar.rb
Last active October 1, 2021 11:41
Safe Async Rollbar on AWS Lambda with Rails https://github.com/customink/lambda_punch
require 'rollbar/rails'
Rollbar.configure do |config|
config.use_async = true
config.async_handler = proc do |payload|
LambdaPunch.push { Rollbar.process_from_async_handler(payload) }
end
end
@metaskills
metaskills / project-Dockerfile
Created September 16, 2021 12:16
Custom Ink Common Strap Codespaces Examples
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:14
VOLUME [ "/var/lib/docker" ]
@metaskills
metaskills / strap-codespaces-docker.sh
Created September 16, 2021 12:06
Part of Custom Ink's `strap-codespaces` repo. Install Docker.
#!/bin/sh
set -e
if ! [ -x "$(command -v docker)" ]; then
echo "== [Custom Ink Strap Codespaces] installing 'docker' and 'docker-compose'... =="
URL="https://raw.githubusercontent.com/microsoft/vscode-dev-containers/main/script-library/docker-in-docker-debian.sh"
curl -s $URL | sudo bash /dev/stdin 1> /dev/null
fi
const { S3, GetObjectCommand } = require("@aws-sdk/client-s3");
const S3C = new S3(S3Config.mms());
response = await S3C.send(new GetObjectCommand(params));
data = await this.streamToString(response.Body);
async streamToString(stream) {
return new Promise((resolve, reject) => {
const chunks = [];
stream.on("data", (chunk) => chunks.push(chunk));
@metaskills
metaskills / production.rb
Created May 31, 2021 14:09
Using Rack Deflater in Lambda with Rails
# In config/environments/production.rb
config.middleware.insert_after ActionDispatch::Static, Rack::Deflater, sync: false
@metaskills
metaskills / deploy.yml
Created March 20, 2021 17:27
Private GitHub ECR Action Abstract
- name: Checkout (private actions)
uses: daspn/private-actions-checkout@v2
with:
actions_list: '["myorg/create-ecr-repo@main"]'
ssh_private_key: ${{ secrets.MYORG_GITHUB_SSH_KEY }}
- name: ECR
uses: ./.github/actions/create-ecr-repo
with:
stage: ${{ github.event.inputs.stage }}
repo-name: myorg/myapp
@metaskills
metaskills / proposal.md
Created March 9, 2021 10:30
Modernizing Rails with Serverless Containers - RailsConf 2021 Proposal

Abstract

Rails was made for servers. From web servers to background jobs, orchestrating the complexity of Rails in our cloud's infrastructure is hard work. We can not Kubernetes our way out of it either. There is a better way...one that is not well understood. With AWS Lambda and event-driven methodologies, we can fundamentally reinvent our beloved framework. It can change, and indeed thrive, without servers.

For Review Committee

Details

AWS Lambda is a commoditized compute platform of the future. Deeply integrated within AWS, it allows your Rails architecture to be completely reimagined atop fully managed infrastructure resources like API Gateway, SQS, S3, CloudWatch, VPC NAT Gateways, IAM, and so much more. As we explore Rails on Lambda, a pattern of evaporating concerns will become a common theme.

@metaskills
metaskills / template.yml
Last active January 15, 2021 19:47
Lambdakiq Lamby Template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: LambdakiqRail
Parameters:
RailsEnv:
Type: String
Default: staging
AllowedValues:
@metaskills
metaskills / omniauth.rb
Created November 20, 2020 22:23
AWS SSO Omniauth
metadata = Rails.root.join 'config', 'myapp_ins-8d2c1e14da9ca2bc.xml'
idpdata = File.read(metadata)
parser = OneLogin::RubySaml::IdpMetadataParser.new
SAML_SETTINGS = parser.parse_to_hash(idpdata)
Rails.application.config.middleware.use OmniAuth::Builder do
provider :saml, SAML_SETTINGS.merge(
issuer: 'myapp'
)
end