Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aws-apprunner): support the Service L2 construct #15810

Merged
merged 45 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2a9acdd
feat(aws-apprunner): support the Service L2 construct
pahud Jul 29, 2021
c79d90b
Merge branch 'master' into apprunner-service
pahud Jul 29, 2021
b44033e
fix fromServiceName
pahud Jul 29, 2021
6910a22
chore: update README
pahud Jul 29, 2021
1f8705e
support fromEcrRepository()
pahud Jul 29, 2021
8eaafcc
minor
pahud Jul 29, 2021
b125a6d
chore: update README
pahud Jul 29, 2021
4bfbe85
chore: update README
pahud Jul 29, 2021
f77157c
support instanceRole and accessRole
pahud Jul 29, 2021
8ab98dc
chore: update README
pahud Jul 29, 2021
185c938
minor
pahud Jul 29, 2021
f27d6d1
Update packages/@aws-cdk/aws-apprunner/lib/service.ts
pahud Jul 30, 2021
76b2b3b
Update packages/@aws-cdk/aws-apprunner/lib/service.ts
pahud Jul 30, 2021
636ab89
Update packages/@aws-cdk/aws-apprunner/lib/service.ts
pahud Jul 30, 2021
d731f7a
Update packages/@aws-cdk/aws-apprunner/lib/service.ts
pahud Jul 30, 2021
19b00af
Update packages/@aws-cdk/aws-apprunner/lib/service.ts
pahud Jul 30, 2021
93b87d3
Update packages/@aws-cdk/aws-apprunner/lib/service.ts
pahud Jul 30, 2021
9546e33
Update packages/@aws-cdk/aws-apprunner/lib/service.ts
pahud Jul 30, 2021
d2d35e8
Merge branch 'master' into apprunner-service
pahud Jul 30, 2021
3cc9a93
Merge branch 'master' into apprunner-service
pahud Aug 10, 2021
6662b60
refactor
pahud Aug 11, 2021
d7a6d2b
update README
pahud Aug 11, 2021
c390308
Merge branch 'master' into apprunner-service
pahud Sep 1, 2021
eb1fd05
fix test
pahud Sep 2, 2021
6953f9a
Merge branch 'aws:master' into apprunner-service
pahud Sep 15, 2021
05c65a3
minor issues addressed
pahud Sep 15, 2021
5b9095e
minor
pahud Sep 15, 2021
fff2422
Merge branch 'master' into apprunner-service
pahud Sep 15, 2021
01b5652
refactor with Source factor
pahud Sep 16, 2021
cc4ba51
lint
pahud Sep 16, 2021
4252c2d
Merge branch 'master' into apprunner-service
pahud Sep 16, 2021
480d784
fix the integ
pahud Sep 16, 2021
27c47b5
update README
pahud Sep 16, 2021
2c481f2
update README
pahud Sep 16, 2021
caf5d94
Merge branch 'master' into apprunner-service
pahud Sep 17, 2021
566ae31
Merge branch 'master' into apprunner-service
pahud Sep 17, 2021
d512ca4
Merge branch 'master' into apprunner-service
pahud Sep 20, 2021
74904bc
Merge branch 'master' into apprunner-service
pahud Sep 23, 2021
82b72e6
fix tests
pahud Sep 23, 2021
4e567bf
fix tests
pahud Sep 23, 2021
12cda09
minor
pahud Sep 23, 2021
9a7e923
update tests
pahud Sep 23, 2021
be34d70
use @aws-cdk/assertions for the tests
pahud Sep 23, 2021
6e78dc9
Merge branch 'master' into apprunner-service
mergify[bot] Sep 23, 2021
99748a6
Merge branch 'master' into apprunner-service
mergify[bot] Sep 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions packages/@aws-cdk/aws-apprunner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
>
> [CFN Resources]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib

![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)

> The APIs of higher level constructs in this module are experimental and under active development.
> They are subject to non-backward compatible changes or removal in any future version. These are
> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
> announced in the release notes. This means that while you may use them, you may need to update
> your source code when upgrading to a newer version of this package.

---

<!--END STABILITY BANNER-->
Expand All @@ -18,3 +26,80 @@ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aw
```ts
import apprunner = require('@aws-cdk/aws-apprunner');
```

## Introduction

AWS App Runner is a fully managed service that makes it easy for developers to quickly deploy containerized web applications and APIs, at scale and with no prior infrastructure experience required. Start with your source code or a container image. App Runner automatically builds and deploys the web application and load balances traffic with encryption. App Runner also scales up or down automatically to meet your traffic needs. With App Runner, rather than thinking about servers or scaling, you have more time to focus on your applications.

## Service

The `Service` construct allows you to create AWS App Runner services with `ECR Public`, `ECR` or `Github`. You need specify either `image` or `code` for different scenarios.

## ECR Public

To create a `Service` with ECR Public, define the `image` property with `ContainerImage.fromEcrPublic()`:

```ts
new Service(stack, 'Service', {
image: ContainerImage.fromEcrPublic('public.ecr.aws/aws-containers/hello-app-runner:latest'),
port: 80,
});
```

## ECR

To create a `Service` from an existing ECR repository, use `ContainerImage.fromEcrRepository()`:

```ts
// import the existing ECR repository by name
const repo = ecr.Repository.fromRepositoryName(stack, 'ExistingRepository', 'existing-repo');
new Service(stack, 'Service', {
image: ContainerImage.fromEcrRepository(repo),
port: 80,
});
```


To create a `Service` from local docker image assets being built and pushed to Amazon ECR,
use `ContainerImage.fromDockerImageAssets()`:

```ts
const imageAssets = new assets.DockerImageAsset(stack, 'ImageAssets', {
directory, // your code assets directory with Dockerfile
});
new Service(stack, 'Service', {
image: ContainerImage.fromDockerImageAssets(imageAssets),
port: 80,
});
```

## Github

To create a `Service` from the Github repository, you need to specify an existing App Runner Connection.

See [Managing App Runner connections](https://docs.aws.amazon.com/apprunner/latest/dg/manage-connections.html) for more details.

```ts
new Service(stack, 'Service', {
connection: Connection.fromConnectionArn(connectionArn),
code: CodeRepository.fromGithubRepository({
repositoryUrl: 'https://github.com/aws-containers/hello-app-runner',
branch: 'main',
runtime: CodeRuntime.PYTHON_3,
}),
});
```

## IAM Roles

You are allowed to define `instanceRole` and `accessRole` for the `Service`.

`instanceRole` - The IAM role that provides permissions to your App Runner service. These are permissions that
your code needs when it calls any AWS APIs.

`accessRole` - The IAM role that grants the App Runner service access to a source repository. It's required for
ECR image repositories (but not for ECR Public repositories). If not defined, a new access role will be generated
when required.
pahud marked this conversation as resolved.
Show resolved Hide resolved

See [App Runner IAM Roles](https://docs.aws.amazon.com/apprunner/latest/dg/security_iam_service-with-iam.html#security_iam_service-with-iam-roles) for more details.

1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-apprunner/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// AWS::AppRunner CloudFormation Resources:
export * from './apprunner.generated';
export * from './service';
Loading