Create a new stack for your application
This guide is outdated
The guide is outdated due to us moving from PoC to using micro stacks. The new documentation is not ready yet.
If you are setting up something new, please contact team Kjøremiljø first so we can do this together For more up to date information about how to set up your infrastructure you can take sneak peek at our reference app pirates-iac.
This guide can still be used for trouble shooting purposes for teams that have not yet taken the micro stack structure in use.
This stack will contain the ECS service and task definition for your application, which will run in the ECS cluster we created in the stack above.
Prepare application stack
-
Go to the root of the environment directory
-
Run the
ok scaffold
command to create a new stack
Add modules to application stack
-
ECS Service module
-
Verify that the module was added
-
Open
ecs_service.tf
and replace the values inside themodule "ecs_service"
block with your own values
Replacing variables
Which values you have to change and what to change them to is explained in the file itself.
Elastic Container Registry
If you plan on using Elastic Container Registry (ECR) for storing container images, fetch the ECR template:
Open ecr_registry.tf
and replace the values marked with a TODO
to match your setup.
Apply configuration to set up the application stack
Coffee break
This might take a few minutes to complete.
The application should now be running in the Elastic Container Service (ECS) cluster.
Verify that the service is running
You have two options on how to verify that the application is running:
By checking the URL of the service
- The URL of the service is a combination of the
service_name
androot_domain
you specified in theecs_service
module.Example:
https://myapp.my-team-dev.oslo.systems/
- If you are interested in viewing the logs generated by app the application, scroll down to View logs from the service
By checking the ECS console
You can either do this by going to the AWS console and looking at the ECS service:
- Go to the AWS console and navigate to the ECS Cluster list
- Click on the cluster you created in the
infra
stackThe name of the cluster is inherited from the
metadata.environment
value in theenv.yml
file. - Click on the
Services
tab - Click on the service you created in the
application
stackThe name of the service is inherited from the variable
application_name
value in theecs_service.tf
module. - Click on the
Tasks
tabYou should see a running task with the status:
RUNNING
View logs from the service
- Go to the AWS console and navigate to the ECS Cluster list
- Click on the cluster you created in the
infra
stackThe name of the cluster is inherited from the
metadata.environment
value in theenv.yml
file. - Click on the
Tasks
tab - Click on the task you created in the
application
stackThe name of the task is inherited from the variable
application_name
value in theecs_service.tf
module. - Click on the
Logs
tab - You will see a list of log streams, the one you want to view is the one with the name of your service, for example
myapp
You can verify this by going to the AWS console and looking at the ECS service in the cluster you created in the previous step.