awscdkapprunneralpha

package module
v2.8.0-alpha.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

AWS::AppRunner Construct Library


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 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.


This module is part of the AWS Cloud Development Kit project.

import * as apprunner from '@aws-cdk/aws-apprunner-alpha';

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:

new apprunner.Service(this, 'Service', {
  source: apprunner.Source.fromEcrPublic({
    imageConfiguration: { port: 8000 },
    imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
  }),
});

ECR

To create a Service from an existing ECR repository:

import * as ecr from 'aws-cdk-lib/aws-ecr';

new apprunner.Service(this, 'Service', {
  source: apprunner.Source.fromEcr({
    imageConfiguration: { port: 80 },
    repository: ecr.Repository.fromRepositoryName(this, 'NginxRepository', 'nginx'),
    tag: 'latest',
  }),
});

To create a Service from local docker image asset directory built and pushed to Amazon ECR:

import * as assets from 'aws-cdk-lib/aws-ecr-assets';

const imageAsset = new assets.DockerImageAsset(this, 'ImageAssets', {
  directory: path.join(__dirname, './docker.assets'),
});
new apprunner.Service(this, 'Service', {
  source: apprunner.Source.fromAsset({
    imageConfiguration: { port: 8000 },
    asset: imageAsset,
  }),
});

GitHub

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

See Managing App Runner connections for more details.

new apprunner.Service(this, 'Service', {
  source: apprunner.Source.fromGitHub({
    repositoryUrl: 'https://github.com/aws-containers/hello-app-runner',
    branch: 'main',
    configurationSource: apprunner.ConfigurationSourceType.REPOSITORY,
    connection: apprunner.GitHubConnection.fromConnectionArn('CONNECTION_ARN'),
  }),
});

Use codeConfigurationValues to override configuration values with the API configuration source type.

