# `app`

Boilerplate for an application running on ECS.

## Example

In `vars-common.yml`:

```yml
AccountId: "12345679876"
Region: "eu-west-1"
Team: "pirates"
Environment: "pirates-dev"
```

In `vars-app-rain.yml`:

```yml
StackName: "app-rain"
AppName: "rain"
WithExampleImage: true
WithDailyShutdown: false
WithAlbHostRouting: true
WithOpenTelemetrySidecar: false
WithVPCEndpoints: false
```

Render the template:

```sh
boilerplate \
  --template-url . \
  --var-file vars-common.yml \
  --var-file vars-app-rain.yml \
  --output-folder app-rain \
  --non-interactive
```

<!-- BOILERPLATE BEGIN -->
<!-- Generated by running `make docs` from the `boilerplate` dir) -->
<!-- Updated automatically in release PRs -->

## Variables

|           Name            |                                                                                                                                                                                          Description                                                                                                                                                                                           |  Type  |                                                                                      Default                                                                                       |Required|
|---------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
|`AppName`                  |Application name. Used to name the ECS service and related resources.                                                                                                                                                                                                                                                                                                                           |`string`|``n/a``                                                                                                                                                                             |yes     |
|`AppReadOnlyRootFileSystem`|Make the container's root filesystem read-only, so the app can only write to mounted volumes.                                                                                                                                                                                                                                                                                                   |`bool`  |``false``                                                                                                                                                                           |no      |
|`AppEcsExec`               |Let you open an interactive shell in the running container with the AWS CLI (Amazon ECS Exec).                                                                                                                                                                                                                                                                                                  |`bool`  |``false``                                                                                                                                                                           |no      |
|`ExampleImage`             |Run a public Nginx example image instead of your own application image. Useful for verifying that the infrastructure works before your own image and deployment pipeline exist. Cannot be combined with `DeploymentPipelineV2`.                                                                                                                                                                 |`map`   |``{"Enable": false}``                                                                                                                                                               |no      |
|`AlbHostRouting`           |Expose the app through the environment's shared load balancer. `Subdomain` serves it at `https://<AppName>.<Environment>.oslo.systems`, `ApexDomain` at `https://<AppName>.oslo.kommune.no`. `Internal` uses the environment's internal load balancer instead of the public one. `TargetGroupTargetStickiness` keeps a visitor on the same container for 24 hours, using a load balancer cookie.|`map`   |``{"Enable": false, "Internal": true, "Subdomain": {"Enable": false, "TargetGroupTargetStickiness": false}, "ApexDomain": {"Enable": false, "TargetGroupTargetStickiness": false}}``|no      |
|`DatabaseConnectivity`     |Give the app network access to the environment's database (created by the `databases` template), and inject the database endpoint into the container as the `DB_ENDPOINT` environment variable. Does not create a database.                                                                                                                                                                     |`map`   |``{"Enable": false}``                                                                                                                                                               |no      |
|`OpenTelemetrySidecar`     |Deprecated: use `TelemetryCollection` instead. Adds a sidecar that scrapes the app's Prometheus metrics from `/metrics` and sends them, along with container metrics, to the environment's Amazon Managed Prometheus workspace.                                                                                                                                                                 |`map`   |``{"Enable": false}``                                                                                                                                                               |no      |
|`DeploymentPipelineV2`     |Deploy the app with the next-generation deployment pipeline. Replaces `IamForCicd` and `Ecr`.                                                                                                                                                                                                                                                                                                   |`map`   |``{"Enable": false}``                                                                                                                                                               |no      |
|`TelemetryCollection`      |Send the app's logs, traces and metrics to Datadog. `AutoInstrumentation` instruments the app automatically at startup (currently Java only). `DatadogAgent` adds container-level monitoring.                                                                                                                                                                                                   |`map`   |``{"Enable": false, "AutoInstrumentation": {"Enable": false, "Runtime": "java"}, "DatadogAgent": {"Enable": false}}``                                                               |no      |
|`Xray`                     |Deprecated: use `TelemetryCollection` instead. Sends traces to AWS X-Ray.                                                                                                                                                                                                                                                                                                                       |`map`   |``{"Enable": false}``                                                                                                                                                               |no      |
|`VpcEndpoints`             |Keep the app's outbound traffic inside the VPC by using the environment's VPC endpoints instead of the internet. Requires VPC endpoints in the `networking` stack; does not create them.                                                                                                                                                                                                        |`map`   |``{"Enable": false}``                                                                                                                                                               |no      |
|`ServiceConnect`           |Let this app and other Service Connect-enabled services in the ECS cluster reach each other at `http://<AppName>:<port>` (Amazon ECS Service Connect).                                                                                                                                                                                                                                          |`map`   |``{"Enable": false}``                                                                                                                                                               |no      |
|`DailyShutdown`            |Stop the app every day at 16:00 UTC and start it again at 06:00 UTC. Saves money in environments that aren't used outside working hours, and follows the Green Software Foundation pattern [Scale down applications when not in use](https://patterns.greensoftware.foundation/operations/capacity-management/scale-down-unused-applications/).                                                 |`map`   |``{"Enable": false}``                                                                                                                                                               |no      |
|`IamForCicd`               |Deprecated: use `DeploymentPipelineV2` instead. Creates IAM roles for GitHub Actions: one for pushing images from the app repository (`AppGitHubRepo`), one for running Terraform from the IaC repository (`IacGitHubRepo`). `EcsDeployFromAppRepo` also lets the app repository trigger deployments. `AssumableCdRole` adds a role for debugging deployment permissions.                       |`map`   |``{"Enable": false, "AppGitHubRepo": null, "IacGitHubRepo": null, "AssumableCdRole": false, "EcsDeployFromAppRepo": false}``                                                        |no      |
|`DeploymentCircuitBreaker` |Stop a deployment if the new version repeatedly fails to start or become healthy, and roll back to the last working version.                                                                                                                                                                                                                                                                    |`map`   |``{"Enable": false}``                                                                                                                                                               |no      |
|`Ecr`                      |Deprecated: use `DeploymentPipelineV2` instead. Pulls the container image from the app's ECR repository (created by the `app-data` template). If disabled, set `image_uri` in `config_override.tf`.                                                                                                                                                                                             |`map`   |``{"Enable": true}``                                                                                                                                                                |no      |

<!-- BOILERPLATE END -->
