Beer Brewing

Temperatures

  • Lagers: 10-14 degrees
    • Pilsner is a type of pale lager.
  • Ales: 18-21 degrees

Hydrometer

Understanding what your fermentation is doing will help ensure a successful brew and encourage improvement in your brewing. A hydrometer to measure the gravity before, during and after fermentation is part of that process. If nothing else, it will help you work out the amount of alcohol in the beer and you’ll know when the fermentation has finished.

They measure: specific gravity, potential alcohol and approximate sugar per liter.

At its most basic scientific purpose, a hydrometer is an instrument that measures the specific gravity of liquids, that is to say, it measures the ratio of the density of the liquid to the density of water.

Timeline

  • Clean your drum with a sterilizing agent
  • Brewing, 2 hours
    • Dissolve your brew in 2-4 liters of very hot water
    • Add 1kg of sugar or dextrose
    • Put about 10 liters of cold water in your fermenter
    • Add the hot mixture, and mix well.
    • Top it up to 23 liters and sprinkle with brewers’ yeast when the temperature is below 30°.
  • Fermenting about a week
    • Seal the fermenter and partly fill the airlock with boiled, cooled water.
    • Once the airlock stops bubbling and the brew clears, leave it for another 48 hours
    • If the hydrometer reading is close to the expected reading and static for more than 24 hours then it’s ready for bottling.
  • Sterilize your bottles and caps with a sterilizing agent
  • Add a teaspoon of sugar or dextrose to each bottle
  • Fill each bottle to 40mm below the top
  • Cap the bottles, tilt them a few times to help dissolve the sugar
  • Store them in a warm place for five days
  • Move them somewhere a bit cooler for another five days
  • Give them another week, and try your beer

Sample at three weeks, three months, and six months if you don’t get rat-assed with your mates and smash them all.

References

Command Line Interface Overview

Firstly install and configure both the AWSCLI and ECSCLI.

For the examples below ecs is the [options] argument after the aws command. It instructs aws to run the command for Elastic Container Services. Any commands that point to a .json configuration file are available on github.

Tags

Assign metadata to AWS resources, this is a array of key|value so you can allocate infrastructure resources.

1
aws ecs list-tags-for-resource --resource-arn

Clusters

1
2
3
4
5
aws ecs list-clusters

aws ecs delete-cluster --cluster arn:aws:ecs:ap-southeast-2:000000000000:cluster/my-cluster

aws ecs describe-clusters --clusters arn:aws:ecs:ap-southeast-2:000000000000:cluster/my-cluster

ECR - Elastic Container Registry

ECR CLI commands are listed here in context of the lexicon project.

Task Definitions

(YOU CANNOT DELETE TASK DEFINITIONS, ONLY deregister)

1
2
3
aws ecs list-task-definitions --region ap-southeast-2 --status INACTIVE

aws ecs deregister-task-definition --task-definition {def-name:revision|ARN}

Register new from local .json file

1
aws ecs register-task-definition --cli-input-json file://some-task.json --region ap-southeast-2

Service

Start from task definition and keep it running.

1
2
3
aws ecs list-services --cluster ec2-cluster

aws ecs run-task --task-definition lexicon-service:2

VPC

1
aws ec2 describe-vpcs

References

Elastic Container Service - Lexicon from CLI

Prerequisites

Firstly install and configure both the AWSCLI and ECSCLI.

These are the steps to use the CLI to generate the Lexicon infrastructure with a Fargate Task. All .json configuration files are available on github.

Cluster

1
2
3
4
5
6
7
8
--- Create ECS cluster using config and profile setup from `Prerequisites`
ecs-cli up --cluster-config carl_configuration_name --ecs-profile carl_ecs_cli_profile

--- Get default security group ID for the VPC. Use the VPC ID from the previous output
aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-00000000000000000 --region ap-southeast-2

--- Security group rule to allow inbound access on port 80
aws ec2 authorize-security-group-ingress --group-id sg-0000000000000000 --protocol tcp --port 80 --cidr 0.0.0.0/0 --region ap-southeast-2

Compose File

Here you will need subnet ID 1, subnet ID 2 and security group ID values which would have been displayed when you ran ecs-cli up. If you cleared the console you can use aws ec2 describe-vpcs and look at the Tags to make an educated guess.

References

Elastic Container Service - Lexicon

The Lexicon is an open source project available on GitHub, the steps below setup the infrastructure in AWS using the AWS Console. There is a stack overview here that shows how the infrastructure works together. Alternatively this can also be done from the CLI.

Cluster

Login to the Console and search for ECS and select create new cluster.

Instance configuration

1
Type:                            EC2 Linux + Networking

This will also create the following resources:

  • Cluster
  • VPC
  • Subnets
  • Auto Scaling group with Linux AMI
1
2
Cluster name:                    lexicon-cluster
Provisioning Model: On-Demand Instance

With On-Demand Instances, you pay for compute capacity by the hour, with no long-term commitments or upfront payments.

