Skip to content

Commit 7a02c93

Browse files
authored
Merge pull request #142 from ruby-no-kai/apprunner-decom
decommission App Runner service
2 parents 433534e + def9e20 commit 7a02c93

File tree

7 files changed

+9
-184
lines changed

7 files changed

+9
-184
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,38 +58,6 @@ jobs:
5858
push: true
5959
tags: "${{ steps.login-ecr.outputs.registry }}/rko-router:${{ github.sha }},${{ steps.login-ecr.outputs.registry }}/rko-router:latest"
6060

61-
deploy-apprunner:
62-
name: deploy-apprunner
63-
if: "github.ref == 'refs/heads/master'"
64-
environment:
65-
name: apprunner-prod
66-
url: https://rko-router.rubykaigi.org
67-
concurrency:
68-
group: apprunner-prod
69-
permissions:
70-
contents: read
71-
id-token: write
72-
runs-on: ubuntu-latest
73-
needs:
74-
- ci
75-
steps:
76-
- uses: aws-actions/configure-aws-credentials@v4
77-
with:
78-
aws-region: "us-west-2"
79-
role-skip-session-tagging: true
80-
role-to-assume: "arn:aws:iam::005216166247:role/GhaRkoRouterDeploy"
81-
mask-aws-account-id: 'false' # only string works
82-
- uses: awslabs/amazon-app-runner-deploy@v2.5.2
83-
with:
84-
region: "us-west-2"
85-
service: "rko-router"
86-
image: "${{needs.ci.outputs.image-tag}}"
87-
access-role-arn: "arn:aws:iam::005216166247:role/AppraRkoRouter"
88-
wait-for-service-stability: true
89-
cpu: '0.25' # vCPU
90-
memory: '0.5' # GB
91-
port: "8080"
92-
9361
deploy-lambda:
9462
name: deploy-lambda
9563
if: "github.ref == 'refs/heads/master'"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules/
33
tf/cf_functions/src/*.js
44
tf/cf_functions/src/*.js.map
5+
*.tsbuildinfo

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# rubykaigi.org router
22

3-
nginx container deployed on AWS App Runner and served through CloudFront.
3+
nginx container deployed on Lambda Function URL and served through CloudFront.
44

5-
Detailed docs for RubyKaigi orgz: https://rubykaigi.esa.io/posts/1241
5+
- Detailed docs for RubyKaigi orgz: https://rubykaigi.esa.io/posts/1241
66

77
## Quick Reference
88

@@ -65,14 +65,13 @@ If you're going to do something more than the above, continue reading. Don't for
6565
Deployments are automatically performed on GitHub Actions on `master` branch after CI.
6666

6767
- Lambda: [rko-router](https://us-west-2.console.aws.amazon.com/lambda/home?region=us-west-2#/functions/rko-router?tab=monitoring)
68-
- App Runner (deprecated): [arn:aws:apprunner:us-west-2:005216166247:service/rko-router/2c9219ae5e14411baaf46fa932f33025](https://us-west-2.console.aws.amazon.com/apprunner/home?region=us-west-2#/services/dashboard?service_arn=arn%3Aaws%3Aapprunner%3Aus-west-2%3A005216166247%3Aservice%2Frko-router%2F2c9219ae5e14411baaf46fa932f33025&active_tab=logs)
6968
- CloudFront: [arn:aws:cloudfront::005216166247:distribution/E2WEWQCYU12GVD](https://us-east-1.console.aws.amazon.com/cloudfront/v3/home?region=ap-northeast-1#/distributions/E2WEWQCYU12GVD)
7069

7170
All resources except deployment is managed under Terraform [./tf](./tf).
7271

73-
### Domains
72+
### Serving multiple domains in production
7473

75-
Due to the quota of custom domains per App Runner service and the lambda function URL, the first hop on rko-router proxies a request to itself with correct `Host` header. We call this virtual host a _jump host._
74+
Because Lambda Function URL does not support custom domains, the first hop on rko-router proxies a request to itself with correct `Host` header. We call this virtual host a _jump host._
7675

7776
`x-rko-host` and `x-rko-xfp` headers are referenced as a `Host` and `X-Forwarded-Proto` header for the second hop.
7877

tf/apprunner.tf

Lines changed: 0 additions & 87 deletions
This file was deleted.

tf/cloudfront.tf

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,6 @@ resource "aws_cloudfront_distribution" "rko-router" {
4040
}
4141
}
4242

43-
origin {
44-
origin_id = "rko-router-apprunner"
45-
domain_name = replace(aws_apprunner_service.rko-router.service_url, "https://", "")
46-
47-
custom_origin_config {
48-
http_port = 80
49-
https_port = 443
50-
origin_protocol_policy = "https-only"
51-
origin_ssl_protocols = ["TLSv1.2"]
52-
origin_keepalive_timeout = 30
53-
origin_read_timeout = 35
54-
}
55-
56-
origin_shield {
57-
enabled = true
58-
origin_shield_region = "us-west-2"
59-
}
60-
}
61-
6243
origin {
6344
origin_id = "rko-router-lambda"
6445
domain_name = replace(aws_lambda_function_url.rko-router.function_url, "/^https:\\/+|\\/$/", "")

tf/iam_GhaRkoRouterDeploy.tf

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ data "aws_iam_policy_document" "rko-router-deploy-trust" {
1616
test = "StringEquals"
1717
variable = "token.actions.githubusercontent.com:sub"
1818
values = [
19-
"repo:ruby-no-kai/rko-router:environment:apprunner-prod",
2019
"repo:ruby-no-kai/rko-router:environment:lambda-prod",
2120
"repo:ruby-no-kai/rko-router:ref:refs/heads/master",
2221
"repo:ruby-no-kai/rko-router:ref:refs/heads/test",
@@ -70,57 +69,21 @@ data "aws_iam_policy_document" "rko-router-deploy-apprunner" {
7069
statement {
7170
effect = "Allow"
7271
actions = [
73-
"iam:PassRole",
74-
]
75-
resources = [aws_iam_role.rko-router-access.arn]
76-
77-
condition {
78-
test = "StringEquals"
79-
variable = "token.actions.githubusercontent.com:sub"
80-
values = [
81-
"repo:ruby-no-kai/rko-router:environment:apprunner-prod",
82-
]
83-
}
84-
}
85-
86-
statement {
87-
effect = "Allow"
88-
actions = [
89-
"apprunner:DescribeService",
90-
"apprunner:UpdateService",
91-
"apprunner:ListOperations"
72+
"lambda:UpdateFunctionCode",
9273
]
9374
resources = [
94-
aws_apprunner_service.rko-router.arn,
75+
aws_lambda_function.rko-router.arn,
9576
]
9677

9778
condition {
9879
test = "StringEquals"
9980
variable = "token.actions.githubusercontent.com:sub"
10081
values = [
101-
"repo:ruby-no-kai/rko-router:environment:apprunner-prod",
82+
"repo:ruby-no-kai/rko-router:environment:lambda-prod",
10283
]
10384
}
10485
}
10586

106-
statement {
107-
effect = "Allow"
108-
actions = [
109-
"apprunner:ListServices",
110-
]
111-
resources = ["*"]
112-
}
113-
114-
statement {
115-
effect = "Allow"
116-
actions = [
117-
"lambda:UpdateFunctionCode",
118-
]
119-
resources = [
120-
aws_lambda_function.rko-router.arn,
121-
]
122-
}
123-
12487
statement {
12588
effect = "Allow"
12689
actions = [

tf/iam_GhaRkoRouterPurge.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ data "aws_iam_policy_document" "rko-router-purge-trust" {
1616
test = "StringEquals"
1717
variable = "token.actions.githubusercontent.com:sub"
1818
values = [
19-
"repo:ruby-no-kai/rko-router:environment:apprunner-prod",
19+
"repo:ruby-no-kai/rko-router:environment:lambda-prod",
2020
"repo:ruby-no-kai/rubykaigi.org:environment:github-pages",
2121
]
2222
}

0 commit comments

Comments
 (0)