Skip to content

Instantly share code, notes, and snippets.

@toddlers
toddlers / index.js
Created February 2, 2021 13:14
nodejs http post
//https://blog.bearer.sh/node-http-request/
//https://nodejs.org/en/knowledge/HTTP/clients/how-to-create-a-HTTP-request/
const http = require("http")
let body = JSON.stringify({
title: "Make a request with Node's http module"
})
let options = {
@toddlers
toddlers / cfn.yml
Created January 23, 2021 14:28
sample api gateway cfn template
AWSTemplateFormatVersion: 2010-09-09
Description: My API Gateway and Lambda function
Parameters:
apiGatewayName:
Type: String
Default: my-api
apiGatewayStageName:
Type: String
AllowedPattern: "[a-z0-9]+"

AWS Cloudformation ApiGateway vs ApiGatewayV2 with Lambda

This shows how to convert a basic REST ApiGateway template to its equivalent HTTP ApiGatewayV2.

The original code before refactoring to ApiGatewayV2 comes from this article

Deployment

Replace MY_PROFILE, MY_REGION and MY_STACK_NAME

@toddlers
toddlers / terraform_information.md
Last active January 20, 2021 14:16
terraform 0.13.4 with aws provider v3.16.0

terraform version

✔ ~/src/old_tf
11:36 $ terraform --version
Terraform v0.13.4
+ provider registry.terraform.io/hashicorp/aws v3.16.0

Your version of Terraform is out of date! The latest version
is 0.14.4. You can update by downloading from https://www.terraform.io/downloads.html
@toddlers
toddlers / stepfunction.json
Created January 14, 2021 16:39
new state machine with execution name only
{
"Comment": "Defines the statemachine.",
"StartAt": "SageMaker CreateTransformJob",
"States": {
"SageMaker CreateTransformJob": {
"Type": "Task",
"Resource": "arn:aws:states:::sagemaker:createTransformJob.sync",
"Parameters": {
"BatchStrategy": "SingleRecord",
"DataProcessing": {
@toddlers
toddlers / cfn.yml
Created January 12, 2021 14:14
ec2 userdata cloudformation
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Persistantly sets the hostname of a RHEL7 EC2 instance on start
Mappings:
RegionMap:
us-east-1:
'32': ami-6411e20d
'64': ami-7a11e213
us-west-1:
'32': ami-c9c7978c
@toddlers
toddlers / eventname.list
Created January 12, 2021 09:58
cloud trail event names
AbortDocumentVersionUpload
AbortEnvironmentUpdate
AbortMultipartUpload
AbortVaultLock
AcceptAccountMapping
AcceptCertificateTransfer
AcceptDelegate
AcceptDirectConnectGatewayAssociationProposal
AcceptFxPaymentCurrencyTermsAndConditions
AcceptHandshake
@toddlers
toddlers / rmq.py
Last active January 8, 2021 15:08
rabbitmq connect
In [24]: node = pika.URLParameters('amqps://<>.mq.us-east-1.amazonaws.com:5671')
In [25]: conn = pika.BlockingConnection([node])
Pika version 1.1.0 connecting to ('<>', 5671)
Socket connected: <socket.socket fd=17, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.178.45', 50679), raddr=('<>', 5671)>
SSL handshake completed successfully: <ssl.SSLSocket fd=17, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.178.45', 50679), raddr=('<>', 5671)>
Streaming transport linked up: (<pika.adapters.utils.io_services_utils._AsyncSSLTransport object at 0x110918ee0>, _StreamingProtocolShim: <SelectConnection PROTOCOL transport=<pika.adapters.utils.io_services_utils._AsyncSSLTransport object at 0x110918ee0> params=<URLParameters host=<>.mq.us-east-1.amazonaws.com port=5671 virtual_host=/ ssl=True>>).
Aborting transport connection: state=1; <ssl.SSLSocket fd=17, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.178.45',
@toddlers
toddlers / stepfunction.json
Created January 7, 2021 11:58
intrinsic functions
{
"Comment": "A Catch example of the Amazon States Language using an AWS Lambda Function",
"StartAt": "nextstep",
"States": {
"nextstep": {
"Type": "Task",
"Resource": "arn:aws:lambda:eu-central-1:1234567890:function:catcherror",
"Parameters": {
"executionId.$": "States.Format('somestring {}', $$.Execution.Id)"
},
@toddlers
toddlers / pipeline.yml
Last active June 30, 2022 13:00
bitbucket pipeline with aws credentials
pipelines:
- step:
script:
# assuming the base image which is pulled from ecr has aws cli installed
- export AWS_PROFILE=deployment
# aws login
- eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email)
# docker
- export BUILD_ID=$BITBUCKET_BRANCH_$BITBUCKET_COMMIT_$BITBUCKET_BUILD_NUMBER
- docker build -t ${AWS_REGISTRY_URL}:$BUILD_ID .