Skip to content

Instantly share code, notes, and snippets.

View tomwwright's full-sized avatar
🎯
Focusing

Tom Wright tomwwright

🎯
Focusing
View GitHub Profile
@tomwwright
tomwwright / create-tags-change-set.sh
Created December 6, 2022 00:26
Script to create a change set against a stack and execute it if it is exclusively Tags in scope
#!/bin/bash
set -e
set -o pipefail
set -u
# depends on cfparams: https://github.com/cultureamp/cfparams
FARM=$1
CHANGE_SET_NAME="changeset-tags-$(date +%Y%m%d%H%M%S)-$(git rev-parse HEAD)"
@tomwwright
tomwwright / deepracer.py
Created December 20, 2018 05:10
Medium : AWS DeepRacer
THROTTLE_PENALTY_FACTOR = 0.5
STEERING_PENALTY_FACTOR = 0.5
def reward_function(on_track, x, y, distance_from_center, car_orientation, progress, steps, throttle, steering, track_width, waypoints, closest_waypoint):
'''
@on_track (boolean) :: The vehicle is off-track if the front of the vehicle is outside of the white
lines
@x (float range: [0, 1]) :: Fraction of where the car is along the x-axis. 1 indicates
max 'x' value in the coordinate system.
@tomwwright
tomwwright / iam-update-build-numbers.json
Created December 17, 2018 11:03
Medium : Build Numbers with AWS CodeBuild
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:GetParameter",
"ssm:GetParameters",
"ssm:PutParameter"
],
@tomwwright
tomwwright / update-build-numbers.js
Created December 17, 2018 10:59
Medium : Build Numbers with AWS CodeBuild
const AWS = require('aws-sdk');
const ssm = new AWS.SSM();
exports.handler = async (event) => {
const parameterName = '/build-number/' + event['detail']['project-name'];
const getBuildNumberParams = {
Name: parameterName
@tomwwright
tomwwright / iam-read-build-numbers.json
Last active December 17, 2018 10:31
Medium : Build Numbers with AWS CodeBuild
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:GetParameter",
"ssm:GetParameters"
],
"Resource": "arn:aws:ssm:{region}:{account-id}:parameter/build-number/*"
# describing a non-existent Aurora cluster results in an error
$ aws rds describe-db-clusters --db-cluster-identifier doesnotexist
An error occurred (DBClusterNotFoundFault) when calling the DescribeDBClusters operation: DBCluster doesnotexist not found.
# but using --filter to describe a non-existent Aurora cluster is ok
$ aws rds describe-db-clusters --filters Name=db-cluster-id,Values=doesnotexist
{
"DBClusters": []
}
- hosts: localhost
vars:
aurora_cluster_name: mycoolauroracluster
aurora_cluster_engine: aurora-mysql
aurora_cluster_version: 5.7.12
aws_region: ap-southeast-2
tasks:
- name: look for an existing Aurora cluster using the AWS CLI
command: >
- hosts: localhost
vars:
aurora_cluster_name: mycoolauroracluster
aurora_cluster_engine: aurora-mysql
aurora_cluster_version: 5.7.12
aws_region: ap-southeast-2
tasks:
- name: create Aurora Cluster with the AWS CLI
command: >
- hosts: localhost
tasks:
- name: create an S3 bucket -- we'll see this one is 'changed'
s3_bucket:
name: mysupercoolexamplebucket
region: ap-southeast-2
state: present
@tomwwright
tomwwright / ansibled:logentries:docker-compose-env-example.yml
Last active July 30, 2018 07:08
ansibled : logentries : docker compose env example
- name: add each Logentries token to Docker Compose .env settings
lineinfile:
dest: "{{ docker_compose_directory }}/.env"
regexp: "^LOGENTRIES_{{ item.key | upper }}=.*"
line: "LOGENTRIES_{{ item.key | upper }}={{ item.value }}"
create: yes
with_dict : "{{ logentries_log_tokens }}"