Skip to content

Application

Given this configuration, you should achieve the following outcome after completing this page:

Configuration
Environment pirates-dev
AppName too-tikki
Outcome
ECR pirates-dev-too-tikki
URL https://too-tikki.pirates-dev.oslo.systems/

Step 1: Create a new configuration file

Create a new configuration file for the application and enable the components you need.

This configuration enables as few options as possible to set up a hello world application running on nginx that will have an internet-facing address.

The remaining options are disabled to keep the setup as simple as possible.

repo-iac/environments/dev/_config/app-too-tikki.yml
# Attribute reference:
# https://github.com/oslokommune/golden-path-boilerplate/blob/main/boilerplate/terraform/app/boilerplate.yml
StackName: "app-too-tikki"
app-data.StackName: "app-too-tikki-data"

AppName: "too-tikki"
AppEcsExec: false
AppReadOnlyRootFileSystem: false

ExampleImage:
  Enable: true
ServiceConnect:
  Enable: false
AlbHostRouting:
  Enable: true
  Internal: false
DatabaseConnectivity:
  Enable: true
OpenTelemetrySidecar:
  Enable: false
VpcEndpoints:
  Enable: false
Xray:
  Enable: false
DailyShutdown:
  Enable: false
IamForCicd:
  Enable: false
  AppGitHubRepo: pirates-apps
  IacGitHubRepo: pirates-iac
  AssumableCdRole: false

Step 2: Add and install the app package

Run the following command in the repo-iac/environments/dev/ directory:

repo-iac/environments/dev/
ok pkg add app app-too-tikki

This will add the package you want to install to packages.yml. If you want to know more about how this works, read the reference documentation for packages.yml.

Then, run the following command to install the package:

repo-iac/environments/dev/
ok pkg install app-too-tikki

Step 3: Initialize and apply the app-common stacks

Applications are separated into two stacks when creating them.

The first stack is the data stack, which contains ECR and data-related resources, this must be applied first.

The second stack is the application stack, which contains the load balancing set up, ECS service, security groups and more for your application.

repo-iac/environments/dev
cd app-too-tikki-data/
terraform init
terraform apply
repo-iac/environments/dev
cd app-too-tikki/
terraform init
terraform apply

Step 4: Verify

Verify in the AWS CLI

To verify that ECR is correctly set up, run the following command:

aws ecr describe-repositories | jq '.repositories[].repositoryName'

The output list should contain the name of the ECR repository.

Verify in the AWS console

Login to the AWS console and navigate to ECR. Select Repositories in the left-hand menu.

The list should contain the name of the ECR repository.

Verify in the browser

Go to https://too-tikki.pirates-dev.oslo.systems/ and you should see the default Nginx page. Change URL according to your environment and application name.

Commit your files

At this stage it is a good idea to commit your files.

Otter celebrating with balloons