Skip to content

Instantly share code, notes, and snippets.

@awssimplified
awssimplified / gist:02d7c43a3ed9222312746138181e1af9
Created December 19, 2020 18:25
api gateway service proxy
DynamoDb Put Item Documentation - https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html
API Gateway Policy
---
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
AWSTemplateFormatVersion: 2010-09-09
Resources:
OrdersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: AuthorsTable_prod
AttributeDefinitions:
- AttributeName: "AuthorName"
AttributeType: "S"
- AttributeName: "BookTitle"
Commands
------------
1. Build Docker Image
docker build -t test .
2. Run container /w image
docker run -d --publish 8888:5000 test
3. Login to ECR
aws ecr get-login-password --region REGIONHERE!!!! | docker login --username AWS --password-stdin ACCOUNTIDHERE!!!!.dkr.ecr.REGIONHERE!!!.amazonaws.com
ECR
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "ecr:*",
"Resource": "*"
},
NodeJS
---
Every file is a 'module'
console.log(`Hi ${this.name}!`); <-- `` Templating
Make sure to use the relative path when importing or node will think you are using the built in module
exports.sayHello = function() {
console.log("Hello!");
};
Docker Orchestration
----
Kubernetes
---
Takes declared state, and works to make that happen across a cluster.
Node - 'kubelet' runs pods and talks 2 master. Node = Computer
Pod - runs 1+ containers, exists on node
Service - handles requests using LB
Docker Notes
---
docker daemon
REST Api to interact with it
CLI to interact with it uses the REST APIs
your docker daemon can run on a totally different machine and you can issue commands to it from your local
'dockerd' = daemon
'docker' = using the api
//Lets Learn Redis!
// **** PreRequisites ****
// Have Reddis running on localhost, either by using docker or installing it directly on your machine
const redis = require("redis");
1. SHOW ALL DATABASES
show dbs
2. SHOW CURRENT DATABASE
db
3. CREATE DATABASE
use transactions
4. CREATE COLLECTION / TABLE
#IAM Permission needed: dynamodb:query
import json
import sys
import boto3
from boto3.dynamodb.conditions import Key, Attr
dynamodb = boto3.resource('dynamodb')
def lambda_handler(event, context):