# AWS::AppRunner Construct Library
<!--BEGIN STABILITY BANNER-->---
![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)
> All classes with the `Cfn` prefix in this module ([CFN Resources](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) are always stable and safe to use.
![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-->
This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.
```python
import aws_cdk.aws_apprunner as 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` with the `source` property in the following scenarios:
* `Source.fromEcr()` - To define the source repository from `ECR`.
* `Source.fromEcrPublic()` - To define the source repository from `ECR Public`.
* `Source.fromGitHub()` - To define the source repository from the `Github repository`.
* `Source.fromAsset()` - To define the source from local asset directory.
## ECR Public
To create a `Service` with ECR Public:
```python
apprunner.Service(self, "Service",
source=apprunner.Source.from_ecr_public(
image_configuration=apprunner.ImageConfiguration(port=8000),
image_identifier="public.ecr.aws/aws-containers/hello-app-runner:latest"
)
)
```
## ECR
To create a `Service` from an existing ECR repository:
```python
import aws_cdk.aws_ecr as ecr
apprunner.Service(self, "Service",
source=apprunner.Source.from_ecr(
image_configuration=apprunner.ImageConfiguration(port=80),
repository=ecr.Repository.from_repository_name(self, "NginxRepository", "nginx"),
tag_or_digest="latest"
)
)
```
To create a `Service` from local docker image asset directory built and pushed to Amazon ECR:
```python
import aws_cdk.aws_ecr_assets as assets
image_asset = assets.DockerImageAsset(self, "ImageAssets",
directory=path.join(__dirname, "./docker.assets")
)
apprunner.Service(self, "Service",
source=apprunner.Source.from_asset(
image_configuration=apprunner.ImageConfiguration(port=8000),
asset=image_asset
)
)
```
## 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.
```python
apprunner.Service(self, "Service",
source=apprunner.Source.from_git_hub(
repository_url="https://github.com/aws-containers/hello-app-runner",
branch="main",
configuration_source=apprunner.ConfigurationSourceType.REPOSITORY,
connection=apprunner.GitHubConnection.from_connection_arn("CONNECTION_ARN")
)
)
```
Use `codeConfigurationValues` to override configuration values with the `API` configuration source type.
```python
apprunner.Service(self, "Service",
source=apprunner.Source.from_git_hub(
repository_url="https://github.com/aws-containers/hello-app-runner",
branch="main",
configuration_source=apprunner.ConfigurationSourceType.API,
code_configuration_values=apprunner.CodeConfigurationValues(
runtime=apprunner.Runtime.PYTHON_3,
port="8000",
start_command="python app.py",
build_command="yum install -y pycairo && pip install -r requirements.txt"
),
connection=apprunner.GitHubConnection.from_connection_arn("CONNECTION_ARN")
)
)
```
## 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.
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.
## VPC Connector
To associate an App Runner service with a custom VPC, define `vpcConnector` for the service.
```python
import aws_cdk.aws_ec2 as ec2
vpc = ec2.Vpc(self, "Vpc",
cidr="10.0.0.0/16"
)
vpc_connector = apprunner.VpcConnector(self, "VpcConnector",
vpc=vpc,
vpc_subnets=vpc.select_subnets(subnet_type=ec2.SubnetType.PUBLIC),
vpc_connector_name="MyVpcConnector"
)
apprunner.Service(self, "Service",
source=apprunner.Source.from_ecr_public(
image_configuration=apprunner.ImageConfiguration(port=8000),
image_identifier="public.ecr.aws/aws-containers/hello-app-runner:latest"
),
vpc_connector=vpc_connector
)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/aws/aws-cdk",
"name": "aws-cdk.aws-apprunner",
"maintainer": "",
"docs_url": null,
"requires_python": "~=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Amazon Web Services",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/50/87/81bb1e795a564b99db4e71756e3f62917b4203d559bea2de281a6bc2a174/aws-cdk.aws-apprunner-1.203.0.tar.gz",
"platform": null,
"description": "# AWS::AppRunner Construct Library\n\n<!--BEGIN STABILITY BANNER-->---\n\n\n![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)\n\n> All classes with the `Cfn` prefix in this module ([CFN Resources](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) are always stable and safe to use.\n\n![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)\n\n> The APIs of higher level constructs in this module are experimental and under active development.\n> They are subject to non-backward compatible changes or removal in any future version. These are\n> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be\n> announced in the release notes. This means that while you may use them, you may need to update\n> your source code when upgrading to a newer version of this package.\n\n---\n<!--END STABILITY BANNER-->\n\nThis module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.\n\n```python\nimport aws_cdk.aws_apprunner as apprunner\n```\n\n## Introduction\n\nAWS 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.\n\n## Service\n\nThe `Service` construct allows you to create AWS App Runner services with `ECR Public`, `ECR` or `Github` with the `source` property in the following scenarios:\n\n* `Source.fromEcr()` - To define the source repository from `ECR`.\n* `Source.fromEcrPublic()` - To define the source repository from `ECR Public`.\n* `Source.fromGitHub()` - To define the source repository from the `Github repository`.\n* `Source.fromAsset()` - To define the source from local asset directory.\n\n## ECR Public\n\nTo create a `Service` with ECR Public:\n\n```python\napprunner.Service(self, \"Service\",\n source=apprunner.Source.from_ecr_public(\n image_configuration=apprunner.ImageConfiguration(port=8000),\n image_identifier=\"public.ecr.aws/aws-containers/hello-app-runner:latest\"\n )\n)\n```\n\n## ECR\n\nTo create a `Service` from an existing ECR repository:\n\n```python\nimport aws_cdk.aws_ecr as ecr\n\n\napprunner.Service(self, \"Service\",\n source=apprunner.Source.from_ecr(\n image_configuration=apprunner.ImageConfiguration(port=80),\n repository=ecr.Repository.from_repository_name(self, \"NginxRepository\", \"nginx\"),\n tag_or_digest=\"latest\"\n )\n)\n```\n\nTo create a `Service` from local docker image asset directory built and pushed to Amazon ECR:\n\n```python\nimport aws_cdk.aws_ecr_assets as assets\n\n\nimage_asset = assets.DockerImageAsset(self, \"ImageAssets\",\n directory=path.join(__dirname, \"./docker.assets\")\n)\napprunner.Service(self, \"Service\",\n source=apprunner.Source.from_asset(\n image_configuration=apprunner.ImageConfiguration(port=8000),\n asset=image_asset\n )\n)\n```\n\n## GitHub\n\nTo create a `Service` from the GitHub repository, you need to specify an existing App Runner `Connection`.\n\nSee [Managing App Runner connections](https://docs.aws.amazon.com/apprunner/latest/dg/manage-connections.html) for more details.\n\n```python\napprunner.Service(self, \"Service\",\n source=apprunner.Source.from_git_hub(\n repository_url=\"https://github.com/aws-containers/hello-app-runner\",\n branch=\"main\",\n configuration_source=apprunner.ConfigurationSourceType.REPOSITORY,\n connection=apprunner.GitHubConnection.from_connection_arn(\"CONNECTION_ARN\")\n )\n)\n```\n\nUse `codeConfigurationValues` to override configuration values with the `API` configuration source type.\n\n```python\napprunner.Service(self, \"Service\",\n source=apprunner.Source.from_git_hub(\n repository_url=\"https://github.com/aws-containers/hello-app-runner\",\n branch=\"main\",\n configuration_source=apprunner.ConfigurationSourceType.API,\n code_configuration_values=apprunner.CodeConfigurationValues(\n runtime=apprunner.Runtime.PYTHON_3,\n port=\"8000\",\n start_command=\"python app.py\",\n build_command=\"yum install -y pycairo && pip install -r requirements.txt\"\n ),\n connection=apprunner.GitHubConnection.from_connection_arn(\"CONNECTION_ARN\")\n )\n)\n```\n\n## IAM Roles\n\nYou are allowed to define `instanceRole` and `accessRole` for the `Service`.\n\n`instanceRole` - The IAM role that provides permissions to your App Runner service. These are permissions that\nyour code needs when it calls any AWS APIs.\n\n`accessRole` - The IAM role that grants the App Runner service access to a source repository. It's required for\nECR image repositories (but not for ECR Public repositories). If not defined, a new access role will be generated\nwhen required.\n\nSee [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.\n\n## VPC Connector\n\nTo associate an App Runner service with a custom VPC, define `vpcConnector` for the service.\n\n```python\nimport aws_cdk.aws_ec2 as ec2\n\n\nvpc = ec2.Vpc(self, \"Vpc\",\n cidr=\"10.0.0.0/16\"\n)\n\nvpc_connector = apprunner.VpcConnector(self, \"VpcConnector\",\n vpc=vpc,\n vpc_subnets=vpc.select_subnets(subnet_type=ec2.SubnetType.PUBLIC),\n vpc_connector_name=\"MyVpcConnector\"\n)\n\napprunner.Service(self, \"Service\",\n source=apprunner.Source.from_ecr_public(\n image_configuration=apprunner.ImageConfiguration(port=8000),\n image_identifier=\"public.ecr.aws/aws-containers/hello-app-runner:latest\"\n ),\n vpc_connector=vpc_connector\n)\n```\n\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "The CDK Construct Library for AWS::AppRunner",
"version": "1.203.0",
"project_urls": {
"Homepage": "https://github.com/aws/aws-cdk",
"Source": "https://github.com/aws/aws-cdk.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "79acb927a0d14a8e9a3a1404b78979fd417b8d964d961931b6af02089f97bbbc",
"md5": "e31e4cd4393e9d159f22e49f50f63249",
"sha256": "02701336e15709e874f9cc4dffbc0b3828aad170ed22a0813c2134fbbbe42cda"
},
"downloads": -1,
"filename": "aws_cdk.aws_apprunner-1.203.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e31e4cd4393e9d159f22e49f50f63249",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.7",
"size": 187959,
"upload_time": "2023-05-31T22:52:44",
"upload_time_iso_8601": "2023-05-31T22:52:44.653229Z",
"url": "https://files.pythonhosted.org/packages/79/ac/b927a0d14a8e9a3a1404b78979fd417b8d964d961931b6af02089f97bbbc/aws_cdk.aws_apprunner-1.203.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "508781bb1e795a564b99db4e71756e3f62917b4203d559bea2de281a6bc2a174",
"md5": "2bfd31984c2cba3a9c635dbe6e19fc34",
"sha256": "c9fdf0859e9d60728b19459c3bb686480ee94bedc244610738aab7d211314cce"
},
"downloads": -1,
"filename": "aws-cdk.aws-apprunner-1.203.0.tar.gz",
"has_sig": false,
"md5_digest": "2bfd31984c2cba3a9c635dbe6e19fc34",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.7",
"size": 188446,
"upload_time": "2023-05-31T23:00:42",
"upload_time_iso_8601": "2023-05-31T23:00:42.568713Z",
"url": "https://files.pythonhosted.org/packages/50/87/81bb1e795a564b99db4e71756e3f62917b4203d559bea2de281a6bc2a174/aws-cdk.aws-apprunner-1.203.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-31 23:00:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aws",
"github_project": "aws-cdk",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "aws-cdk.aws-apprunner"
}