1
2
3
4
5
EC2 instance type:               m5.large
Instances: 1
EC2 Ami Id: *select if setup
EBS storage (GiB): 22
Key pair: *select if setup on EC2

Networking

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.

1
2
3
4
5
6
VPC:                             create new
CIDR block: 10.0.0.0/16
Subnet 1: 10.0.0.0/24
Subnet 2: 10.0.1.0/24
Security group: create new
Security group inbound rules: 0.0.0.0/0:80

Container instance IAM role

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.

1
Container instance IAM role:     ecsInstanceRole

Tags

These are key value

1
Description:lexicon

CloudWatch Container Insights

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.

1
CloudWatch Container Insights:    [X] Enable Container Insights

Clicking create will then create all of the following resources

  • ECS cluster - ECS Cluster lexicon-cluster successfully created
  • ECS Instance IAM Policy - IAM Policy for the role ecsInstanceRole successfully attached
  • CloudFormation Stack - CloudFormation stack EC2ContainerService-lexicon-cluster and its resources successfully created

Cluster resources

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Instance typem5.large
Desired number of instances1
Key pair
ECS AMI IDami-0c7dea114481e059d
VPCvpc-0f7c247aaee86898a
Subnet 1subnet-034b4e1648e087e00
Subnet 1 route table associationrtbassoc-0f00a646e08954693
Subnet 2subnet-035ef093933b3004d
Subnet 2 route table associationrtbassoc-06baa9d9966bdc321
VPC Availability Zonesap-southeast-2a, ap-southeast-2b, ap-southeast-2c
Security groupsg-0bf09a7725e98639a
Internet gatewayigw-059a6dde43c07265b
Route tablertb-0f5117a414443aa77
Amazon EC2 routeEC2Co-Publi-1CGPQELKTIYXG
Virtual private gateway attachmentEC2Co-Attac-160S89W6RPC2V
Launch configurationEC2ContainerService-lexicon-cluster-EcsInstanceLc-1FBGSYZZTIHOC
Auto Scaling groupEC2ContainerService-lexicon-cluster-EcsInstanceAsg-1UZUKKM0HD2K6

Task Definitions

From Task Definitions select Create new Task Definition

1
2
3
4
5
Launch type: EC2 
Task Definition Name: lexicon-definition
Requires Compatibilities: EC2
Task Role: ecsTaskExecutionRole
Network Mode: Bridge (FARGATE will only have awsvpc)

Task execution IAM role

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.

1
Task execution role:              ecsTaskExecutionRole

Task size

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.

1
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’.

1
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’.

Add Container (WEB)

This is the ASP.NET MVC web application.

Standard
1
2
3
4
Container name:          lexicon-web
Image: 000000000000.dkr.ecr.ap-southeast-2.amazonaws.com/lexicon-test
Memory Limits (MiB): soft 512
Port mappings: 0 -> 80

Port mappings: 0 means any from the host

Advanced container configuration
1
2
Essential:               un-check 
Log configuration: [x] Auto-configure CloudWatch Logs

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.

Add Container (SQL)

1
2
3
4
Container name:          lexicon-sql
Image: microsoft/mssql-server-linux:2017-CU13
Memory Limits (MiB): soft 2048
Port mappings: 0 -> 1433
1
2
Environment variables:   LEXICON_SQL_CONNECTION|Password123
ACCEPT_EULA|Y

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.

1
2
Essential:               check
Log configuration: [x] Auto-configure CloudWatch Logs

Task (run once off)

  • Clusters -> lexicon-cluster -> tasks -> run new task
1
2
3
4
Launch type:             EC2
Task Definition: lexicon-definition:1
Cluster: lexicon-cluster
Number of tasks: 1

Then hit Run Task and wait for the status to change to RUNNING

  • Clusters -> select task -> expand container
    Click external link

Service

Start from task definition and keep it running as apposed to running the task as once off.

References

Elastic Container Registry

Amazon Elastic Container Registry (ECR) is a fully-managed Docker container registry that makes it easy for developers to store, manage, and deploy Docker container images.

Registry

Create ECR Repository from the AWS Console, example: lexicon-webmvc

1
2
000000000000.dkr.ecr.ap-southeast-2.amazonaws.com/lexicon-webmvc
This is the same as a docker hub image: microsoft/mssql-server-linux:2017-CU13

Push image from Local

Use the CLI to generate your login command

1
2
3
4
5
6
7
aws ecr get-login --no-include-email --region ap-southeast-2

docker login -u AWS -p [MASSIVE ENCRIPTED BLOB] https://000000000000.dkr.ecr.ap-southeast-2.amazonaws.com

docker tag docker-compose-lexicon_lexicon-webmvc 000000000000.dkr.ecr.ap-southeast-2.amazonaws.com/lexicon-webmvc

docker push 000000000000.dkr.ecr.ap-southeast-2.amazonaws.com/lexicon-webmvc

Now the image will be available at the ECR.

References