Skip to content

Instantly share code, notes, and snippets.

@413n
413n / Create AWS Exports for Vercel.md
Last active September 15, 2023 07:08
Create AWS Exports for Vercel

Create AWS Exports for Vercel

DISCLAIMER: Unfortunately this method is manual, but eventually needs to be done just the first time you create the Amplify Environment.

You need to have the aws-exports.js file (generated by Amplify) to do this process.

We're gonna use a Environment variable (in my case BASE64_AWS_EXPORTS) that will contain the aws-exports.js file content encoded in base64. The script will then decode it and create the aws-exports.js file.

The package.json needs to be changed so that this script will be created before the build.

@chanan
chanan / auth.server.js
Created December 21, 2021 21:55
Cognito authentication method for Remix
import { redirect, createCookie } from "remix";
const sessionSecret = process.env.SESSION_SECRET;
const cognitoDomain = process.env.COGNITO_DOMAIN;
const clientId = process.env.CLIENT_ID;
if (!sessionSecret) {
throw new Error("SESSION_SECRET must be set");
}
if (!cognitoDomain) {
throw new Error("COGNITO_DOMAIN must be set");
@josefaidt
josefaidt / post-checkout
Created November 9, 2021 21:16
Git post-checkout hook to change AWS Amplify environments upon branch checkout
#!/bin/bash
# .git/hooks/post-checkout
# Utility to change AWS Amplify environments on branch checkout
# helper to get path to aws-exports.js
function get_aws_exports_path {
local AMPLIFY_PROJECT_CONFIG_PATH="amplify/.config/project-config.json"
local AMPLIFY_EXPORTS_PATH=$(jq -r '.javascript.config.SourceDir' $AMPLIFY_PROJECT_CONFIG_PATH)
if [[ "$AMPLIFY_EXPORTS_PATH" == */ ]]
@renegoretzka
renegoretzka / README.MD
Last active May 11, 2024 07:17
Example to invoke AppSync from AWS Lambda

How to access an AppSync Endpoint from a Lambda function

Setup in project

Run amplify add function and go thru the manual configuration and add access to other resources. Add API here. Run amplify update api if you have a project already setup and configure IAM as an additional auth mode.

Setup in schema.graphql

Add the authorization as following to your type definition:

import { useCallback, useState } from 'react';
export interface ApiResult<R> {
data: R | null;
isBusy: boolean;
isError: boolean;
isSuccess: boolean;
}
function useCall<D, R>(
import React, { useState, useEffect, createContext, useContext, ReactNode } from 'react'
import Amplify, { Auth, Hub } from 'aws-amplify'
import { CognitoUser } from '@aws-amplify/auth'
import { CognitoUserSession } from 'amazon-cognito-identity-js'
import { HubCallback } from '@aws-amplify/core/lib/Hub'
import IUser from '../../types/IUser'
interface IAuthContext {
user: IUser | null
login(username: string, password: string): Promise<CognitoUser>
Serial Keys:
FU512-2DG1H-M85QZ-U7Z5T-PY8ZD
CU3MA-2LG1N-48EGQ-9GNGZ-QG0UD
GV7N2-DQZ00-4897Y-27ZNX-NV0TD
YZ718-4REEQ-08DHQ-JNYQC-ZQRD0
GZ3N0-6CX0L-H80UP-FPM59-NKAD4
YY31H-6EYEJ-480VZ-VXXZC-QF2E0
ZG51K-25FE1-H81ZP-95XGT-WV2C0
VG30H-2AX11-H88FQ-CQXGZ-M6AY4
@sibelius
sibelius / metro.config.js
Created December 30, 2018 11:28
Metro config to make react native play nice with monorepos
const path = require('path');
const getWorkspaces = require('get-yarn-workspaces');
const blacklist = require('metro-config/src/defaults/blacklist');
const workspaces = getWorkspaces(__dirname);
module.exports = {
projectRoot: path.resolve(__dirname, 'packages/app'),
@digitaljhelms
digitaljhelms / gist:4287848
Last active July 5, 2024 16:30
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"