Skip to content

Instantly share code, notes, and snippets.

@shortjared
shortjared / index.ts
Created Jul 31, 2020
CDK State Machine
View index.ts
const STATUS = "$.status"
const RETRY_SECONDS = "$.retrySeconds"
const PENDING = "pending"
const PROGRESS = "in-progress"
const FAILED = "failed"
const COMPLETE = "complete"
const setPending = stepFunction.setStatus(this, props.table, PENDING);
const setProgress = stepFunction.setStatus(this, props.table, PROGRESS);
const setSuccess = stepFunction.setStatus(this, props.table, COMPLETE);
@shortjared
shortjared / cfn.json
Created Jul 31, 2020
CloudFormation StateMachine
View cfn.json
{
"DeliveryStepFunctionStateMachine": {
"Type": "AWS::StepFunctions::StateMachine",
"Properties": {
"RoleArn": {
"Fn::GetAtt": ["DeliveryStepFunctionStateMachineRoleC6479370", "Arn"]
},
"DefinitionString": {
"Fn::Join": [
"",
View tweet-1287839614057754625.ts
const definition = this.mapperTask()
.next(setPending)
.next(waitForNSeconds)
.next(setInProgress)
.next(this.deliverTransactionTask())
.next(
new Choice(this, 'Delivery success?)
.when(Condition.stringEquals(STATUS, COMPLETE), setComplete)
.when(Condition.stringEquals(STATUS, FAILED), setFailed)
.otherwise(setPending)
@shortjared
shortjared / serverless.yml
Created Jan 29, 2019
Configs with serverless-api-gateway-caching plugin
View serverless.yml
service: aws-nodejs
custom:
apiGatewayCaching:
enabled: true
provider:
name: aws
runtime: nodejs8.10
@shortjared
shortjared / handler.js
Created Jan 29, 2019
Function Throttle Alarms Serverless.yml Example
View handler.js
'use strict';
function sleep(ms){
return new Promise(resolve => setTimeout(resolve, ms));
}
module.exports.hello = async (event, context) => {
await sleep(5000); // hit api endpoint twice in 5 seconds, get a 429!
return {
statusCode: 200,
body: JSON.stringify({
@shortjared
shortjared / list.txt
Last active Sep 28, 2021
List of AWS Service Principals
View list.txt
a4b.amazonaws.com
acm-pca.amazonaws.com
acm.amazonaws.com
alexa-appkit.amazon.com
alexa-connectedhome.amazon.com
amazonmq.amazonaws.com
apigateway.amazonaws.com
appflow.amazonaws.com
application-autoscaling.amazonaws.com
appstream.application-autoscaling.amazonaws.com
@shortjared
shortjared / README.md
Last active Oct 8, 2019
If you have ever wanted to grab a marketplace AMI (ex: OpenVPN) you'll know that the process is painful. This solves the pain.
View README.md

Usage

  • You will need to first make sure you have subscribed to the marketplace product
  • Get the AMI of the marketplace
  • Copy the script to machine
  • awsume (or otherwise authorize) to AWS
  • chmod the script to be executable if needed chmod +x marketplace-ami-encryptor.sh

Usage ./marketplace-ami-encryptor.sh {region} {ami} {name}
Example: ./marketplace-ami-encryptor.sh us-east-1 ami-f6eed4e0 OpenVPN

@shortjared
shortjared / nginx.conf
Last active Feb 2, 2021
AWS API Gateway Nginx Reverse Proxy
View nginx.conf
# NOTE
#
#
# Use sed on the instance up to replace the INSTANCE_ID and DNS_RESOLVER with the following commands
#
####################################################################################################
# Fetch the private IP for resolving DNS dynamically in nginx
# We also need to escape the `.` from it for usage in later sed
#
# DNS_RESOLVER=`grep nameserver /etc/resolv.conf | cut -d " " -f2 | sed 's/\./\\./g'`
View slack-theme.css
#msgs_scroller_div::-webkit-scrollbar-track, #client_body::before, .client_container,
#search_terms, #client_body, #footer, ts-message, .channel_header, ts-jumper ts-jumper-container,
ts-jumper input[type="text"] {
background: #282c34 !important;
}
#message_edit_form .ql-editor, #message_edit_form .ql-placeholder, #msg_form .ql-editor, #msg_form .ql-placeholder {
color: #fff
}
View test-animation.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.