AWS::AppRunner::Service - AWS CloudFormation

AWS::AppRunner::Service

The AWS::AppRunner::Service resource is an AWS App Runner resource type that specifies an App Runner service.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

Properties

AutoScalingConfigurationArn

The Amazon Resource Name (ARN) of an App Runner automatic scaling configuration resource that you want to associate with your service. If not provided, App Runner associates the latest revision of a default auto scaling configuration.

Specify an ARN with a name and a revision number to associate that revision. For example: arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/3

Specify just the name to associate the latest revision. For example: arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability

Required: No

Type: String

Pattern: arn:aws(-[\w]+)*:[a-z0-9-\\.]{0,63}:[a-z0-9-\\.]{0,63}:[0-9]{12}:(\w|\/|-){1,1011}

Minimum: 1

Maximum: 1011

Update requires: No interruption

EncryptionConfiguration

An optional custom encryption key that App Runner uses to encrypt the copy of your source repository that it maintains and your service logs. By default, App Runner uses an AWS managed key.

Required: No

Type: EncryptionConfiguration

Update requires: Replacement

HealthCheckConfiguration

The settings for the health check that AWS App Runner performs to monitor the health of the App Runner service.

Required: No

Type: HealthCheckConfiguration

Update requires: No interruption

InstanceConfiguration

The runtime configuration of instances (scaling units) of your service.

Required: No

Type: InstanceConfiguration

Update requires: No interruption

NetworkConfiguration

Configuration settings related to network traffic of the web application that the App Runner service runs.

Required: No

Type: NetworkConfiguration

Update requires: No interruption

ObservabilityConfiguration

The observability configuration of your service.

Required: No

Type: ServiceObservabilityConfiguration

Update requires: No interruption

ServiceName

A name for the App Runner service. It must be unique across all the running App Runner services in your AWS account in the AWS Region.

If you don't specify a name, AWS CloudFormation generates a name for your service.

Required: No

Type: String

Pattern: [A-Za-z0-9][A-Za-z0-9-_]{3,39}

Minimum: 4

Maximum: 40

Update requires: Replacement

SourceConfiguration

The source to deploy to the App Runner service. It can be a code or an image repository.

Required: Yes

Type: SourceConfiguration

Update requires: No interruption

Tags

An optional list of metadata items that you can associate with the App Runner service resource. A tag is a key-value pair.

Required: No

Type: Array of Tag

Update requires: Replacement

Return values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the ARN of the App Runner service.

For more information about using the Ref function, see Ref.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

ServiceArn

The Amazon Resource Name (ARN) of this service.

ServiceId

An ID that App Runner generated for this service. It's unique within the AWS Region.

ServiceUrl

A subdomain URL that App Runner generated for this service. You can use this URL to access your service web application.

Status

The current state of the App Runner service. These particular values mean the following.

  • CREATE_FAILED – The service failed to create. The failed service isn't usable, and still counts towards your service quota. To troubleshoot this failure, read the failure events and logs, change any parameters that need to be fixed, and rebuild your service using UpdateService.

  • DELETE_FAILED – The service failed to delete and can't be successfully recovered. Retry the service deletion call to ensure that all related resources are removed.

Examples

Service based on source code

This example illustrates creating a service based on a Python source code repository.

JSON

{ "Type": "AWS::AppRunner::Service", "Properties": { "ServiceName": "python-app", "SourceConfiguration": { "AuthenticationConfiguration": { "ConnectionArn": "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e" }, "AutoDeploymentsEnabled": true, "CodeRepository": { "RepositoryUrl": "https://github.com/my-account/python-hello", "SourceCodeVersion": { "Type": "BRANCH", "Value": "main" }, "CodeConfiguration": { "ConfigurationSource": "API", "CodeConfigurationValues": { "Runtime": "PYTHON_3", "BuildCommand": "pip install -r requirements.txt", "StartCommand": "python server.py", "Port": "8080", "RuntimeEnvironmentVariables": [ { "Name": "NAME", "Value": "Jane" } ] } } } }, "InstanceConfiguration": { "Cpu": "1 vCPU", "Memory": "3 GB" } } }

YAML

Type: AWS::AppRunner::Service Properties: ServiceName: python-app SourceConfiguration: AuthenticationConfiguration: ConnectionArn: "arn:aws:apprunner:us-east-1:123456789012:connection/my-github-connection/e7656250f67242d7819feade6800f59e" AutoDeploymentsEnabled: true CodeRepository: RepositoryUrl: "https://github.com/my-account/python-hello" SourceCodeVersion: Type: BRANCH Value: main CodeConfiguration: ConfigurationSource: API CodeConfigurationValues: Runtime: PYTHON_3 BuildCommand: "pip install -r requirements.txt" StartCommand: "python server.py" Port: 8080 RuntimeEnvironmentVariables: - Name: NAME Value: Jane InstanceConfiguration: Cpu: 1 vCPU Memory: 3 GB

Service based on source image

This example illustrates creating a service based on an image stored in Amazon Elastic Container Registry (Amazon ECR).

JSON

{ "Type": "AWS::AppRunner::Service", "Properties": { "ServiceName": "golang-container-app", "SourceConfiguration": { "AuthenticationConfiguration": { "AccessRoleArn": "arn:aws:iam::123456789012:role/my-ecr-role" }, "AutoDeploymentsEnabled": true, "ImageRepository": { "ImageIdentifier": "123456789012.dkr.ecr.us-east-1.amazonaws.com/golang-app:latest", "ImageRepositoryType": "ECR", "ImageConfiguration": { "Port": "8080", "RuntimeEnvironmentVariables": [ { "Name": "NAME", "Value": "Jane" } ] } } }, "InstanceConfiguration": { "Cpu": "1 vCPU", "Memory": "3 GB" } } }

YAML

Type: AWS::AppRunner::Service Properties: ServiceName: golang-container-app SourceConfiguration: AuthenticationConfiguration: AccessRoleArn: "arn:aws:iam::123456789012:role/my-ecr-role" AutoDeploymentsEnabled: true ImageRepository: ImageIdentifier: "123456789012.dkr.ecr.us-east-1.amazonaws.com/golang-app:latest" ImageRepositoryType: ECR ImageConfiguration: Port: 8080 RuntimeEnvironmentVariables: - Name: NAME Value: Jane InstanceConfiguration: Cpu: 1 vCPU Memory: 3 GB

See also