Lexicon is an open source project available on GitHub, the steps below setup the infrastructure in AWS using the AWS Console for launch type
EC2. There is a stack overview here that shows how the infrastructure works together. Alternatively this can also be done from the CLI where I used the launch type
Login to the Console and search for
ECS and select create new cluster.
Fargate type is a compute engine that allows you to run containers without having to manage servers or clusters. For the steps below I used
EC2 Linux + Networking. (for reasons :D)
Type: EC2 Linux + Networking
This will also create the following resources:
- Auto Scaling group with Linux AMI
Cluster name: lexicon-cluster
With On-Demand Instances, you pay for compute capacity by the hour, with no long-term commitments or upfront payments.
EC2 instance type: m5.large
ami-0e18747114eff8bce is the Amazon Linux AMI 2.0.20190913 x86_64 ECS HVM GP2 Linux Image used for the virtual machine. AMI stands for Amazon Machine Image.
Configure the VPC for your container instances to use. A VPC is an isolated portion of the AWS cloud populated by AWS objects, such as Amazon EC2 instances. You can choose an existing VPC, or create a new one with this wizard.
VPC: *create new
The Amazon ECS container agent makes calls to the Amazon ECS API actions on your behalf, so container instances that run the agent require the ecsInstanceRole IAM policy and role for the service to know that the agent belongs to you. If you do not have the ecsInstanceRole already, we can create one for you.
Container instance IAM role: ecsInstanceRole
These are key value
CloudWatch Container Insights is a monitoring and troubleshooting solution for containerized applications and microservices. It collects, aggregates, and summarizes compute utilization such as CPU, memory, disk, and network; and diagnostic information such as container restart failures to help you isolate issues with your clusters and resolve them quickly.
CloudWatch Container Insights: [X] Enable Container Insights
Clicking create will then create all of the following resources
- ECS cluster as
- ECS Instance IAM Policy - IAM Policy for the role ecsInstanceRole is attached
- CloudFormation Stack -
ECS AMI ID ami-0e18747114eff8bce
Task Definitions select
Create new Task Definition
Launch type: EC2
If you choose
- For bridge (FARGATE will only have awsvpc)
This role is required by tasks to pull container images and publish container logs to Amazon CloudWatch on your behalf. If you do not have the ecsTaskExecutionRole already, we can create one for you.
Task execution role: ecsTaskExecutionRole
The task size allows you to specify a fixed size for your task. Task size is required for tasks using the Fargate launch type and is optional for the EC2 launch type. Container level memory settings are optional when task size is set. Task size is not supported for Windows containers.
Task memory (GB): 4096
The amount of memory (in MiB) used by the task. It can be expressed as an integer using MiB, for example 1024, or as a string using GB, for example ‘1GB’ or ‘1 gb’.
Task CPU (vCPU): 2048 (512 = 0.5 vCPU, 1024 = 1 vCPU, 2048 = 2 vCPU)
The number of CPU units used by the task. It can be expressed as an integer using CPU units, for example 1024, or as a string using vCPUs, for example ‘1 vCPU’ or ‘1 vcpu’.
This is the ASP.NET MVC web application.
Container name: lexicon-web
0 -> 80 means any from the
host to the container on 80. This will however then assign a random port like 32722 which would probably not be open in the security group.
Essential, if you check this and your process exits, then the entire task is shut down as well. At least one of your containers HAS to have this checked.
Container name: lexicon-sql
You may also designate AWS Systems Manager Parameter Store keys or ARNs using the ‘valueFrom’ field. ECS will inject the value into containers at run-time.
run new task
Launch type: EC2
Run Task and wait for the status to change to
expand container-> Click external link
You can start from task definition and keep it running as apposed to running the task as