Service

class aws_cdk.aws_apprunner.Service(scope, id, *, source, access_role=None, cpu=None, instance_role=None, memory=None, service_name=None, vpc_connector=None)

Bases: Resource

(experimental) The App Runner Service.

Stability:

experimental

ExampleMetadata:

infused

Example:

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
    )
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • source (Source) – (experimental) The source of the repository for the service.

  • access_role (Optional[IRole]) – (experimental) 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. Default: - generate a new access role.

  • cpu (Optional[Cpu]) – (experimental) The number of CPU units reserved for each instance of your App Runner service. Default: Cpu.ONE_VCPU

  • instance_role (Optional[IRole]) – (experimental) 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. Default: - no instance role attached.

  • memory (Optional[Memory]) – (experimental) The amount of memory reserved for each instance of your App Runner service. Default: Memory.TWO_GB

  • service_name (Optional[str]) – (experimental) Name of the service. Default: - auto-generated if undefined.

  • vpc_connector (Optional[IVpcConnector]) – (experimental) Settings for an App Runner VPC connector to associate with the service. Default: - no VPC connector, uses the DEFAULT egress type instead

Stability:

experimental

Methods

apply_removal_policy(policy)

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

Parameters:

policy (RemovalPolicy) –

Return type:

None

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

env

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.

node

The construct tree node associated with this construct.

service_arn

(experimental) The ARN of the Service.

Stability:

experimental

Attribute:

true

service_id

(experimental) The ID of the Service.

Stability:

experimental

Attribute:

true

service_name

(experimental) The name of the service.

Stability:

experimental

Attribute:

true

service_status

(experimental) The status of the Service.

Stability:

experimental

Attribute:

true

service_url

(experimental) The URL of the Service.

Stability:

experimental

Attribute:

true

stack

The stack in which this resource is defined.

Static Methods

classmethod from_service_attributes(scope, id, *, service_arn, service_name, service_status, service_url)

(experimental) Import from service attributes.

Parameters:
  • scope (Construct) –

  • id (str) –

  • service_arn (str) – (experimental) The ARN of the service.

  • service_name (str) – (experimental) The name of the service.

  • service_status (str) – (experimental) The status of the service.

  • service_url (str) – (experimental) The URL of the service.

Stability:

experimental

Return type:

IService

classmethod from_service_name(scope, id, service_name)

(experimental) Import from service name.

Parameters:
  • scope (Construct) –

  • id (str) –

  • service_name (str) –

Stability:

experimental

Return type:

IService

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters:

x (Any) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool