Skip to content

Instantly share code, notes, and snippets.

@shortjared
shortjared / index.ts
Created July 31, 2020 20:32
CDK State Machine
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 July 31, 2020 20:26
CloudFormation StateMachine
{
"DeliveryStepFunctionStateMachine": {
"Type": "AWS::StepFunctions::StateMachine",
"Properties": {
"RoleArn": {
"Fn::GetAtt": ["DeliveryStepFunctionStateMachineRoleC6479370", "Arn"]
},
"DefinitionString": {
"Fn::Join": [
"",
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 January 29, 2019 21:29
Configs with serverless-api-gateway-caching plugin
service: aws-nodejs
custom:
apiGatewayCaching:
enabled: true
provider:
name: aws
runtime: nodejs8.10
@shortjared
shortjared / handler.js
Created January 29, 2019 20:29
Function Throttle Alarms Serverless.yml Example
'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 October 2, 2024 19:57
List of AWS Service Principals
a4b.amazonaws.com
access-analyzer.amazonaws.com
account.amazonaws.com
acm-pca.amazonaws.com
acm.amazonaws.com
airflow-env.amazonaws.com
airflow.amazonaws.com
alexa-appkit.amazon.com
alexa-connectedhome.amazon.com
amazonmq.amazonaws.com
@shortjared
shortjared / README.md
Last active October 23, 2023 06:13
If you have ever wanted to grab a marketplace AMI (ex: OpenVPN) you'll know that the process is painful. This solves the pain.

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 June 19, 2023 18:29
AWS API Gateway Nginx Reverse Proxy
# 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'`
#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
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.