AWS CDK App Runner Alpha

raw JSON →
2.251.0a0 verified Mon Apr 27 auth: no python

Alpha version of the CDK Construct Library for AWS App Runner, allowing deployment of containerized web applications and APIs. Current version 2.251.0a0, release follows CDK releases.

pip install aws-cdk-aws-apprunner-alpha
error ModuleNotFoundError: No module named 'aws_cdk.aws_apprunner_alpha'
cause Package not installed or wrong Python environment.
fix
pip install aws-cdk-aws-apprunner-alpha
error jsii.errors.JSIIError: Expected a value of type @aws-cdk/aws-apprunner-alpha.Service but received ...
cause Mixing constructs from different CDK versions.
fix
Ensure all CDK packages (aws-cdk-lib, aws-cdk-aws-apprunner-alpha) are the same version.
error TypeError: __init__() got an unexpected keyword argument 'source'
cause Using an older version that used 'source_configuration' instead of 'source'.
fix
Upgrade to latest version: pip install --upgrade aws-cdk-aws-apprunner-alpha
breaking Module prefix changed from @aws-cdk/aws-apprunner-alpha to aws-cdk-aws-apprunner-alpha in v2.
fix Use pip install aws-cdk-aws-apprunner-alpha instead of @aws-cdk/aws-apprunner-alpha.
breaking Construct path changed: now under aws_cdk.aws_apprunner_alpha (lowercase, underscore) vs previous aws_cdk.aws_apprunner (no alpha suffix, different casing).
fix Update imports to from aws_cdk.aws_apprunner_alpha import ...
gotcha Alpha modules are not subject to semantic versioning and may have breaking changes in minor releases.
fix Pin exact version in requirements.txt and review changelog before upgrading.
gotcha Source.from_asset() expects a dictionary with 'location' and 'source_code_provider' keys; ordering of arguments is strict.
fix Always pass keyword arguments: source=Source.from_asset({...})

Minimal CDK stack creating an App Runner service from a GitHub repository.

import aws_cdk as cdk
from aws_cdk.aws_apprunner_alpha import AppRunnerService, Source, SourceCodeBuild

class MyStack(cdk.Stack):
    def __init__(self, scope, id, **kwargs):
        super().__init__(scope, id, **kwargs)
        AppRunnerService(self, 'Service',
            source=Source.from_asset({
                'location': './app',
                'source_code_provider': SourceCodeBuild({
                    'repository': 'https://github.com/example/repo',
                    'branch': 'main'
                })
            })
        )

app = cdk.App()
MyStack(app, 'MyAppRunnerStack')
app.synth()