Skip to content

Instantly share code, notes, and snippets.

View wenindoubt's full-sized avatar
🎯
Focusing

Jeffrey Wen wenindoubt

🎯
Focusing
  • Autodesk, Inc.
  • Irvine, CA
View GitHub Profile
Initializing the backend...
2021/11/01 17:53:38 [DEBUG] New state was assigned lineage "cda351b1-59de-0f34-81e8-65124caba103"
2021/11/01 17:53:38 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
Use TF_LOG=TRACE to see Terraform's internal logs.
----
2021/11/01 17:53:38 [INFO] AWS Auth provider used: "EnvProvider"
2021/11/01 17:53:38 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2021/11/01 17:53:38 [DEBUG] [aws-sdk-go] DEBUG: Request sts/GetCallerIdentity Details:
---[ REQUEST POST-SIGN ]-----------------------------
POST / HTTP/1.1
@wenindoubt
wenindoubt / postman-pre-request.js
Created October 1, 2021 18:18 — forked from bcnzer/postman-pre-request.js
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
import { mocked } from 'ts-jest/utils';
import { Handler } from 'aws-lambda';
import { middyfy } from '@libs/lambda';
jest.mock('@libs/lambda');
describe('hello', () => {
let main;
let mockedMiddyfy: jest.MockedFunction<typeof middyfy>;
import middy from '@middy/core';
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
import { formatJSONResponse } from './apiGateway';
import { AppError } from './appError';
import MiddlewareFunction = middy.MiddlewareFunction;
export const apiGatewayResponseMiddleware = (options: { enableErrorLogger?: boolean } = {}) => {
const after: MiddlewareFunction<APIGatewayProxyEvent, any> = async (request) => {
@wenindoubt
wenindoubt / create.ts
Created June 30, 2021 19:27 — forked from fredericbarthelet/create.ts
Lamba create.ts with intrinsic service
import { DynamoDB } from 'aws-sdk';
import { ref } from './intrinsic';
import cloudformationResources, { MyTable } from './resources';
export default {
handler:'create.main',
environment: {
TABLE_NAME: ref(cloudformationResources, MyTable)
},
@wenindoubt
wenindoubt / intrinsic.ts
Created June 30, 2021 19:27 — forked from fredericbarthelet/intrinsic.ts
AWS intrinsic function resolution
import {
CloudFormationResource,
CloudFormationResources,
} from 'serverless/aws';
import { findKey } from 'lodash';
interface CloudFormationReference {
Ref: string;
}
@wenindoubt
wenindoubt / create.ts
Created June 30, 2021 19:27 — forked from fredericbarthelet/create.ts
lambda with dynamo
import { DynamoDB } from 'aws-sdk';
export default {
handler:'create.main',
environment: {
TABLE_NAME: {
Ref: 'MyTable'
}
},
events: [
@wenindoubt
wenindoubt / functions.ts
Created June 30, 2021 19:27 — forked from fredericbarthelet/functions.ts
Serverless.ts complex project imports
export { default as hello } from './hello';
export { default as goodbye } from './goodbye';
@wenindoubt
wenindoubt / functions.ts
Created June 30, 2021 19:14 — forked from fredericbarthelet/functions.ts
Serverless.ts splitting
export default {
hello: {
handler: 'index.hello'
},
goodbye: {
handler: 'index.goodbye'
}
};
const { SQS } = require('@aws-sdk/client-sqs');
const sqs = new SQS();
const handler = async (event) => {
console.log('event', event);
const { id, title } = JSON.parse(event.body);
await sqs.sendMessage({
QueueUrl: process.env.QUEUE_URL,