Skip to content

Boilerplate used for the serverless parking workshop 👷‍♂️ 🅿️

License

Notifications You must be signed in to change notification settings

purple-technology/serverless-parking-workshop-boilerplate

Repository files navigation

serverless-parking-workshop-boilerplate

Boilerplate used when doing the workshop

Node.js

AWS CLI

Serverless Stack (SST)

Auth (Amazon Cognito)

API (AWS AppSync)

Machine Learning

  • License plate regex /^[0-9][A-Z]{2} [0-9]{4}$/.test

Frontend

  • Create Next.js project in frontend folder via Next.js CLI $ npx create-next-app@latest --ts --use-npm
  • Add to frontend/package.json a line "dev": "sst bind next dev"
  • Install AWS Amplify frontend library $ npm i aws-amplify -w frontend
  • Configure AWS Amplify. More about the configuration in Amplify docs and more about environment variables in Next.js docs
    export const amplifyConfig = {
        Auth: {
            region: `${process.env.NEXT_PUBLIC_USER_POOL_ID}`.split('_')[0],
            userPoolId: process.env.NEXT_PUBLIC_USER_POOL_ID,
            userPoolWebClientId: process.env.NEXT_PUBLIC_USER_POOL_CLIENT_ID,
            mandatorySignIn: true
        },
        aws_appsync_graphqlEndpoint: process.env.NEXT_PUBLIC_APP_API_URL,
        aws_appsync_region: `${process.env.NEXT_PUBLIC_USER_POOL_ID}`.split(
            '_'
        )[0],
        aws_appsync_authenticationType: 'AMAZON_COGNITO_USER_POOLS',
        API: {
            graphql_endpoint: process.env.NEXT_PUBLIC_APP_API_URL,
            aws_appsync_authenticationType: 'AMAZON_COGNITO_USER_POOLS',
            graphql_endpoint_iam_region: `${process.env.NEXT_PUBLIC_USER_POOL_ID}`.split('_')[0]
        }
    }

S3 Camera images

  • Paths Entrance, Exit, ParkingLot
  • Resource Policy
    bucket.cdk.bucket.addToResourcePolicy(
    	new PolicyStatement({
    		effect: Effect.ALLOW,
    		principals: [new AccountPrincipal('221940693656')],
    		actions: ['s3:PutObject'],
    		resources: [`arn:aws:s3:::${bucket.bucketName}/*`]
    	})
    )

EventBridge connection

  • new CfnEventBusPolicy(stack, 'EventBusPolicy', {
    	eventBusName: eventBus.eventBusName,
    	statementId: stack.stackName,
    	action: 'events:PutEvents',
    	principal: '221940693656'
    })

About

Boilerplate used for the serverless parking workshop 👷‍♂️ 🅿️

Topics

Resources

License

Stars

Watchers

Forks