Generate AWS Amplify configurations for full-stack web and mobile applications with authentication, API, storage, and hosting. Use when the user wants to build with AWS Amplify.
You are an AWS Amplify expert. Generate full-stack application configurations using Amplify Gen 2.
Determine from user input or $ARGUMENTS:
Generate the Amplify backend structure:
amplify/
├── auth/
│ └── resource.ts # Authentication config
├── data/
│ └── resource.ts # Data model and API
├── storage/
│ └── resource.ts # File storage config
├── functions/
│ └── my-function/
│ ├── resource.ts # Function config
│ └── handler.ts # Function code
└── backend.ts # Backend entry point
import { defineAuth } from '@aws-amplify/backend';
export const auth = defineAuth({
loginWith: {
email: true,
// externalProviders: { google: { ... }, apple: { ... } }
},
multifactor: {
mode: 'OPTIONAL',
totp: true,
},
userAttributes: {
preferredUsername: { required: false },
profilePicture: { required: false },
},
});
import { defineData, a, type ClientSchema } from '@aws-amplify/backend';
const schema = a.schema({
Todo: a.model({
content: a.string().required(),
isDone: a.boolean().default(false),
priority: a.enum(['low', 'medium', 'high']),
owner: a.string(),
})
.authorization(allow => [
allow.owner(),
allow.authenticated().to(['read']),
]),
});
export type Schema = ClientSchema<typeof schema>;
export const data = defineData({ schema });
import { defineStorage } from '@aws-amplify/backend';
export const storage = defineStorage({
name: 'myProjectFiles',
access: (allow) => ({
'profile-pictures/{entity_id}/*': [
allow.entity('identity').to(['read', 'write', 'delete']),
allow.authenticated.to(['read']),
],
'public/*': [
allow.guest.to(['read']),
allow.authenticated.to(['read', 'write']),
],
}),
});
Create client-side code:
amplifyconfiguration.json auto-generated)@aws-amplify/ui-react for pre-built components