Skip to content

Instantly share code, notes, and snippets.

@startuml
skin rose
autonumber
title Customer Order Workflow on Website
actor Customer
participant Website
participant OrderService
participant CustomerService
{
"Comment": "A description of my state machine",
"StartAt": "Add Order Entry",
"States": {
"Add Order Entry": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName": "CustomerOrdersTable",
"Item": {
Pre-Reqs
---
1) CDK
2) NPM
3) A Github repository
1. Run this command
export CDK_NEW_BOOTSTRAP=1
npx cdk bootstrap aws://<YOUR_ACCONT_ID>/<YOUR_REGION> --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess aws://<YOUR_ACCONT_ID>/<YOUR_REGION>
{
"Comment": "A description of my state machine",
"StartAt": "Choice",
"States": {
"Choice": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.type",
"StringEquals": "PURCHASE",
IAM Policies
---
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "*"
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"cloudformation:DescribeStacks",
"cloudformation:CreateChangeSet",
"cloudformation:DescribeChangeSet",
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
Connect & Disconnect
---
import json
def lambda_handler(event, context):
print(event)
print("****")
print(context)
lambda function
----
exports.handler = async (event) => {
console.log(event)
const customerId = event.pathParameters.customerId;
const customer = {'customerId': customerId, 'customerName': "Customer " + customerId };
const response = {
statusCode: 200,
// Uncomment below to enable CORS requests
headers: {
DemoHandler
---
def lambda_handler(event, context):
print(event)
return "hello, world!!"
DemoAuthorizer
---