Skip to content

Instantly share code, notes, and snippets.

View dave-malone's full-sized avatar

Dave Malone dave-malone

  • Amazon Web Services
  • Tampa, FL
View GitHub Profile
@dave-malone
dave-malone / bandwidth-speed-test-cloudwatch.js
Created August 21, 2018 15:15
A simple node program that uses the fast-speedtest-api npm package to test internet bandwidth and publishes it to CloudWatch
const FastSpeedtest = require("fast-speedtest-api")
const AWS = require('aws-sdk')
AWS.config.update({region: 'us-east-1'})
const cloudwatch = new AWS.CloudWatch()
let speedtest = new FastSpeedtest({
token: "INSERT-YOUR-TOKEN-HERE",
verbose: false,
timeout: 10000,
https: true,
@dave-malone
dave-malone / aws-iot-update-thing-shadow-lambda-function.js
Last active May 25, 2022 05:57
AWS Lambda function example of how to update IoT Thing Shadows
const AWS = require('aws-sdk')
AWS.config.region = process.env.AWS_REGION
const AWS_IOT_CORE_ENDPOINT = process.env.MQTT_BROKER_ENDPOINT
const IOT_THING_NAME = process.env.THING_NAME
const iotdata = new AWS.IotData({
endpoint: AWS_IOT_CORE_ENDPOINT,
})
@dave-malone
dave-malone / aws-lambda-kvm-gethlsstreamingurl.js
Last active August 27, 2018 15:31
AWS Lambda Function intended to be used by authorized callers to view a Kinesis Video Stream's HLS session URL.
const AWS = require('aws-sdk')
AWS.config.region = process.env.AWS_REGION
const kinesisvideo = new AWS.KinesisVideo({
accessKeyId: process.env.ACCESS_KEY_ID,
secretAccessKey: process.env.SECRET_ACCESS_KEY
})
function getStreamingSessionURL(){
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Resource": [
"arn:aws:iam::*:role/AWSCloudFormationStackSetExecutionRole"
],
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::{account-id}:role/LandingZoneLambdaRoleADConnector",
"arn:aws:iam::{account-id}:role/AWSCloudFormationStackSetAdministrationRole",
"arn:aws:iam::{account-id}:role/StateMachineLambdaRoleADConnector",
@dave-malone
dave-malone / aws-landing-zone-default-okta-roles.template
Created September 21, 2018 16:12
templates/aws_baseline/aws-landing-zone-default-okta-roles.template
AWSTemplateFormatVersion: 2010-09-09
Description: Create Okta IDP and default roles on all accounts.
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: "Okta SAML IDP"
Parameters:
@dave-malone
dave-malone / aws-landing-zone-default-okta-roles.json
Created September 21, 2018 16:13
parameters/aws_baseline/aws-landing-zone-default-okta-roles.json
[
{
"ParameterKey": "EnableAdminRole",
"ParameterValue": "true"
},
{
"ParameterKey": "EnablePowerUserRole",
"ParameterValue": "true"
},
{
- name: DefaultOktaRoles
baseline_products:
- AWS-Landing-Zone-Account-Vending-Machine
template_file: templates/aws_baseline/aws-landing-zone-default-okta-roles.template
parameter_file: parameters/aws_baseline/aws-landing-zone-default-okta-roles.json
deploy_method: stack_set
@dave-malone
dave-malone / add-swap.md
Last active October 16, 2018 12:14
Add more swap space to Raspberry Pi
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo chmod 600 /var/swap.1
sudo /sbin/swapon /var/swap.1

Remove swap space once done

@dave-malone
dave-malone / avro_to_aws_iot.py
Last active November 9, 2018 17:37
A simple Python program to demonstrate submitting an Avro encoded file as a binary payload into AWS IoT Core
from avro.datafile import DataFileWriter
from avro.io import DatumWriter
from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient
import avro.schema
import logging
import time
import os
avro_users_schema_file = "user.avsc"
avro_users_file = "users.avro"