@aws-cdk_aws-apprunner-alpha.Service

class Service (construct) ๐Ÿ”น

LanguageType name
.NETAmazon.CDK.AWS.AppRunner.Alpha.Service
Gogithub.com/aws/aws-cdk-go/awscdkapprunneralpha/v2#Service
Javasoftware.amazon.awscdk.services.apprunner.alpha.Service
Pythonaws_cdk.aws_apprunner_alpha.Service
TypeScript (source)@aws-cdk/aws-apprunner-alpha ยป Service

Implements IConstruct, IDependable, IResource

The App Runner Service.

Example

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'),
  }),
});

Initializer

new Service(scope: Construct, id: string, props: ServiceProps)

Parameters

  • scope Construct
  • id string
  • props ServiceProps

Construct Props

NameTypeDescription
source๐Ÿ”นSourceThe source of the repository for the service.
accessRole?๐Ÿ”นIRoleThe IAM role that grants the App Runner service access to a source repository.
autoDeploymentsEnabled?๐Ÿ”นbooleanSpecifies whether to enable continuous integration from the source repository.
cpu?๐Ÿ”นCpuThe number of CPU units reserved for each instance of your App Runner service.
instanceRole?๐Ÿ”นIRoleThe IAM role that provides permissions to your App Runner service.
memory?๐Ÿ”นMemoryThe amount of memory reserved for each instance of your App Runner service.
serviceName?๐Ÿ”นstringName of the service.
vpcConnector?๐Ÿ”นIVpcConnectorSettings for an App Runner VPC connector to associate with the service.

source๐Ÿ”น

Type: Source

The source of the repository for the service.


accessRole?๐Ÿ”น

Type: IRole (optional, default: generate a new access role.)

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 also: https://docs.aws.amazon.com/apprunner/latest/dg/security_iam_service-with-iam.html#security_iam_service-with-iam-roles-service.access


autoDeploymentsEnabled?๐Ÿ”น

Type: boolean (optional, default: no value will be passed.)

Specifies whether to enable continuous integration from the source repository.

If true, continuous integration from the source repository is enabled for the App Runner service. Each repository change (including any source code commit or new image version) starts a deployment. By default, App Runner sets to false for a source image that uses an ECR Public repository or an ECR repository that's in an AWS account other than the one that the service is in. App Runner sets to true in all other cases (which currently include a source code repository or a source image using a same-account ECR repository).


cpu?๐Ÿ”น

Type: Cpu (optional, default: Cpu.ONE_VCPU)

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


instanceRole?๐Ÿ”น

Type: IRole (optional, default: no instance role attached.)

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 also: https://docs.aws.amazon.com/apprunner/latest/dg/security_iam_service-with-iam.html#security_iam_service-with-iam-roles-service.instance


memory?๐Ÿ”น

Type: Memory (optional, default: Memory.TWO_GB)

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


serviceName?๐Ÿ”น

Type: string (optional, default: auto-generated if undefined.)

Name of the service.


vpcConnector?๐Ÿ”น

Type: IVpcConnector (optional, default: no VPC connector, uses the DEFAULT egress type instead)

Settings for an App Runner VPC connector to associate with the service.

Properties

NameTypeDescription
env๐Ÿ”นResourceEnvironmentThe environment this resource belongs to.
environmentโš ๏ธ{ [string]: string }Environment variables for this service.
node๐Ÿ”นNodeThe tree node.
serviceArn๐Ÿ”นstringThe ARN of the Service.
serviceId๐Ÿ”นstringThe ID of the Service.
serviceName๐Ÿ”นstringThe name of the service.
serviceStatus๐Ÿ”นstringThe status of the Service.
serviceUrl๐Ÿ”นstringThe URL of the Service.
stack๐Ÿ”นStackThe stack in which this resource is defined.

env๐Ÿ”น

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


environmentโš ๏ธ

โš ๏ธ Deprecated: use environmentVariables.

Type: { [string]: string }

Environment variables for this service.


node๐Ÿ”น

Type: Node

The tree node.


serviceArn๐Ÿ”น

Type: string

The ARN of the Service.


serviceId๐Ÿ”น

Type: string

The ID of the Service.


serviceName๐Ÿ”น

Type: string

The name of the service.


serviceStatus๐Ÿ”น

Type: string

The status of the Service.


serviceUrl๐Ÿ”น

Type: string

The URL of the Service.


stack๐Ÿ”น

Type: Stack

The stack in which this resource is defined.

Methods

NameDescription
addEnvironmentVariable(name, value)๐Ÿ”นThis method adds an environment variable to the App Runner service.
addSecret(name, secret)๐Ÿ”นThis method adds a secret as environment variable to the App Runner service.
applyRemovalPolicy(policy)๐Ÿ”นApply the given removal policy to this resource.
toString()๐Ÿ”นReturns a string representation of this construct.
static fromServiceAttributes(scope, id, attrs)๐Ÿ”นImport from service attributes.
static fromServiceName(scope, id, serviceName)๐Ÿ”นImport from service name.

addEnvironmentVariable(name, value)๐Ÿ”น

public addEnvironmentVariable(name: string, value: string): void

Parameters

  • name string
  • value string

This method adds an environment variable to the App Runner service.


addSecret(name, secret)๐Ÿ”น

public addSecret(name: string, secret: Secret): void

Parameters

  • name string
  • secret Secret

This method adds a secret as environment variable to the App Runner service.


applyRemovalPolicy(policy)๐Ÿ”น

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


toString()๐Ÿ”น

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromServiceAttributes(scope, id, attrs)๐Ÿ”น

public static fromServiceAttributes(scope: Construct, id: string, attrs: ServiceAttributes): IService

Parameters

  • scope Construct
  • id string
  • attrs ServiceAttributes

Returns

  • IService

Import from service attributes.


static fromServiceName(scope, id, serviceName)๐Ÿ”น

public static fromServiceName(scope: Construct, id: string, serviceName: string): IService

Parameters

  • scope Construct
  • id string
  • serviceName string

Returns

  • IService

Import from service name.