Skip to content

IaC repo setup

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

Before you begin

This guide assumes

Step 1: Add package

repo-iac/environments/dev/
ok pkg add app app-hello-world
cd 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:

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

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:

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 repo hello-world

Step 4: Push

Push the code to main/master.

Next steps

The "Terraform apply" GitHub actions workflow will now launch an ECS service, but it has no container image to deploy. To do that, follow the application setup in the next guide: App repo setup