package
1.204.0-devpreview
Repository: https://github.com/aws/aws-cdk-go.git
Documentation: pkg.go.dev

# README

AWS::AppRunner Construct Library

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

import apprunner "github.com/aws/aws-cdk-go/awscdk"

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:

apprunner.NewService(this, jsii.String("Service"), &ServiceProps{
	Source: apprunner.Source_FromEcrPublic(&EcrPublicProps{
		ImageConfiguration: &ImageConfiguration{
			Port: jsii.Number(8000),
		},
		ImageIdentifier: jsii.String("public.ecr.aws/aws-containers/hello-app-runner:latest"),
	}),
})

ECR

To create a Service from an existing ECR repository:

import ecr "github.com/aws/aws-cdk-go/awscdk"


apprunner.NewService(this, jsii.String("Service"), &ServiceProps{
	Source: apprunner.Source_FromEcr(&EcrProps{
		ImageConfiguration: &ImageConfiguration{
			Port: jsii.Number(80),
		},
		Repository: ecr.Repository_FromRepositoryName(this, jsii.String("NginxRepository"), jsii.String("nginx")),
		TagOrDigest: jsii.String("latest"),
	}),
})

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

import assets "github.com/aws/aws-cdk-go/awscdk"


imageAsset := assets.NewDockerImageAsset(this, jsii.String("ImageAssets"), &DockerImageAssetProps{
	Directory: path.join(__dirname, jsii.String("./docker.assets")),
})
apprunner.NewService(this, jsii.String("Service"), &ServiceProps{
	Source: apprunner.Source_FromAsset(&AssetProps{
		ImageConfiguration: &ImageConfiguration{
			Port: jsii.Number(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.

apprunner.NewService(this, jsii.String("Service"), &ServiceProps{
	Source: apprunner.Source_FromGitHub(&GithubRepositoryProps{
		RepositoryUrl: jsii.String("https://github.com/aws-containers/hello-app-runner"),
		Branch: jsii.String("main"),
		ConfigurationSource: apprunner.ConfigurationSourceType_REPOSITORY,
		Connection: apprunner.GitHubConnection_FromConnectionArn(jsii.String("CONNECTION_ARN")),
	}),
})

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

apprunner.NewService(this, jsii.String("Service"), &ServiceProps{
	Source: apprunner.Source_FromGitHub(&GithubRepositoryProps{
		RepositoryUrl: jsii.String("https://github.com/aws-containers/hello-app-runner"),
		Branch: jsii.String("main"),
		ConfigurationSource: apprunner.ConfigurationSourceType_API,
		CodeConfigurationValues: &CodeConfigurationValues{
			Runtime: apprunner.Runtime_PYTHON_3(),
			Port: jsii.String("8000"),
			StartCommand: jsii.String("python app.py"),
			BuildCommand: jsii.String("yum install -y pycairo && pip install -r requirements.txt"),
		},
		Connection: apprunner.GitHubConnection_FromConnectionArn(jsii.String("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.

VPC Connector

To associate an App Runner service with a custom VPC, define vpcConnector for the service.

import "github.com/aws/aws-cdk-go/awscdk"


vpc := ec2.NewVpc(this, jsii.String("Vpc"), &VpcProps{
	Cidr: jsii.String("10.0.0.0/16"),
})

vpcConnector := apprunner.NewVpcConnector(this, jsii.String("VpcConnector"), &VpcConnectorProps{
	Vpc: Vpc,
	VpcSubnets: vpc.selectSubnets(&SubnetSelection{
		SubnetType: ec2.SubnetType_PUBLIC,
	}),
	VpcConnectorName: jsii.String("MyVpcConnector"),
})

apprunner.NewService(this, jsii.String("Service"), &ServiceProps{
	Source: apprunner.Source_FromEcrPublic(&EcrPublicProps{
		ImageConfiguration: &ImageConfiguration{
			Port: jsii.Number(8000),
		},
		ImageIdentifier: jsii.String("public.ecr.aws/aws-containers/hello-app-runner:latest"),
	}),
	VpcConnector: VpcConnector,
})

# Functions

Source from local assets.
Source from the ECR repository.
Source from the ECR Public repository.
Source from the GitHub repository.
No description provided by the author
Returns `true` if a construct is a stack element (i.e.
Check whether the given construct is a CfnResource.
Return whether the given object is a Construct.
No description provided by the author
Returns `true` if a construct is a stack element (i.e.
Check whether the given construct is a CfnResource.
Return whether the given object is a Construct.
No description provided by the author
Returns `true` if a construct is a stack element (i.e.
Check whether the given construct is a CfnResource.
Return whether the given object is a Construct.
No description provided by the author
Returns `true` if a construct is a stack element (i.e.
Check whether the given construct is a CfnResource.
Return whether the given object is a Construct.
Custom CPU unit.
No description provided by the author
No description provided by the author
Source from local assets.
Source from the ECR repository.
Source from the ECR Public repository.
Source from the GitHub repository.
Source from local assets.
Source from the ECR repository.
Source from the ECR Public repository.
Source from the GitHub repository.
Using existing App Runner connection by specifying the connection ARN.
Source from local assets.
Source from the ECR repository.
Source from the ECR Public repository.
Source from the GitHub repository.
No description provided by the author
Custom Memory unit.
No description provided by the author
No description provided by the author
Experimental.
Experimental.
Create a new `AWS::AppRunner::ObservabilityConfiguration`.
Create a new `AWS::AppRunner::ObservabilityConfiguration`.
Create a new `AWS::AppRunner::Service`.
Create a new `AWS::AppRunner::Service`.
Create a new `AWS::AppRunner::VpcConnector`.
Create a new `AWS::AppRunner::VpcConnector`.
Create a new `AWS::AppRunner::VpcIngressConnection`.
Create a new `AWS::AppRunner::VpcIngressConnection`.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
No description provided by the author
Other runtimes.
No description provided by the author
Import from service attributes.
Import from service name.
Return whether the given object is a Construct.
Check whether the given construct is a Resource.
Source from local assets.
Source from the ECR repository.
Source from the ECR Public repository.
Source from the GitHub repository.
Import from VPC connector attributes.
Return whether the given object is a Construct.
Check whether the given construct is a Resource.

# Constants

App Runner uses configuration values provided in `configurationValues` and ignores the `apprunner.yaml` file in the source code repository.
App Runner reads configuration values from `the apprunner.yaml` file in the source code repository and ignores `configurationValues`.
Amazon ECR.
Amazon ECR Public.

# Structs

Properties of the image repository for `Source.fromAsset()`.
Describes the configuration of the tracing feature within an AWS App Runner observability configuration.
Properties for defining a `CfnObservabilityConfiguration`.
Describes resources needed to authenticate access to some source repositories.
Describes the configuration that AWS App Runner uses to build and run an App Runner service from a source code repository.
Describes the basic configuration needed for building and running an AWS App Runner service.
Describes a source code repository.
Describes configuration settings related to outbound network traffic of an AWS App Runner service.
Describes a custom encryption key that AWS App Runner uses to encrypt copies of the source repository and service logs.
Describes the settings for the health check that AWS App Runner performs to monitor the health of a service.
Describes the configuration that AWS App Runner uses to run an App Runner service using an image pulled from a source image repository.
Describes a source image repository.
Network configuration settings for inbound network traffic.
Describes the runtime configuration of an AWS App Runner service instance (scaling unit).
Describes a key-value pair, which is a string-to-string mapping.
Describes configuration settings related to network traffic of an AWS App Runner service.
Describes the observability configuration of an AWS App Runner service.
Identifies a version of code that AWS App Runner refers to within a source code repository.
Describes the source deployed to an AWS App Runner service.
Properties for defining a `CfnService`.
Properties for defining a `CfnVpcConnector`.
Specifications for the customer’s VPC and related PrivateLink VPC endpoint that are used to associate with the VPC Ingress Connection resource.
Properties for defining a `CfnVpcIngressConnection`.
Describes the configuration that AWS App Runner uses to build and run an App Runner service from a source code repository.
Describes the basic configuration needed for building and running an AWS App Runner service.
Properties of the CodeRepository.
Properties of the image repository for `Source.fromEcr()`.
Properties of the image repository for `Source.fromEcrPublic()`.
Properties of the Github repository for `Source.fromGitHub()`.
Describes the configuration that AWS App Runner uses to run an App Runner service using an image pulled from a source image repository.
Describes a source image repository.
Attributes for the App Runner Service.
Properties of the AppRunner Service.
Identifies a version of code that AWS App Runner refers to within a source code repository.
Result of binding `Source` into a `Service`.
Attributes for the App Runner VPC Connector.
Properties of the AppRunner VPC Connector.

# Interfaces

Represents the source from local assets.
A CloudFormation `AWS::AppRunner::ObservabilityConfiguration`.
A CloudFormation `AWS::AppRunner::Service`.
A CloudFormation `AWS::AppRunner::VpcConnector`.
A CloudFormation `AWS::AppRunner::VpcIngressConnection`.
The number of CPU units reserved for each instance of your App Runner service.
Represents the service source from ECR Public.
Represents the service source from ECR.
Represents the App Runner connection that enables the App Runner service to connect to a source repository.
Represents the service source from a Github repository.
Represents the App Runner Service.
Represents the App Runner VPC Connector.
The amount of memory reserved for each instance of your App Runner service.
The code runtimes.
The App Runner Service.
Represents the App Runner service source.
The App Runner VPC Connector.

# Type aliases

The source of the App Runner configuration.
The image repository types.