Skip to content

jandolezal71/aws_workshop

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
  • Install local frontend development tool from SST $ npm i -D @serverless-stack/static-site-env -w frontend
  • Add to frontend/package.json a line "dev": "sst-env -- next dev"
  • Install $ npm i -D @sls-next/lambda-at-edge to the root package.json as mentioned in the SST docs
  • 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

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published