Skip to content

Commit

Permalink
fix: cleanup sections
Browse files Browse the repository at this point in the history
  • Loading branch information
agdimech committed Sep 3, 2023
1 parent 486a8c0 commit 65bf911
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 15 deletions.
126 changes: 125 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,131 @@
# aws-pdk
<a href="https://aws.github.io/aws-pdk/getting_started/migration_guide.html"><img src="docs/content/assets/images/rebrand_banner.png" width="1024px"></a>

# Getting started

## What is the AWS PDK?

The AWS Project Development Kit (AWS PDK) provides building blocks for common patterns together with development tools to manage and build your projects.

The AWS PDK lets you define your projects programatically via the expressive power of type safe constructs available in one of 3 languages (typescript, python or java). This approach yields many benefits, including:

- Ability to set up new projects within seconds, with all boilerplate already pre-configured.
- Receive updates to previously bootstrapped projects when new versions become available i.e: updated dependenies or lint configurations.
- Build polyglot monorepos, with build caching, cross-language build dependencies, dependency visualization and much more.
- Leverage codified patterns which vend project and infrastructure (CDK) code.

The AWS PDK is built on top of [Projen](https://github.com/projen/projen) and as such all constructs that you compose together need to be defined via a [projenrc](https://projen.io/programmatic-api.html) file.

## Why use the AWS PDK?

It's much easier to show than explain! Here is some PDK code (within projenrc file) that creates a Polyglot monorepo, with a React Website pre-configured with Cognito Auth and pre-integrated with a Smithy Type Safe Api.

```ts
import { CloudscapeReactTsWebsiteProject } from "@aws/pdk/cloudscape-react-ts-website";
import { InfrastructureTsProject } from "@aws/pdk/infrastructure";
import { MonorepoTsProject } from "@aws/pdk/monorepo";
import {
DocumentationFormat,
Language,
Library,
ModelLanguage,
TypeSafeApiProject,
} from "@aws/pdk/type-safe-api";
import { javascript } from "projen";

const monorepo = new MonorepoTsProject({
name: "my-project",
packageManager: javascript.NodePackageManager.PNPM,
projenrcTs: true,
});

const api = new TypeSafeApiProject({
parent: monorepo,
outdir: "packages/api",
name: "myapi",
infrastructure: {
language: Language.TYPESCRIPT,
},
model: {
language: ModelLanguage.SMITHY,
options: {
smithy: {
serviceName: {
namespace: "com.aws",
serviceName: "MyApi",
},
},
},
},
runtime: {
languages: [Language.TYPESCRIPT],
},
documentation: {
formats: [DocumentationFormat.HTML_REDOC],
},
library: {
libraries: [Library.TYPESCRIPT_REACT_QUERY_HOOKS],
},
handlers: {
languages: [Language.TYPESCRIPT],
},
});

const website = new CloudscapeReactTsWebsiteProject({
parent: monorepo,
outdir: "packages/website",
name: "website",
typeSafeApi: api,
});

new InfrastructureTsProject({
parent: monorepo,
outdir: "packages/infra",
name: "infra",
cloudscapeReactTsWebsite: website,
typeSafeApi: api,
});

monorepo.synth();
```

This code (also available in Python and Java), produces all the source code, packages and infrastructure needed to deploy a fully-operable application in the AWS cloud. All that's left to do is build and deploy it!

From this ~70 lines of code above, the AWS PDK produces the following packages on your behalf:

- `monorepo`: Root level project that manages interdependencies between projects within the Monorepo, provides build caching and dependency visualziation.
- `api/model`: A project that allows you to define your API using Smithy (or OpenAPI) IDL.
- `api/generated/documentation`: A project that automatically creates API documentation in a variety of formats.
- `api/generated/infrastructure`: A project that automatically creates API infrastructure constructs in a type-safe manner.
- `api/generated/libraries`: A project that automatically generates a react hooks library that can be used to call your API from a React based website.
- `api/generated/runtime`: A project that contains server bindings for handlers to ensure type safety.
- `api/handlers`: A project that automatically creates handler stubs, preconfigured with type-safety and a variety of value added features based on your defined API's.
- `website`: A project which creates a React based website built using [Cloudscape](https://cloudscape.design/) that comes pre-integrated with Cognito Auth and your created API. This provides you with the ability to call your API securely.
- `infra`: A project which sets up all CDK related infrastructure needed to deploy your application. It also comes pre-configured to generate a diagram based on your CDK code everytime you build.

### Bootstrapped Source

<img src="docs/content/assets/images/boilerplate_source.png" width="800" />

### Generated Website

<img src="docs/content/assets/images/website_screenshot.png" width="800" />

### Generated Diagram

<img src="docs/content/assets/images/generated_diagram.png" width="800" />

As you can see, the AWS PDK provides you with valuable time savings so you can focus on working on what matters most to your project.

## Developing with the AWS PDK

Please refer to the full documentation website.

https://aws.github.io/aws-pdk

## Contributing to the AWS PDK

https://aws.github.io/aws-pdk/contributing/index.html

## License

This project is licensed under the Apache-2.0 License.
Binary file added docs/content/assets/images/rebrand_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions docs/content/contributing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ This is where the documentation site is defined and built.

Contains configurations for each project within this monorepo.

**_As a rule of thumb, every package in the monorepo should correspond to a file in this directory._**
!!!info
As a rule of thumb, every package in the monorepo should correspond to a file in this directory.

### **packages**

Expand Down Expand Up @@ -214,7 +215,7 @@ From the root directory run: `pdk upgrade-deps`. This will bump all dependencies
If you run into an issue that resembles:

```bash
Type 'import(".../@aws/pdk/node_modules/aws-prototyping-sdk/node_modules/projen/lib/ignore-file").IgnoreFile' is not assignable to type 'import(".../@aws/pdk/node_modules/projen/lib/ignore-file").IgnoreFile'.
Type 'import(".../@aws/pdk/node_modules/@aws/pdk/node_modules/projen/lib/ignore-file").IgnoreFile' is not assignable to type 'import(".../@aws/pdk/node_modules/projen/lib/ignore-file").IgnoreFile'.
Types have separate declarations of a private property '_patterns'.
```

Expand Down
3 changes: 3 additions & 0 deletions docs/content/getting_started/shopping_list_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ This is a continuation from [build your first AWS PDK project](./your_first_aws_

In order to define our API, we need to write some [Smithy](https://smithy.io/2.0/quickstart.html) code which is contained within `packages/api/model/src/main/smithy`.

!!!info
More detailed information on how to use smithy can be found in the [Type Safe API Developer Guide](../developer_guides/type-safe-api/using_smithy.md)

### Definining our types

Firstly, let's define some types for our Shopping List application by creating the following files:
Expand Down
2 changes: 1 addition & 1 deletion docs/content/overrides/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ <h5>Getting started</h5>
</a>

<!-- Developer Guide -->
<a class="card-wrapper" href="developer_guides">
<a class="card-wrapper" href="developer_guides/index.html">
<div class="card">
<div class="logo">
<span class="twemoji">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
nav:
- index.md
- "API Explorer": api_explorer.md
- "Troubleshooting": troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# API Explorer

<img src="../../assets/images/website_auth.png" width="800" />

The `CloudscapeReactTsWebsiteProject` has an optional parameter called `typeSafeApi` which if passed in, automatically configures your website to set up an _API Explorer_ which will allow you to make sigv4 signed requested to your [Type Safe API](../type-safe-api/index.md).

```typescript hl_lines="5"
new CloudscapeReactTsWebsiteProject({
parent: monorepo,
outdir: "packages/website",
name: "website",
typeSafeApi: api,
});
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
[![API Documentation](https://img.shields.io/badge/view-API_Documentation-blue.svg)](../../api/typescript/type-safe-api/index.md)
[![Source Code](https://img.shields.io/badge/view-Source_Code-blue.svg)](https://github.com/aws/aws-pdk/tree/mainline/packages/type-safe-api)

> Define your API's declaratively in a type-safe manner to reduce preventable issues and increase overall productivity.
The _type-safe-api_ package provides a projen project type which allows you to define an API using either [Smithy](https://smithy.io/2.0/) or [OpenAPI v3](https://swagger.io/specification/), and a construct which manages deploying this API in an API Gateway.

You can define your APIs using [Smithy](https://smithy.io/2.0/) or [OpenAPI v3](https://swagger.io/specification/), and leverage the power of generated client and server types, infrastructure, documentation, and automatic input validation.
Expand Down Expand Up @@ -71,13 +73,13 @@ The `TypeSafeApiProject` projen project sets up the project structure for you. C

We recommend you use these projects as part of an `monorepo` project (eg. by specifying `parent: monorepo`), as it makes setting up dependencies much easier, particularly when extending your project further with a CDK app and lambda functions.

1. To start an empty `monorepo` project, use this command:
1.) To start an empty `monorepo` project, use this command:

```bash
pdk new monorepo-ts
```

2. Edit your `.projenrc` and configure `TypeSafeApiProject`.
2.) Edit your `.projenrc` and configure `TypeSafeApiProject`.

!!! tip

Expand Down Expand Up @@ -259,7 +261,7 @@ pdk new monorepo-ts
monorepo.synth()
```

3. Given we have modified our `projenrc` file we need to run the `pdk` command to synthesize our new API and infrastructure onto the filesystem. We can then run a first build with `pdk build`.
3.) Given we have modified our `projenrc` file we need to run the `pdk` command to synthesize our new API and infrastructure onto the filesystem. We can then run a first build with `pdk build`.

## Implement a Lambda handler

Expand Down Expand Up @@ -921,4 +923,4 @@ cd packages/infra
pdk run deploy --require-approval never
```

Try out your new API! You can use a tool such as [awscurl](https://github.com/okigan/awscurl) to make Sigv4 signed requests to your API, since we set the default authorizer to `Authorizers.iam()`.
Try out your new API! You can use a tool such as [awscurl](https://github.com/okigan/awscurl) to make Sigv4 signed requests to your API, since we set the default authorizer to `Authorizers.iam()`. Alternatively, you can deploy the [`CloudscapeReactTsWebsiteProject`](../cloudscape-react-ts-website/index.md) and try out the [API Explorer](../cloudscape-react-ts-website/api_explorer.md).
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,9 @@ When you use a handler router, you must specify the same lambda function for eve
=== "JAVA"

```java
import software.aws.awsprototypingsdk.typesafeapi.TypeSafeApiIntegration;
import software.aws.awsprototypingsdk.typesafeapi.Integrations;
import software.aws.awsprototypingsdk.typesafeapi.Authorizers;
import software.aws.awspdk.typesafeapi.TypeSafeApiIntegration;
import software.aws.awspdk.typesafeapi.Integrations;
import software.aws.awspdk.typesafeapi.Authorizers;

import com.generated.api.myapijavaruntime.runtime.api.Operations;
import com.generated.api.myapijavainfra.infra.Api;
Expand All @@ -524,7 +524,7 @@ When you use a handler router, you must specify the same lambda function for eve
=== "PYTHON"

```python
from aws_prototyping_sdk.type_safe_api import Integrations, TypeSafeApiIntegration, Authorizers
from aws_pdk.type_safe_api import Integrations, TypeSafeApiIntegration, Authorizers
from myapi_python_runtime.apis.tags.default_api_operation_config import Operations
from myapi_python_infra.api import Api

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ Use `MockIntegrations.mockAll` to mock all the operations in your API by returni
=== "JAVA"

```java
import software.aws.awsprototypingsdk.typesafeapi.TypeSafeApiIntegration;
import software.aws.awsprototypingsdk.typesafeapi.Integrations;
import software.aws.awspdk.typesafeapi.TypeSafeApiIntegration;
import software.aws.awspdk.typesafeapi.Integrations;

import com.generated.api.myapijavainfra.infra.Api;
import com.generated.api.myapijavainfra.infra.ApiProps;
Expand All @@ -90,7 +90,7 @@ Use `MockIntegrations.mockAll` to mock all the operations in your API by returni
=== "PYTHON"

```python
from aws_prototyping_sdk.type_safe_api import Integrations, TypeSafeApiIntegration
from aws_pdk.type_safe_api import Integrations, TypeSafeApiIntegration
from myapi_python_runtime.api.operation_config import OperationConfig
from myapi_python_infra.api import Api
from myapi_python_infra.mock_integrations import MockIntegrations
Expand Down

0 comments on commit 65bf911

Please sign in to comment.