This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const serverlessConfiguration: AWS = { | |
... | |
resources: { | |
Resources: { | |
...apiGatewayDefaultResponse4xx(), | |
...apiGatewayDefaultResponse5xx(), | |
...cognitoUserPool.resources, | |
...ddbMainTable.resources, | |
}, | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { varToString } from "./utilities"; | |
export const createUserPool = () => { | |
const identityPoolRole = { | |
Type: "AWS::IAM::Role", | |
Properties: { | |
... | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
postMessage: postMessage({ | |
"Fn::GetAtt": ["mainTable", "Arn"] | |
}, { | |
Ref: "mainTable" | |
}), | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { varToString } from "./utilities"; | |
export const createMainTable = () => { | |
const mainTable = { | |
Type: "AWS::DynamoDB::Table", | |
Properties: { | |
AttributeDefinitions: [ | |
{ | |
AttributeName: "PK", | |
AttributeType: "S", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AwsCfInstruction } from "@serverless/typescript"; | |
import { AuthorizerConfig } from "./utilities"; | |
export type AdditionalPolicyStatement = { | |
Action: string[]; | |
Resource: AwsCfInstruction[]; | |
Effect: "Allow" | "Deny"; | |
}; | |
export const createFunctionHandler = ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createFunctionHandler } from "@resources/createFunctionHandler"; | |
import { AwsCfInstruction } from "@serverless/typescript"; | |
export const postMessage = (mainTableArn: AwsCfInstruction, mainTableName: AwsCfInstruction) => | |
createFunctionHandler( | |
"postMessage", | |
"/messages", | |
"POST", | |
undefined, | |
[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
functions: { | |
postMessage: postMessage(ddbMainTable.arn, ddbMainTable.name), | |
getMessages: getMessages(ddbMainTable.arn, ddbMainTable.name), | |
function3: function3(cognitoAuthorizer, cognitoUserPool.userPoolId, cognitoUserPool.identityPoolId), | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import middy from "@middy/core"; | |
import httpJsonBodyParser from "@middy/http-json-body-parser"; | |
import httpHeaderNormalizer from "@middy/http-header-normalizer"; | |
import httpErrorHandler from "@middy/http-error-handler"; | |
import cors from "@middy/http-cors"; | |
import validator from "@middy/validator"; | |
import httpSecurityHeaders from "@middy/http-security-headers"; | |
import httpResponseSerializer from "@middy/http-response-serializer"; | |
export const middyfy = (handler: any, inputSchema?: Record<string, unknown>, outputSchema?: Record<string, unknown>, origins: string[] = ["*"]) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { AWS } from "@serverless/typescript"; | |
const serverlessConfiguration: AWS = { | |
service: "serverless-streamlined", | |
frameworkVersion: "3", | |
provider: { | |
name: "aws", | |
runtime: "nodejs14.x", | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as apigateway from "@pulumi/aws-apigateway"; | |
import * as aws from "@pulumi/aws"; | |
export const api = new apigateway.RestAPI("pulumi-serverless-journey", { | |
stageName: "dev", | |
routes: [ | |
{ | |
path: "/function1", | |
method: "POST", | |
eventHandler: new aws.lambda.CallbackFunction("function1", { |
NewerOlder