Skip to content

Instantly share code, notes, and snippets.

@lstroud
lstroud / AWS IAM Policy - ForceMFA.json
Created April 30, 2018 23:06 — forked from incyclum/AWS IAM Policy - ForceMFA.json
AWS IAM Policy - Force MFA - This policy allows users to manage their own passwords and MFA devices but nothing else unless they authenticate with MFA
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllUsersToListAccounts",
"Effect": "Allow",
"Action": [
"iam:ListAccountAliases",
"iam:ListUsers",
"iam:GetAccountPasswordPolicy",
@lstroud
lstroud / comprehensive_header.py
Created March 27, 2018 15:58 — forked from NicolasBizzozzero/comprehensive_header.py
Python template of a comprehensive header, with shebang, docstring, GPLv3 license and all metadata.
#!/usr/bin/env python
""" Short description of this Python module.
Longer description of this module.
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
@lstroud
lstroud / README.md
Created March 16, 2018 21:10 — forked from sapessi/README.md
Continuous deployment of React websites to Amazon S3

Continuous deployment of React websites to Amazon S3

This sample includes a continuous deployment pipiline for websites built with React. We use AWS CodePipeline, CodeBuild, and SAM to deploy the application. To deploy the application to S3 using SAM we use a custom CloudFormation resource.

Files included

  • buildspec.yml: YAML configuration for CodeBuild, this file should be in the root of your code repository
  • configure.js: Script executed in the build step to generate a config.json file for the application, this is used to include values exported by other CloudFormation stacks (separate services of the same application).
  • index.js: Custom CloudFormation resource that publishes the website to an S3 bucket. As you can see from the buildspec and SAM template, this function is located in a s3-deployment-custom-resource sub-folder of the repo
  • app-sam.yaml: Serverless Application model YAML file. This configures the S3 bucket and the cu
#!/usr/bin/python
#
# List Active Okta Users
#
import requests
import json
token = 'WHATEVER_YOUR_TOKEN_IS'
limit = '200'
#!/usr/bin/python
#
# List Active Okta Users
#
import requests
import json
import pprint
import csv
@lstroud
lstroud / change_lambda_logger_format.py
Created July 11, 2017 13:48 — forked from niranjv/change_lambda_logger_format.py
Change Python logger format in AWS Lambda
# Python logger in AWS Lambda has a preset format. To change the format of the logging statement, remove the logging handler
# and add a new handler with the required format
logger = logging.getLogger()
for h in logger.handlers:
logger.removeHandler(h)
h = logging.StreamHandler(sys.stdout)
# use whatever format you want here
@lstroud
lstroud / install_python_36_amazon_linux.sh
Created July 11, 2017 13:48 — forked from niranjv/install_python_36_amazon_linux.sh
Install Python 3.6 in Amazon Linux
# A virtualenv running Python3.6 on Amazon Linux/EC2 (approximately) simulates the Python 3.6 Docker container used by Lambda
# and can be used for developing/testing Python 3.6 Lambda functions
# This script installs Python 3.6 on an EC2 instance running Amazon Linux and creates a virtualenv running this version of Python
# This is required because Amazon Linux does not come with Python 3.6 pre-installed
# and several packages available in Amazon Linux are not available in the Lambda Python 3.6 runtime
# The script has been tested successfully on a t2.micro EC2 instance (Root device type: ebs; Virtualization type: hvm)
# running Amazon Linux AMI 2017.03.0 (HVM), SSD Volume Type - ami-c58c1dd3
# and was developed with the help of AWS Support
@lstroud
lstroud / setup_lambda_for_oracle_rds.sh
Created July 11, 2017 13:48 — forked from niranjv/setup_lambda_for_oracle_rds.sh
Setup virtualenv to access Oracle RDS from AWS Lambda
# This script allows Python functions in AWS Lambda to query an Oracle RDS instance
# It is meant to run on an EC2 instance running Amazon Linux
# The script has been tested successfully on a t2.micro EC2 instance (Root device type: ebs; Virtualization type: hvm)
# running Amazon Linux AMI 2017.03.0 (HVM), SSD Volume Type - ami-c58c1dd3
# and was developed with the help of AWS Support
# Steps:
# - install Oracle Instant Client
# - create virtualenv
@lstroud
lstroud / deploy_lambda_oracle_rds.sh
Created July 11, 2017 13:48 — forked from niranjv/deploy_lambda_oracle_rds.sh
Create Python Lambda package to connect to Oracle RDS
# Create and upload a deployment package for a Python Lambda function
# Assumes EC2 instance is associated with an IAM role with permissions to access S3 & Lambda
# Ref: http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html
# This script is meant to be used after virtualenv has been setup to connect to Oracle RDS
# see https://gist.github.com/niranjv/2a576a13afe1b323e9e9600ed7de03ef
# Steps:
# - create temp dir
@lstroud
lstroud / fetch_wwdc_pdfs.js
Created June 5, 2014 12:17
Download 2014 WWDC Slides (PDFs)
var request = require('request');
var cheerio = require('cheerio');
var fs = require('fs');
var auth = {
'user': 'appleid',
'pass': 'mypassword',
'sendImmediately': false
};