Hello App Runner in Terraform

Set up an autoscaling configuration

resource "aws_apprunner_auto_scaling_configuration_version" "hello" {                            
auto_scaling_configuration_name = "hello"
# scale between 1-5 containers
min_size = 1
max_size = 5
}

Configure the service

resource "aws_apprunner_service" "hello" {                            
auto_scaling_configuration_arn = aws_apprunner_auto_scaling_configuration_version.hello.arn

service_name = "hello-app-runner"

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
}
}
output "apprunner_service_hello" {
value = aws_apprunner_service.hello
}

Terraform Plan

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
~ update in-place
Terraform will perform the following actions:# aws_apprunner_auto_scaling_configuration_version.example will be created
+ resource "aws_apprunner_auto_scaling_configuration_version" "hello" {
+ arn = (known after apply)
+ auto_scaling_configuration_name = "hello"
+ auto_scaling_configuration_revision = (known after apply)
+ id = (known after apply)
+ latest = (known after apply)
+ max_concurrency = 100
+ max_size = 5
+ min_size = 1
+ status = (known after apply)
}
# aws_apprunner_service.hello will be created
+ resource "aws_apprunner_service" "hello" {
+ arn = (known after apply)
+ auto_scaling_configuration_arn = (known after apply)
+ id = (known after apply)
+ service_id = (known after apply)
+ service_name = "hello-app-runner"
+ service_url = (known after apply)
+ status = (known after apply)
+ tags = {
+ "Name" = "hello-app-runner"
}
+ tags_all = {
+ "Name" = "hello-app-runner"
}
+ health_check_configuration {
+ healthy_threshold = (known after apply)
+ interval = (known after apply)
+ path = (known after apply)
+ protocol = (known after apply)
+ timeout = (known after apply)
+ unhealthy_threshold = (known after apply)
}
+ instance_configuration {
+ cpu = (known after apply)
+ instance_role_arn = (known after apply)
+ memory = (known after apply)
}
+ source_configuration {
+ auto_deployments_enabled = false
+ image_repository {
+ image_identifier = "public.ecr.aws/aws-containers/hello-app-runner:latest"
+ image_repository_type = "ECR_PUBLIC"
+ image_configuration {
+ port = "8000"
}
}
}
}

Terraform Apply

aws_apprunner_auto_scaling_configuration_version.example: Creating...
aws_apprunner_auto_scaling_configuration_version.example: Creation complete after 1s [id=arn:aws:apprunner:us-east-1:123456789:autoscalingconfiguration/example/1/8a88cca0b41a4844821e92c33de84703]
aws_apprunner_service.hello: Creating...
aws_apprunner_service.hello: Still creating... [10s elapsed]
...
aws_apprunner_service.hello: Still creating... [5m40s elapsed]
aws_apprunner_service.hello: Creation complete after 5m42s [id=arn:aws:apprunner:us-east-1:123456789:service/hello-app-runner/1256948d8558405daceea9cbaabb6ec1]
Apply complete! Resources: 2 added, 1 changed, 0 destroyed.Outputs:apprunner_service_hello = {
"arn" = "arn:aws:apprunner:us-east-1:123456789:service/hello-app-runner/1256948d8558405daceea9cbaabb6ec1"
"auto_scaling_configuration_arn" = "arn:aws:apprunner:us-east-1:123456789:autoscalingconfiguration/example/1/8a88cca0b41a4844821e92c33de84703"
"encryption_configuration" = []
"health_check_configuration" = [
{
"healthy_threshold" = 1
"interval" = 5
"path" = "/"
"protocol" = "TCP"
"timeout" = 2
"unhealthy_threshold" = 5
},
]
"id" = "arn:aws:apprunner:us-east-1:123456789:service/hello-app-runner/1256948d8558405daceea9cbaabb6ec1"
"instance_configuration" = [
{
"cpu" = "1024"
"instance_role_arn" = ""
"memory" = "2048"
},
]
"service_id" = "1256948d8558405daceea9cbaabb6ec1"
"service_name" = "hello-app-runner"
"service_url" = "bg2hcjuckx.us-east-1.awsapprunner.com"
"source_configuration" = [
{
"authentication_configuration" = []
"auto_deployments_enabled" = false
"code_repository" = []
"image_repository" = [
{
"image_configuration" = [
{
"port" = "8000"
"start_command" = ""
},
]
"image_identifier" = "public.ecr.aws/aws-containers/hello-app-runner:latest"
"image_repository_type" = "ECR_PUBLIC"
},
]
},
]
"status" = "RUNNING"
}

Wrap up

“service_url” = “bg2hcjuckx.us-east-1.awsapprunner.com”
Hello App Runner!

--

--

--

Senior SRE @getsentry

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

DevOps Adoption in Geographically Dispersed Organizations

Allow Users Signed In Using Amazon Cognito to Access their Own Amazon S3 Folder

Big surprises in software development

The problem with free software

9 Free Electronic Signature Software in 2022

Golang, how dare you handle my checks!

Data Compression Algorithm

Presearch Weekly Update #52 — Jan 28, 2022

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Michael Warkentin

Michael Warkentin

Senior SRE @getsentry

More from Medium

Project Calico on AWS — AWS Roadmap

How I Setup CI/CD With Github Actions For K3s

EC2 hosted Docker container with HTML & pushing image to ECR

Setup TKG 1.5.1 Management cluster on AWS cloud