You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a sample code repository showcasing to use of [AWS App Runner](https://aws.amazon.com/apprunner/) for running an impression counter API written in Go, that is using it latest feature for accessing private resources inside a VPC.
4
-
This sample code uses Amazon ElastiCache for Redis as its data store.
3
+
This is a sample code repository showcasing how to use [AWS App Runner](https://aws.amazon.com/apprunner/) for running an API server written in [Golang](https://go.dev) that counts page impression, and store the counter in [Amazon Elasticache for Redis](https://aws.amazon.com/elasticache/redis/) private resource. This sample use the VPC support [feature](https://aws.amazon.com/blogs/aws/new-for-app-runner-vpc-support/) that provide access to private resources inside the VPC.
5
4
6
-
To connect to private resources, AWS App Runner use a VPC Connector, that connects App Runner services into a custom VPC as describe in [this](https://docs.aws.amazon.com/apprunner/latest/dg/network-vpc.html) documentation.
5
+
To connect to your VPC, AWS App Runner private resources use a VPC Connector, that connects App Runner services into a VPC as describe in [this](https://docs.aws.amazon.com/apprunner/latest/dg/network-vpc.html) documentation.
7
6
8
7
AWS App Runner [image-base service](https://docs.aws.amazon.com/apprunner/latest/dg/service-source-image.html) allow to run any docker container image in any development language, and [Code-base service](https://docs.aws.amazon.com/apprunner/latest/dg/service-source-code.html) on supported languages App Runner will build the service source code on the service runtime docker images, removing the need to manage build infrastructure.
9
8
9
+
## Prerequisite
10
+
11
+
1. Create an Elasticache redis cluster. A single `cache.t4g.micro` is enough for this sample. Make sure to have a security group that will allow access to the App Runner service.
12
+
2. Build this sample code and push it to your region ECR repository
This is a manual step by step that will install this sample code inside your VPC, Using this sample will have costs in your account.
30
+
31
+
>There is also a terraform [plan](./terraform/) that do all the steps listed in the manual setup.
32
+
>The terraform plan uses a [local-exec](https://www.terraform.io/language/resources/provisioners/local-exec) provisioner to build a docker image for this service, this terraform plan is not for **production** use.
33
+
34
+
1. Create the AWS App Runner Service
35
+
2. Choose the Repository type: Container registry, and the Provider Amazon ECR. Browse and select the repository name `impression-counter-api` and the latest tag.
36
+

37
+
38
+
3. In the Deployment settings, if you have a service-role, select it, and if you don't have a service role, choose **Create a new service role**, and click next
39
+
4. Set the service name `impression-counter-api`, add an Environment variable for the redis host url, the key is `REDIS_HOST` and the value is your elasticache redis primary URL.
40
+

41
+
5. Scroll down and open the Networking section and select `Custom VPC` and click add new.
42
+
6. In the **Add new VPC connector** set the name of the connector `impression-counter-api` select the VPC and at least subnets, and assign the security group that was created in the prerequisite section to allow access from our new App Runner service to the private Elasticache Redis, and click Add
43
+

44
+
7. Click Next, review all the settings and click `Create & Deploy`
45
+
8. Once the service is ready, click the service default domain to see the service.
13
46
14
47
## Architecture
15
48
@@ -21,4 +54,4 @@ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more inform
21
54
22
55
## License
23
56
24
-
This library is licensed under the MIT-0 License. See the LICENSE file.
57
+
This library is licensed under the MIT-0 License. See the [LICENSE](./LICENSE) file.
0 commit comments