Skip to content

Instantly share code, notes, and snippets.

Avatar
🐙
Being Inkcellent to Each Other

Ken Collins metaskills

🐙
Being Inkcellent to Each Other
View GitHub Profile
@metaskills
metaskills / deploy.yml
Created Mar 20, 2021
Private GitHub ECR Action Abstract
View deploy.yml
- 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 Mar 9, 2021
Modernizing Rails with Serverless Containers - RailsConf 2021 Proposal
View proposal.md

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 Jan 15, 2021
Lambdakiq Lamby Template
View template.yml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: LambdakiqRail
Parameters:
RailsEnv:
Type: String
Default: staging
AllowedValues:
View omniauth.rb
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
View pconcurrency.sh
# Setup
aws application-autoscaling \
register-scalable-target \
--service-namespace "lambda" \
--resource-id "function:myapp:live" \
--min-capacity 5 \
--max-capacity 100 \
--scalable-dimension "lambda:function:ProvisionedConcurrency"
@metaskills
metaskills / capysetup.rb
Created Sep 28, 2020
Rails Capybara System Tests Setup
View capysetup.rb
# Gemfile
gem 'selenium-webdriver'
# test/application_system_test_case.rb (or capy setup file)
require 'test_helper'
Capybara.server = :webrick
Webdrivers::Chromedriver.required_version = '2.36'
driver_path = Webdrivers::Chromedriver.update
@metaskills
metaskills / layer_downloader.rb
Created Jul 25, 2020
Useful for Ruby/Docker SAM Projects
View layer_downloader.rb
require 'yaml'
require 'open-uri'
require 'aws-sdk-lambda'
class LayerDownloader
def download
File.open(zip_file, 'wb') do |f|
URI.open(location) { |zip| f.write(zip.read) }
end
@metaskills
metaskills / event.json
Created Jun 16, 2020
Sample API Gateway HTTP API Version 1 Event
View event.json
{
"version": "1.0",
"resource": "$default",
"path": "/",
"httpMethod": "GET",
"headers": {
"Content-Length": "0",
"Host": "myawesomelambda.example.com",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15",
"X-Amzn-Trace-Id": "Root=1-5e7fe714-fee6909429159440eb352c40",
@metaskills
metaskills / wizard.sh
Last active May 10, 2020
Learning to Program The Cloud
View wizard.sh
insert_file_over_pattern () {
dline=$(sed -n "/${2}/=" $1)
rline=$(expr $dline - 1)
sed --in-place -e "${dline}d" $1
sed --in-place "${rline}r ../inserts/${1}" $1
}
insert_file_over_pattern 'config/application.rb' 'Bundler.require'
@metaskills
metaskills / jest-environment-samlocal.js
Created Apr 25, 2020
Using Jest SAM Local Environment
View jest-environment-samlocal.js
const { spawn } = require('child_process');
const NodeEnvironment = require('jest-environment-node');
const { timeout, TimeoutError } = require('promise-timeout');
class SamlocalEnvironment extends NodeEnvironment {
constructor(config) {
super(config);
}
async setup() {