Skip to content

Instantly share code, notes, and snippets.

View xschildw's full-sized avatar

Xavier Schildwachter xschildw

  • Sage Bionetworks
  • Seattle, WA
View GitHub Profile
@xschildw
xschildw / code.js
Created April 22, 2021 16:25
synapsestatus
var isError;
exports.handler = function (event, context, callback) {
isError = false;
console.log('Running index.handler');
console.log('==================================');
console.log('event', event);
console.log('==================================');
testRepo(callback);
};
@xschildw
xschildw / code.py
Created April 22, 2021 16:16
stagingSynapseDocsRedirector
import re
# Returns a tuple (subdomain, path) to match in handler
def process_uri(uri):
pattern_all = re.compile('/(python|rest|r)/?(.*)')
m = pattern_all.match(uri)
if (m != None):
return m.group(1, 2)
else:
@xschildw
xschildw / code.py
Created April 22, 2021 16:04
cloudsearchindexcheck
import logging
import boto3
def requires_indexing(client, domain_name):
req_indexing = False
response = client.describe_domains(DomainNames=[domain_name])
if (response != None and response['DomainStatusList'] != None):
domain_status_list = response['DomainStatusList']
if (len(domain_status_list) == 1):
domain_status = domain_status_list[0]
@xschildw
xschildw / code.js
Created April 22, 2021 15:59
testCloudfrontLambdaAtEdge
'use strict';
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
const cacheControlHeader = 'Cache-Control';
const expiresHeader = 'Expires';
const pragmaHeader = 'Pragma';
const noCachePragmaValue = 'no-cache';
const noCacheValue = 'no-cache, max-age=0, must-revalidate, pre-check=0, post-check=0';
# From https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-s3.html#scenario-s3-bucket-website-customdomain
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Provision a S3 static website (HTTPS) with cloudfront for a SageBionetworks Portal
#Transform: S3Objects
Parameters:
DomainName:
Description: Domain name for your website (example.org)
Type: String
AllowedPattern: (?!-)[a-zA-Z0-9-.]{1,63}(?<!-)
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Provision EC2 instance running Qualys scanner + associated role for auditor
Parameters:
AuditorAccountId:
Description: AccountId of auditor
Type: String
AuditorStsExternalId:
Description: ExternalId of auditor
Type: String
AWSTemplateFormatVersion: 2010-09-09
Description: Basics for Beanstalk Datawarehouse
Parameters:
DwEbAppName:
Description: Elastic Beanstalk Datawarehouse Application Name
Type: String
Default: 'beanstalk-dw'
DwAppDeployBucket:
Description: Bucket where beanstalk deploys apps from
Type: String
@xschildw
xschildw / restore-rds-db.yaml
Created March 14, 2019 22:14
restore-rds-db
Description: AWS CloudFormation template to create an RDS instance for the warehouse workers build
Parameters:
DBAllocatedStorage:
Default: '5'
Description: The size of the database (Gb)
Type: Number
DBClass:
Default: db.t2.large
Description: Database instance class
Type: String
@xschildw
xschildw / DockerFile
Last active January 9, 2019 17:31
docker-jenkins-portal-deploy
FROM jenkins/jenkins:lts
LABEL maintainer="[email protected]"
USER root
# Basic deps
RUN apt update && apt install -y apt-transport-https curl software-properties-common python3-pip groff
# To install latest versions
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
@xschildw
xschildw / gist:239f7f1f1b1b5d2889c5268f765c03d5
Created October 31, 2018 18:47
Cloudformation script to deploy database
Description: AWS CloudFormation template to create an RDS instance for the warehouse workers build
Parameters:
DBAllocatedStorage:
Default: '5'
Description: The size of the database (Gb)
Type: Number
DBClass:
Default: db.t2.micro
Description: Database instance class
Type: String