Skip to content

Commit

Permalink
Edits to Gen 2 project structure page (#6840)
Browse files Browse the repository at this point in the history
* Edits to Gen 2 project structure page

* Removed the aws-cdk-lib command and warning message

* Updated CDK wording
  • Loading branch information
hibler13 authored Jan 30, 2024
1 parent c573afb commit 0e6cb4e
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions src/pages/gen2/reference/project-structure/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const meta = {
title: 'Project structure',
description: 'Learn more about the Amplify project structure.'
description: 'Learn more about how Amplify projects are structured.'
};

export function getStaticProps(context) {
Expand All @@ -11,9 +11,9 @@ export function getStaticProps(context) {
};
}

Amplify (Gen 2) backends are defined using TypeScript, and enable you to collocate resources depending on their function. For example, you can author a [Post Confirmation trigger for Amazon Cognito](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-post-confirmation.html) right next to your auth's resource file.
Amplify (Gen 2) backends are defined using TypeScript, and enable you to collocate resources depending on their function. For example, you can author a [post confirmation trigger for Amazon Cognito](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-post-confirmation.html) right next to your auth's resource file.

First, after creating your first Amplify project with `npm create amplify@latest`, it will contain the scaffolding for Data and Authentication resources:
When you create your first Amplify project using `npm create amplify@latest`, it will automatically set up the scaffolding for Data and Authentication resources:

```text
├── amplify/
Expand All @@ -30,7 +30,7 @@ First, after creating your first Amplify project with `npm create amplify@latest
└── tsconfig.json
```

As your project grows and your backend is built out, the structure of your project may look like the following:
As your project grows and you build out your backend, the structure of your project may look like the following:

```text
├── amplify/
Expand Down Expand Up @@ -88,7 +88,7 @@ export const auth = defineAuth({
});
```

After defining backend resources they are set on the backend:
After the resources are defined, they are set up on the backend:

```ts title="amplify/backend.ts"
import { defineBackend } from '@aws-amplify/backend';
Expand All @@ -101,28 +101,7 @@ defineBackend({
});
```

Backends can be extended using the [AWS Cloud Development Kit (CDK)](https://docs.aws.amazon.com/cdk/v2/guide/home.html). By leveraging CDK you can build using any AWS service, such as an Amazon S3 bucket that authenticated users have read and write access to. You can get started by installing AWS CDK:

```bash
npm add --save-dev aws-cdk-lib
```

<Callout warning>

Depending on the Node.js package manager you are using, you may encounter warnings where it is now unable to resolve the peer dependency version `@aws-amplify/backend` has on `aws-cdk-lib`. If you encounter a warning similar to the following, re-install the version specified in the warning text:

```
npm WARN Could not resolve dependency:
npm WARN peer aws-cdk-lib@"~2.103.0" from @aws-amplify/backend@0.4.0
npm WARN node_modules/@aws-amplify/backend
npm WARN dev @aws-amplify/backend@"^0.4.0" from the root project
```

Using the sample warning text above, you would need to install `aws-cdk-lib@2.103.0`.

</Callout>

Then add CDK to your backend:
You can extend backends by using the [AWS Cloud Development Kit (AWS CDK)](https://docs.aws.amazon.com/cdk/v2/guide/home.html), which is installed by default as part of the `create amplify` workflow. With the CDK, you can build using any AWS service, such as an Amazon S3 bucket that authenticated users have read and write access to. To get started with the CDK, add it to your backend:

```ts title="amplify/backend.ts"
import * as s3 from 'aws-cdk-lib/aws-s3';
Expand Down Expand Up @@ -150,7 +129,7 @@ const unauthRole = backend.auth.resources.unauthenticatedUserIamRole;
bucket.grantRead(unauthRole);
```

## Next Steps
## Next steps

- [Learn the concepts](/gen2/how-amplify-works/concepts)
- [Learn how to add AWS services to your backend](/gen2/build-a-backend/add-aws-services)

0 comments on commit 0e6cb4e

Please sign in to comment.