Playing Terraform for AWS

This post is based on terraform tutorial Build infrastructure | Terraform | HashiCorp Developer

Make sure AWSCli being installed and configured correctly (aws configure). Make sure IAM user are configured with AWS role, AWS Access key ID and AWS Secret Access Key.

Use the ami catalog, to determine the ami ID, then after make necessary changes run the init

Result of terraform init
terraform plan will show configuration to be applied once init are successful
AWS EC2 creation failed

To solve this VPC and subnet needs to be created first.

Creation of VPC completed, copy the DMZ subnet ID

Make small change to the EC2 instance of terraform file.

Add DMZ subnet to the terraform file

Rerun the terraform init, terraform plan, terraform validate before rerunning terraform apply, then type yes.

EC2 provisioning Completed
Cleaning up, terraform destroy

To clean up the experiment to avoid paying more, start by destroying the instance then the VPC.

Terraform code is available at https://bitbucket.org/KarMeng/terraform_aws

Experimenting with Terraform

All the experience in this post is based on Install Terraform | Terraform | HashiCorp Developer

After terraform init, terraform apply needs confirmation of “yes” before applying into environment

Feels like running ansible but simpler, as the tutorial of quickstart runs on docker engine.

After applying terraform, confirm the nginx is running

Further confirmation running browser to browse the site.

The terraform tutorial are running nginx at port 8000 of your host machine.
If you preferred curl

How to use docker compose to setup AWStats

Have added changes to incorporate both generating AWStats logs and starting up AWStats service in a single docker compose file at KarMeng / docker_awstats — Bitbucket

Sample docker compose for AWStats

This is an easy and simple example that beginners can use to generate web statistics using AWStats.

Required softwares:
Hashicorp Vagrant 2.4.1
Oracle VirtualBox 7.0.14

Continue reading

ElasticSearch 8.12 docker compose do not work

Error message exited 137

The first error that will be face on get go is the error “kibana Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap” and exiting error “dependency failed to start: container docker-es03-1 exited (137)”.

Searching mentioned error on google or the internet will yield result that advice swap memory and memory limit hit.

Continue reading

ElasticSearch 8.12 kibana cluster using vagrant and docker compose

Pre-requisite:
– VirtualBox 7.0.14
– Vagrant 2.4.1
– Windows 10 or better OS
– 16GB RAM (10GB RAM are required for creating ElasticSearch with kibana; 1GB and 2 x ElasticSearch node; 4GB each, rest of the RAM for VM host OS)

Overview:
There are 2 layers of virtualization, first the Virtual Box, then the docker engine running in the Virtual Box VM running on Ubuntu 20.04 focal.

Orchestration used in the host OS level; Windows 10 are the hashicorp vagrant. The vagrant is used to configure the VM Ubuntu OS to be configured to run properly configured docker and Ubuntu 20.04.

Then docker compose v2 are used to create the ElasticSearch 8.12 cluster or stack.

The downside of this example, vagrant up needs to be run initially to configure the VM Ubuntu 20.04 OS. I have yet to discover if Vagrant has the ability to bootstrap grub and configuring the sysctl to allow the docker engine to run properly with the ElasticSearch 8.12 stack.

Continue reading

Using of legacy built in command of MS DOS copy con

Usage of copy con is possible in modern Windows OS command prompt is possible

copy con is a legacy command that allows a plain MSDOS to create text file such as autoexec.bat and config.sys

From my experience, the command is supported from MSDOS 3.30 till today. Have yet to test this command in Windows 11 OS.

To commit and save the file into disk, use CTRL + Z

This command was learned/discovered during the days before existence of Internet, by attentively looking over the shoulder of seniors, who are not willing to teach during computer club session.

@echo off
netsh wlan show profiles |findstr All > tmp.txt
for /f "tokens=2 delims=:" %%a in (tmp.txt) do (
echo %%a
netsh wlan show profiles name=%%a key=clear
)
del tmp.txt

This batch script will list out list of saved wifi profiles, save the profile into text file tmp.txt

From the file tmp.txt, print out the 2nd token from the text file which will returns the WiFi profile name, then using the same command to expose WiFi key in clear text.

How to upgrade an old laptop that is lagging

First assuming that compatible hardware is available, get compatible SODIMM RAM. and identify type of hard disk your laptop can use.

General idea, check the laptop user manual to identify what are the maximum RAM that are supported total, what are the maximum RAM supported in a slot. And importantly does the motherboard chipset of your laptop supports SODIMM that are different capacity. Clock speed as long as its higher than the laptop spec, the motherboard chipset will automatically tune the RAM Clock speed to match the maximum speed supported by the motherboard.

For context, the old laptop for upgrade is an Acer Aspire E5-475 which comes with 4GB RAM, 1TB HDD that has an Intel i5-7200U CPU at 2.5GHz.

Generally, a laptop should be serviceable, however by opening the service area, it will void the laptop warranty, ACER Aspire E5-475
Continue reading

Measuring how much time vagrant up is using to complete orchestration

A little bit of effort to search the net and encountering the solution, powershell will is a simple way to measure time spent executing a command. In Linux environment, time command can be used, but in this post, it is limited to Windows environment.

Based on the conventional wisdom from the documentation of Measure-Command of powershell. The command would be as follows:

Measure-Command {vagrant up}

However, by running the above powershell command, the output to the screen will be not available.

Hence, more searching in the internet (Source: time – Timing a command’s execution in PowerShell – Stack Overflow) leads to the complete command below:

Measure-Command {vagrant up|Out-Default}
Console output is shown when the command running is being piped into Out-Default

Based on the previous post of the vagrant orchestration of GitLab, the orchestration takes about 50 minutes in my computer with timedotcom broadband connection.

Total time spent for the command to end, 50 minutes plus.

Conclusion, measure-command is easy way but lack of detail such as time spent on CPU, IDLE time and network operations time. It will not be suitable for use if more details are needed.

How to use Hashicorp Vagrant to quickstart GitLab docker compose sample

The code of the project is available at chowkarmeng/vagrant_gitlab (github.com), the docker compose is based on the sample provided in GitLab Docker images | GitLab

The improvement done was to change the folder sync for virtual box into docker volumes.

First, git clone the repository https://github.com/chowkarmeng/vagrant_gitlab.git

Fire up the quickstart by running “vagrant up” in the localdev

The process will take hours depending on the speed of your computer and speed of your internet connection.

Continue reading

Making your windows RDP accessible from your home network

It is simple to make your computer in your home LAN accessible from internet.

The pre-requisite would be understanding how Network Address Translation works. To make the dynamic IP of ISP provide to your home internet access, feel free to research into finding Dynamic DNS providers. This will make it easier than using websites like whatismyip.com . And you just need to fire up the RDP client, and use the Dynamic DNS FQDN which will be always pointing to your static IP.

Depending on the network equipment used in your home or provided by your Internet Service Provider (ISP), you may need to look for NAT or in my case IPv4 port mapping.

The screenshot above, shows how to create a NAT mapping or a IPv4 port mapping for a computer with LAN IP, 192.168.100.12, take note that the port of RDP is 3389 and the protocol used is TCP. Hence, the internal port must be numbered 3389.

External port set to 3389 are for the sake of simplicity.

If there are more host in your LAN need to be accessible from the internet remotely using RDP, there is no need to change the default port of RDP of your host.

Instead, use the known port that is not blocked by your ISP. Example assuming that higher port numbers are not blocked by your ISP, you could use 13389, or 23389, or 33389 or 43389, or 53389 or 63389, as long as it is not more than 65535 or lesser than 1024. Those port number can be used as the External port number, while maintaining the internal port number to 3389.