Boilerplate used when doing the workshop
- Official installation guildelines
- Setup configuration via
$ aws configure --profile workshop - Add credentials to
$ nano ~/.aws/credentials
$ nvm use 16- Create SST project via
$ npx create-sst my-app - Constructs docs: https://docs.sst.dev/constructs
- How SST works with AWS profiles: https://docs.sst.dev/working-with-your-team#aws-account-per-environment
- Cross stack references via
use: https://docs.sst.dev/advanced/cross-stack-references
- License plate regex
/^[0-9][A-Z]{2} [0-9]{4}$/.test
- Create Next.js project in
frontendfolder via Next.js CLI$ npx create-next-app@latest --ts --use-npm - Add to
frontend/package.jsona 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] } }
- 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}/*`] }) )
-
new CfnEventBusPolicy(stack, 'EventBusPolicy', { eventBusName: eventBus.eventBusName, statementId: stack.stackName, action: 'events:PutEvents', principal: '221940693656' })