Resource: aws_apprunner_service

Manages an App Runner Service.

Example Usage

Service with a Code Repository Source

resource "aws_apprunner_service" "example" {
  service_name = "example"

  source_configuration {
    authentication_configuration {
      connection_arn = aws_apprunner_connection.example.arn
    }
    code_repository {
      code_configuration {
        code_configuration_values {
          build_command = "python setup.py develop"
          port          = "8000"
          runtime       = "PYTHON_3"
          start_command = "python runapp.py"
        }
        configuration_source = "API"
      }
      repository_url = "https://github.com/example/my-example-python-app"
      source_code_version {
        type  = "BRANCH"
        value = "main"
      }
    }
  }

  network_configuration {
    egress_configuration {
      egress_type       = "VPC"
      vpc_connector_arn = aws_apprunner_vpc_connector.connector.arn
    }
  }

  tags = {
    Name = "example-apprunner-service"
  }
}

Service with an Image Repository Source

resource "aws_apprunner_service" "example" {
  service_name = "example"

  source_configuration {
    image_repository {
      image_configuration {
        port = "8000"
      }
      image_identifier      = "public.ecr.aws/aws-containers/hello-app-runner:latest"
      image_repository_type = "ECR_PUBLIC"
    }
    auto_deployments_enabled = false
  }

  tags = {
    Name = "example-apprunner-service"
  }
}

Service with Observability Configuration

resource "aws_apprunner_service" "example" {
  service_name = "example"

  observability_configuration {
    observability_configuration_arn = aws_apprunner_observability_configuration.example.arn
    observability_enabled           = true
  }

  source_configuration {
    image_repository {
      image_configuration {
        port = "8000"
      }
      image_identifier      = "public.ecr.aws/aws-containers/hello-app-runner:latest"
      image_repository_type = "ECR_PUBLIC"
    }
    auto_deployments_enabled = false
  }

  tags = {
    Name = "example-apprunner-service"
  }
}

resource "aws_apprunner_observability_configuration" "example" {
  observability_configuration_name = "example"

  trace_configuration {
    vendor = "AWSXRAY"
  }
}

Argument Reference

The following arguments are required:

The following arguments are optional:

Encryption Configuration

The encryption_configuration block supports the following argument:

Health Check Configuration

The health_check_configuration block supports the following arguments:

Instance Configuration

The instance_configuration block supports the following arguments:

Source Configuration

The source_configuration block supports the following arguments:

~>Note: Either code_repository or image_repository must be specified (but not both).

Authentication Configuration

The authentication_configuration block supports the following arguments:

Network Configuration

The network_configuration block supports the following arguments:

Ingress Configuration

The ingress_configuration block supports the following argument:

Egress Configuration

The egress_configuration block supports the following argument:

Observability Configuration

The observability_configuration block supports the following arguments:

Code Repository

The code_repository block supports the following arguments:

Image Repository

The image_repository block supports the following arguments:

Code Configuration

The code_configuration block supports the following arguments:

Code Configuration Values

The code_configuration_values blocks supports the following arguments:

Image Configuration

The image_configuration block supports the following arguments:

Source Code Version

The source_code_version block supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import App Runner Services using the arn. For example:

import {
  to = aws_apprunner_service.example
  id = "arn:aws:apprunner:us-east-1:1234567890:service/example/0a03292a89764e5882c41d8f991c82fe"
}

Using terraform import, import App Runner Services using the arn. For example:

% terraform import aws_apprunner_service.example arn:aws:apprunner:us-east-1:1234567890:service/example/0a03292a89764e5882c41d8f991c82fe