This file contains hidden or 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 { useState, useEffect } from 'react' | |
import { Storage } from 'aws-amplify' | |
function App() { | |
const [images, setImages] = useState([]) | |
useEffect(() => { | |
fetchImages() | |
}, []) | |
async function fetchImages() { | |
let imageKeys = await Storage.list('') |
This file contains hidden or 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
var aws = require('aws-sdk') | |
var ddb = new aws.DynamoDB() | |
exports.handler = async (event, context) => { | |
let date = new Date() | |
if (event.request.userAttributes.sub) { | |
let params = { | |
Item: { | |
'id': {S: event.request.userAttributes.sub}, | |
'__typename': {S: 'User'}, |
This file contains hidden or 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
// To man manually check for groups, you can get the user's identity from | |
// the event.identity object, and check for claims in | |
// the event.identity.claims['cognito:groups'] | |
function checkForGroup(event:AppSyncEvent, groupName:string) { | |
if (event.identity) { | |
if (event.identity.claims['cognito:groups']) { | |
if (event.identity.claims['cognito:groups'].includes(groupName)) { | |
return true | |
} |
This file contains hidden or 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
/* On the server */ | |
const AWS = require('aws-sdk') | |
const chime = new AWS.Chime({ region: 'us-east-1' }) | |
// create a room | |
const meeting = await chime.createMeeting({ | |
ClientRequestToken: uuid(), | |
MediaRegion: 'us-east-1' | |
}).promise() |
This file contains hidden or 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
nextamplified: | |
component: "@sls-next/[email protected]" | |
inputs: | |
domain: "nextjsonaws.com" |
This file contains hidden or 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
# Build locally | |
# docker build . -t nextapp | |
# Run locally | |
# docker run -it -p 8080:3000 nextapp | |
FROM public.ecr.aws/bitnami/node:14.15.1-debian-10-r8 | |
WORKDIR /app | |
COPY package.json yarn.lock ./ | |
RUN yarn |
This file contains hidden or 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
// In a regular Lambda function | |
const user = event.requestContext.authorizer.claims | |
// In a Serverless Express route | |
const user = req.apiGateway.event.requestContext.authorizer.claims | |
// On client | |
async function callApi() { | |
const user = await Auth.currentAuthenticatedUser() | |
const token = user.signInUserSession.idToken.jwtToken |
This file contains hidden or 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
# .github/workflows/main.yml | |
name: CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
build: |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Ansi 0 Color</key> | |
<dict> | |
<key>Alpha Component</key> | |
<real>1</real> | |
<key>Blue Component</key> | |
<real>0.0</real> |
This file contains hidden or 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 Amplify from 'aws-amplify'; | |
const { AppsyncCdkAppStack } = require('./outputs.json'); | |
import config from './aws-exports'; | |
Amplify.configure({ | |
...config, | |
aws_appsync_graphqlEndpoint: AppsyncCdkAppStack.GraphQLAPIURL, | |
aws_appsync_apiKey: AppsyncCdkAppStack.GraphQLAPIKey | |
}) |