# IaC repository setup

Set up the infrastructure for a new application in your IaC repository.

## Step 1: Add package

```bash title="repo-iac/environments/dev/"
ok pkg add app app-hello-world
```

Update `package-config.yml` to enable the components you need. You can use the following configuration to set up a
minimal application running on **Nginx** with an internet-facing address:

```yaml title="repo-iac/environments/dev/app-hello-world/package-config.yml"
# Attribute reference:
# https://github.com/oslokommune/golden-path-boilerplate/blob/main/boilerplate/terraform/app/boilerplate.yml
StackName: "app-hello-world"
app-data.StackName: "app-hello-world-data"

AppName: "hello-world" # TODO: Set this to the name of your application
AppEcsExec: false
AppReadOnlyRootFileSystem: false

ExampleImage:
  Enable: false
Ecr:
  Enable: false
ServiceConnect:
  Enable: true
AlbHostRouting:
  Enable: true
  Internal: false
  Subdomain:
    Enable: true
    TargetGroupTargetStickiness: false
DatabaseConnectivity:
  Enable: false
DailyShutdown:
  Enable: false
DeploymentPipelineV2:
  Enable: true
TelemetryCollection:
  Enable: false
  AutoInstrumentation:
    Enable: false
    Runtime: java
```

## Step 2: Install the package

```bash title="repo-iac/environments/dev/app-hello-world/"
ok pkg install
```

## Step 3: Add app to `cicd-common`

Add your application repository to `config_override.tf`:

```terraform title="repo-iac/environments/dev/cicd-common/config_override.tf"
locals {
  trusted_repositories = [
    # ...
    {
      name = "<repo-name>"
      type = "app"
    }
  ]
}
```

Update these values:

| Field         | Description                             | Example       |
| ------------- | --------------------------------------- | ------------- |
| `<repo-name>` | The name of your application repository | `hello-world` |

## Step 4: Push

Push the code to `main`/`master`.

## Next steps

The "Terraform apply" GitHub Actions workflow launches an ECS service, but it has no container image to deploy.
To do that, follow the application setup in the next guide: [Set up CI/CD for `dev`](set-up-cicd-for-dev.md)