new apprunner.Service(this, 'Service', {
  source: apprunner.Source.fromGitHub({
    repositoryUrl: 'https://github.com/aws-containers/hello-app-runner',
    branch: 'main',
    configurationSource: apprunner.ConfigurationSourceType.API,
    codeConfigurationValues: {
      runtime: apprunner.Runtime.PYTHON_3,
      port: '8000',
      startCommand: 'python app.py',
      buildCommand: 'yum install -y pycairo && pip install -r requirements.txt',
    },
    connection: apprunner.GitHubConnection.fromConnectionArn('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 for more details.

Documentation

Overview

The CDK Construct Library for AWS::AppRunner

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAssetSource_Override

func NewAssetSource_Override(a AssetSource, props *AssetProps)

Experimental.

func NewEcrPublicSource_Override

func NewEcrPublicSource_Override(e EcrPublicSource, props *EcrPublicProps)

Experimental.

func NewEcrSource_Override

func NewEcrSource_Override(e EcrSource, props *EcrProps)

Experimental.

func NewGitHubConnection_Override

func NewGitHubConnection_Override(g GitHubConnection, arn *string)

Experimental.

func NewGithubSource_Override

func NewGithubSource_Override(g GithubSource, props *GithubRepositoryProps)

Experimental.

func NewService_Override

func NewService_Override(s Service, scope constructs.Construct, id *string, props *ServiceProps)

Experimental.

func NewSource_Override

func NewSource_Override(s Source)

Experimental.

func Service_IsConstruct

func Service_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead

func Service_IsResource

func Service_IsResource(construct constructs.IConstruct) *bool

Check whether the given construct is a Resource. Experimental.

Types

type AssetProps

type AssetProps struct {
	// Represents the docker image asset.
	// Experimental.
	Asset awsecrassets.DockerImageAsset `json:"asset" yaml:"asset"`
	// The image configuration for the image built from the asset.
	// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-imageconfiguration.html#cfn-apprunner-service-imageconfiguration-port
	//
	// Experimental.
	ImageConfiguration *ImageConfiguration `json:"imageConfiguration" yaml:"imageConfiguration"`
}

Properties of the image repository for `Source.fromAsset()`.

TODO: EXAMPLE

Experimental.

type AssetSource

type AssetSource interface {
	Source
	Bind(_scope constructs.Construct) *SourceConfig
}

Represents the source from local assets.

TODO: EXAMPLE

Experimental.

func AssetSource_FromAsset

func AssetSource_FromAsset(props *AssetProps) AssetSource

Source from local assets. Experimental.

func EcrPublicSource_FromAsset

func EcrPublicSource_FromAsset(props *AssetProps) AssetSource

Source from local assets. Experimental.

func EcrSource_FromAsset

func EcrSource_FromAsset(props *AssetProps) AssetSource

Source from local assets. Experimental.

func GithubSource_FromAsset

func GithubSource_FromAsset(props *AssetProps) AssetSource

Source from local assets. Experimental.

func NewAssetSource

func NewAssetSource(props *AssetProps) AssetSource

Experimental.

func Source_FromAsset

func Source_FromAsset(props *AssetProps) AssetSource

Source from local assets. Experimental.

type CodeConfiguration

type CodeConfiguration struct {
	// The source of the App Runner configuration.
	// Experimental.
	ConfigurationSource ConfigurationSourceType `json:"configurationSource" yaml:"configurationSource"`
	// The basic configuration for building and running the App Runner service.
	//
	// Use it to quickly launch an App Runner service without providing a apprunner.yaml file in the
	// source code repository (or ignoring the file if it exists).
	// Experimental.
	ConfigurationValues *CodeConfigurationValues `json:"configurationValues" yaml:"configurationValues"`
}

Describes the configuration that AWS App Runner uses to build and run an App Runner service from a source code repository.

TODO: EXAMPLE

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-codeconfiguration.html

Experimental.

type CodeConfigurationValues

type CodeConfigurationValues struct {
	// A runtime environment type for building and running an App Runner service.
	//
	// It represents
	// a programming language runtime.
	// Experimental.
	Runtime Runtime `json:"runtime" yaml:"runtime"`
	// The command App Runner runs to build your application.
	// Experimental.
	BuildCommand *string `json:"buildCommand" yaml:"buildCommand"`
	// The environment variables that are available to your running App Runner service.
	// Experimental.
	Environment *map[string]*string `json:"environment" yaml:"environment"`
	// The port that your application listens to in the container.
	// Experimental.
	Port *string `json:"port" yaml:"port"`
	// The command App Runner runs to start your application.
	// Experimental.
	StartCommand *string `json:"startCommand" yaml:"startCommand"`
}

Describes the basic configuration needed for building and running an AWS App Runner service.

This type doesn't support the full set of possible configuration options. Fur full configuration capabilities, use a `apprunner.yaml` file in the source code repository.

TODO: EXAMPLE

Experimental.

type CodeRepositoryProps

type CodeRepositoryProps struct {
	// Configuration for building and running the service from a source code repository.
	// Experimental.
	CodeConfiguration *CodeConfiguration `json:"codeConfiguration" yaml:"codeConfiguration"`
	// The App Runner connection for GitHub.
	// Experimental.
	Connection GitHubConnection `json:"connection" yaml:"connection"`
	// The location of the repository that contains the source code.
	// Experimental.
	RepositoryUrl *string `json:"repositoryUrl" yaml:"repositoryUrl"`
	// The version that should be used within the source code repository.
	// Experimental.
	SourceCodeVersion *SourceCodeVersion `json:"sourceCodeVersion" yaml:"sourceCodeVersion"`
}

Properties of the CodeRepository.

TODO: EXAMPLE

Experimental.

type ConfigurationSourceType

type ConfigurationSourceType string

The source of the App Runner configuration.

TODO: EXAMPLE

Experimental.

const (
	ConfigurationSourceType_REPOSITORY ConfigurationSourceType = "REPOSITORY"
	ConfigurationSourceType_API        ConfigurationSourceType = "API"
)

type Cpu

type Cpu interface {
	Unit() *string
}

The number of CPU units reserved for each instance of your App Runner service.

TODO: EXAMPLE

Experimental.

func Cpu_ONE_VCPU

func Cpu_ONE_VCPU() Cpu

func Cpu_TWO_VCPU

func Cpu_TWO_VCPU() Cpu

type EcrProps

type EcrProps struct {
	// Represents the ECR repository.
	// Experimental.
	Repository awsecr.IRepository `json:"repository" yaml:"repository"`
	// The image configuration for the image from ECR.
	// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-imageconfiguration.html#cfn-apprunner-service-imageconfiguration-port
	//
	// Experimental.
	ImageConfiguration *ImageConfiguration `json:"imageConfiguration" yaml:"imageConfiguration"`
	// Image tag.
	// Experimental.
	Tag *string `json:"tag" yaml:"tag"`
}

Properties of the image repository for `Source.fromEcr()`.

TODO: EXAMPLE

Experimental.

type EcrPublicProps

type EcrPublicProps struct {
	// The ECR Public image URI.
	// Experimental.
	ImageIdentifier *string `json:"imageIdentifier" yaml:"imageIdentifier"`
	// The image configuration for the image from ECR Public.
	// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-imageconfiguration.html#cfn-apprunner-service-imageconfiguration-port
	//
	// Experimental.
	ImageConfiguration *ImageConfiguration `json:"imageConfiguration" yaml:"imageConfiguration"`
}

Properties of the image repository for `Source.fromEcrPublic()`.

TODO: EXAMPLE

Experimental.

type EcrPublicSource

type EcrPublicSource interface {
	Source
	Bind(_scope constructs.Construct) *SourceConfig
}

Represents the service source from ECR Public.

TODO: EXAMPLE

Experimental.

func AssetSource_FromEcrPublic

func AssetSource_FromEcrPublic(props *EcrPublicProps) EcrPublicSource

Source from the ECR Public repository. Experimental.

func EcrPublicSource_FromEcrPublic

func EcrPublicSource_FromEcrPublic(props *EcrPublicProps) EcrPublicSource

Source from the ECR Public repository. Experimental.

func EcrSource_FromEcrPublic

func EcrSource_FromEcrPublic(props *EcrPublicProps) EcrPublicSource

Source from the ECR Public repository. Experimental.

func GithubSource_FromEcrPublic

func GithubSource_FromEcrPublic(props *EcrPublicProps) EcrPublicSource

Source from the ECR Public repository. Experimental.

func NewEcrPublicSource

func NewEcrPublicSource(props *EcrPublicProps) EcrPublicSource

Experimental.

func Source_FromEcrPublic

func Source_FromEcrPublic(props *EcrPublicProps) EcrPublicSource

Source from the ECR Public repository. Experimental.

type EcrSource

type EcrSource interface {
	Source
	Bind(_scope constructs.Construct) *SourceConfig
}

Represents the service source from ECR.

TODO: EXAMPLE

Experimental.

func AssetSource_FromEcr

func AssetSource_FromEcr(props *EcrProps) EcrSource

Source from the ECR repository. Experimental.

func EcrPublicSource_FromEcr

func EcrPublicSource_FromEcr(props *EcrProps) EcrSource

Source from the ECR repository. Experimental.

func EcrSource_FromEcr

func EcrSource_FromEcr(props *EcrProps) EcrSource

Source from the ECR repository. Experimental.

func GithubSource_FromEcr

func GithubSource_FromEcr(props *EcrProps) EcrSource

Source from the ECR repository. Experimental.

func NewEcrSource

func NewEcrSource(props *EcrProps) EcrSource

Experimental.

func Source_FromEcr

func Source_FromEcr(props *EcrProps) EcrSource

Source from the ECR repository. Experimental.

type GitHubConnection

type GitHubConnection interface {
	ConnectionArn() *string
}

Represents the App Runner connection that enables the App Runner service to connect to a source repository.

It's required for GitHub code repositories.

TODO: EXAMPLE

Experimental.

func GitHubConnection_FromConnectionArn

func GitHubConnection_FromConnectionArn(arn *string) GitHubConnection

Using existing App Runner connection by specifying the connection ARN.

Returns: Connection Experimental.

func NewGitHubConnection

func NewGitHubConnection(arn *string) GitHubConnection

Experimental.

type GithubRepositoryProps

type GithubRepositoryProps struct {
	// The source of the App Runner configuration.
	// Experimental.
	ConfigurationSource ConfigurationSourceType `json:"configurationSource" yaml:"configurationSource"`
	// ARN of the connection to Github.
	//
	// Only required for Github source.
	// Experimental.
	Connection GitHubConnection `json:"connection" yaml:"connection"`
	// The location of the repository that contains the source code.
	// Experimental.
	RepositoryUrl *string `json:"repositoryUrl" yaml:"repositoryUrl"`
	// The branch name that represents a specific version for the repository.
	// Experimental.
	Branch *string `json:"branch" yaml:"branch"`
	// The code configuration values.
	//
	// Will be ignored if configurationSource is `REPOSITORY`.
	// Experimental.
	CodeConfigurationValues *CodeConfigurationValues `json:"codeConfigurationValues" yaml:"codeConfigurationValues"`
}

Properties of the Github repository for `Source.fromGitHub()`.

TODO: EXAMPLE

Experimental.

type GithubSource

type GithubSource interface {
	Source
	Bind(_scope constructs.Construct) *SourceConfig
}

Represents the service source from a Github repository.

TODO: EXAMPLE

Experimental.

func AssetSource_FromGitHub

func AssetSource_FromGitHub(props *GithubRepositoryProps) GithubSource

Source from the GitHub repository. Experimental.

func EcrPublicSource_FromGitHub

func EcrPublicSource_FromGitHub(props *GithubRepositoryProps) GithubSource

Source from the GitHub repository. Experimental.

func EcrSource_FromGitHub

func EcrSource_FromGitHub(props *GithubRepositoryProps) GithubSource

Source from the GitHub repository. Experimental.

func GithubSource_FromGitHub

func GithubSource_FromGitHub(props *GithubRepositoryProps) GithubSource

Source from the GitHub repository. Experimental.

func NewGithubSource

func NewGithubSource(props *GithubRepositoryProps) GithubSource

Experimental.

func Source_FromGitHub

func Source_FromGitHub(props *GithubRepositoryProps) GithubSource

Source from the GitHub repository. Experimental.

type IService

type IService interface {
	awscdk.IResource
	// The ARN of the service.
	// Experimental.
	ServiceArn() *string
	// The Name of the service.
	// Experimental.
	ServiceName() *string
}

Represents the App Runner Service. Experimental.

func Service_FromServiceAttributes

func Service_FromServiceAttributes(scope constructs.Construct, id *string, attrs *ServiceAttributes) IService

Import from service attributes. Experimental.

func Service_FromServiceName

func Service_FromServiceName(scope constructs.Construct, id *string, serviceName *string) IService

Import from service name. Experimental.

type ImageConfiguration

type ImageConfiguration struct {
	// Environment variables that are available to your running App Runner service.
	// Experimental.
	Environment *map[string]*string `json:"environment" yaml:"environment"`
	// The port that your application listens to in the container.
	// Experimental.
	Port *float64 `json:"port" yaml:"port"`
	// An optional command that App Runner runs to start the application in the source image.
	//
	// If specified, this command overrides the Docker image’s default start command.
	// Experimental.
	StartCommand *string `json:"startCommand" yaml:"startCommand"`
}

Describes the configuration that AWS App Runner uses to run an App Runner service using an image pulled from a source image repository.

TODO: EXAMPLE

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-imageconfiguration.html

Experimental.

type ImageRepository

type ImageRepository struct {
	// The identifier of the image.
	//
	// For `ECR_PUBLIC` imageRepositoryType, the identifier domain should
	// always be `public.ecr.aws`. For `ECR`, the pattern should be
	// `([0-9]{12}.dkr.ecr.[a-z\-]+-[0-9]{1}.amazonaws.com\/.*)`.
	// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-imagerepository.html for more details.
	//
	// Experimental.
	ImageIdentifier *string `json:"imageIdentifier" yaml:"imageIdentifier"`
	// The type of the image repository.
	//
	// This reflects the repository provider and whether
	// the repository is private or public.
	// Experimental.
	ImageRepositoryType ImageRepositoryType `json:"imageRepositoryType" yaml:"imageRepositoryType"`
	// Configuration for running the identified image.
	// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-imageconfiguration.html#cfn-apprunner-service-imageconfiguration-port
	//
	// Experimental.
	ImageConfiguration *ImageConfiguration `json:"imageConfiguration" yaml:"imageConfiguration"`
}

Describes a source image repository.

TODO: EXAMPLE

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-imagerepository.html

Experimental.

type ImageRepositoryType

type ImageRepositoryType string

The image repository types. Experimental.

const (
	ImageRepositoryType_ECR_PUBLIC ImageRepositoryType = "ECR_PUBLIC"
	ImageRepositoryType_ECR        ImageRepositoryType = "ECR"
)

type Memory

type Memory interface {
	Unit() *string
}

The amount of memory reserved for each instance of your App Runner service.

TODO: EXAMPLE

Experimental.

func Memory_FOUR_GB

func Memory_FOUR_GB() Memory

func Memory_THREE_GB

func Memory_THREE_GB() Memory

func Memory_TWO_GB

func Memory_TWO_GB() Memory

type Runtime

type Runtime interface {
	Name() *string
}

The code runtimes.

TODO: EXAMPLE

Experimental.

func Runtime_NODEJS_12

func Runtime_NODEJS_12() Runtime

func Runtime_PYTHON_3

func Runtime_PYTHON_3() Runtime

type Service

type Service interface {
	awscdk.Resource
	Env() *awscdk.ResourceEnvironment
	Node() constructs.Node
	PhysicalName() *string
	ServiceArn() *string
	ServiceId() *string
	ServiceName() *string
	ServiceStatus() *string
	ServiceUrl() *string
	Stack() awscdk.Stack
	ApplyRemovalPolicy(policy awscdk.RemovalPolicy)
	GeneratePhysicalName() *string
	GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string
	GetResourceNameAttribute(nameAttr *string) *string
	ToString() *string
}

The App Runner Service.

TODO: EXAMPLE

Experimental.

func NewService

func NewService(scope constructs.Construct, id *string, props *ServiceProps) Service

Experimental.

type ServiceAttributes

type ServiceAttributes struct {
	// The ARN of the service.
	// Experimental.
	ServiceArn *string `json:"serviceArn" yaml:"serviceArn"`
	// The name of the service.
	// Experimental.
	ServiceName *string `json:"serviceName" yaml:"serviceName"`
	// The status of the service.
	// Experimental.
	ServiceStatus *string `json:"serviceStatus" yaml:"serviceStatus"`
	// The URL of the service.
	// Experimental.
	ServiceUrl *string `json:"serviceUrl" yaml:"serviceUrl"`
}

Attributes for the App Runner Service.

TODO: EXAMPLE

Experimental.

type ServiceProps

type ServiceProps struct {
	// The source of the repository for the service.
	// Experimental.
	Source Source `json:"source" yaml:"source"`
	// 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).
	//
	// The role must be assumable by the 'build.apprunner.amazonaws.com' service principal.
	// See: https://docs.aws.amazon.com/apprunner/latest/dg/security_iam_service-with-iam.html#security_iam_service-with-iam-roles-service.access
	//
	// Experimental.
	AccessRole awsiam.IRole `json:"accessRole" yaml:"accessRole"`
	// The number of CPU units reserved for each instance of your App Runner service.
	// Experimental.
	Cpu Cpu `json:"cpu" yaml:"cpu"`
	// The IAM role that provides permissions to your App Runner service.
	//
	// These are permissions that your code needs when it calls any AWS APIs.
	//
	// The role must be assumable by the 'tasks.apprunner.amazonaws.com' service principal.
	// See: https://docs.aws.amazon.com/apprunner/latest/dg/security_iam_service-with-iam.html#security_iam_service-with-iam-roles-service.instance
	//
	// Experimental.
	InstanceRole awsiam.IRole `json:"instanceRole" yaml:"instanceRole"`
	// The amount of memory reserved for each instance of your App Runner service.
	// Experimental.
	Memory Memory `json:"memory" yaml:"memory"`
	// Name of the service.
	// Experimental.
	ServiceName *string `json:"serviceName" yaml:"serviceName"`
}

Properties of the AppRunner Service.

TODO: EXAMPLE

Experimental.

type Source

type Source interface {
	Bind(scope constructs.Construct) *SourceConfig
}

Represents the App Runner service source.

TODO: EXAMPLE

Experimental.

type SourceCodeVersion

type SourceCodeVersion struct {
	// The type of version identifier.
	// Experimental.
	Type *string `json:"type" yaml:"type"`
	// A source code version.
	// Experimental.
	Value *string `json:"value" yaml:"value"`
}

Identifies a version of code that AWS App Runner refers to within a source code repository.

TODO: EXAMPLE

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-sourcecodeversion.html

Experimental.

type SourceConfig

type SourceConfig struct {
	// The code repository configuration (mutually exclusive  with `imageRepository`).
	// Experimental.
	CodeRepository *CodeRepositoryProps `json:"codeRepository" yaml:"codeRepository"`
	// The ECR repository (required to grant the pull privileges for the iam role).
	// Experimental.
	EcrRepository awsecr.IRepository `json:"ecrRepository" yaml:"ecrRepository"`
	// The image repository configuration (mutually exclusive  with `codeRepository`).
	// Experimental.
	ImageRepository *ImageRepository `json:"imageRepository" yaml:"imageRepository"`
}

Result of binding `Source` into a `Service`.

TODO: EXAMPLE

Experimental.

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL