|
1 | 1 | # AWS App Runner Module |
2 | | -Terraform module which creates AWS AppRunner resources |
| 2 | +Terraform module which creates AWS AppRunner resources, currently only creates `aws_apprunner_service`, and have to provide arns for extra apprunner related resources. |
| 3 | + |
| 4 | +## Future Improvements Plan |
| 5 | +- Support Custom VPC using [aws_apprunner_vpc_connector](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/apprunner_vpc_connector) resource. |
| 6 | +- Support Custom autoscaling config using [aws_apprunner_auto_scaling_configuration_version](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/apprunner_auto_scaling_configuration_version) resource. |
| 7 | +- Support custom domains using [aws_apprunner_custom_domain_association](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/apprunner_custom_domain_association) resource. |
| 8 | +- Support creation of Github connection with [aws_apprunner_connection](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/apprunner_connection) resource. |
| 9 | + |
| 10 | +## Usage |
| 11 | + |
| 12 | +### The Official [AWS App Runner hello app](https://github.com/aws-containers/hello-app-runner) example that uses public ECR image source |
| 13 | + |
| 14 | +```hcl |
| 15 | +module "hello_app_runner" { |
| 16 | + source = "bhegazy/terraform-aws-app-runner" |
| 17 | +
|
| 18 | + create = true |
| 19 | + service_name = "hello-app-runner" |
| 20 | +
|
| 21 | + tags = { |
| 22 | + Name = "hello-app-runner" |
| 23 | + } |
| 24 | +
|
| 25 | + service_source_type = "image" |
| 26 | + image_repository_type = "ECR_PUBLIC" |
| 27 | + image_identifier = "public.ecr.aws/aws-containers/hello-app-runner:latest" |
| 28 | + auto_deployments_enabled = false # Must set to false to disable auto deployment for ECR_PUBLIC type |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +### Create App runner service from private image source (ECR) for example |
| 33 | + |
| 34 | +> Example uses [aws-app-runner-rust-example](https://github.com/bhegazy/aws-app-runner-rust-example) |
| 35 | +
|
| 36 | +```hcl |
| 37 | +module "image_repository_private" { |
| 38 | + source = "bhegazy/terraform-aws-app-runner" |
| 39 | +
|
| 40 | + create = true |
| 41 | + service_name = "my-service" |
| 42 | +
|
| 43 | + tags = { |
| 44 | + Name = "my-service" |
| 45 | + } |
| 46 | +
|
| 47 | + service_source_type = "image" |
| 48 | + auto_deployments_enabled = true |
| 49 | + image_repository_type = "ECR" |
| 50 | + image_access_role_arn = module.image_repository_private_ecr_role.iam_role_arn |
| 51 | + image_identifier = "112233445566.dkr.ecr.us-east-1.amazonaws.com/aws-app-runner-rust-example:latest" |
| 52 | + image_configuration = { |
| 53 | + port = 8080 |
| 54 | + start_command = "./aws-app-runner-rust-example" |
| 55 | + runtime_environment_variables = { |
| 56 | + ENV_VAR_1 = "value1" |
| 57 | + ENV_VAR_2 = "value2" |
| 58 | + } |
| 59 | + } |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +### Create App runner service from code source that have an app config (`apprunner.yml` file). |
| 64 | + |
| 65 | +```hcl |
| 66 | +module "code_repository_source" { |
| 67 | + source = "bhegazy/terraform-aws-app-runner" |
| 68 | + |
| 69 | + create = true |
| 70 | + service_name = "my-service" |
| 71 | + |
| 72 | + tags = { |
| 73 | + Name = "my-service" |
| 74 | + } |
| 75 | + |
| 76 | + service_source_type = "code" |
| 77 | + auto_deployments_enabled = true |
| 78 | + code_connection_arn = aws_apprunner_connection.main.arn |
| 79 | + code_repository_url = "https://github.com/bhegazy/apprunner-python-app" |
| 80 | + code_version_type = "BRANCH" |
| 81 | + code_version_value = "main" |
| 82 | + code_configuration_source = "REPOSITORY" |
| 83 | +} |
| 84 | +``` |
| 85 | +### Examples |
| 86 | +- [AWS App Runner Hello App](https://github.com/bhegazy/terraform-aws-apprunner/blob/main/examples/hello-app-runner) |
| 87 | +- [Complete Code Source](https://github.com/bhegazy/terraform-aws-apprunner/tree/main/examples/complete_code_source_api) |
| 88 | +- [Code Source with App Config (apprunner.yaml)](https://github.com/bhegazy/terraform-aws-apprunner/tree/main/examples/code_source_config_apprunner.yaml) |
| 89 | +- [Image Source (Private ECR)](https://github.com/bhegazy/terraform-aws-apprunner/tree/main/examples/image_repository_private) |
3 | 90 |
|
4 | 91 | <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
5 | 92 | ## Requirements |
|
0 commit comments