Close

Give EC2 instance access to a specific S3 bucket using IAM

Here’s the policy you need to attach to your instance’s IAM: { “Version”: “2012-10-17”, “Statement”: [ { “Effect”: “Allow”, “Action”: “s3:*”, “Resource”: [ “arn:aws:s3:::bucket-name”, “arn:aws:s3:::bucket-name/*” ] } ] } You can replace the ‘*’ above with more restrictive permissions (e.g. read only) where necessary. This approach means you don’t need to set up any kind […]

Read More

Golang – Organise your code using functions

Functions are a block of code that can call in your code. Functions and Packages are the 2 main ways used for organising code in Golang. You can feed parameters to functions and functions can also return values. You can call one function from inside another function.

Read More

Setup a Workspace for Go

Before you can start writing Golang code. You first need to set up a Workspace. A workspace is just a folder that will store all your Golang related stuff. In my case I’ll create a workspace called ‘go_project’: $ mkdir /root/go_project A workspace needs to have 3 top level folders called pkg, bin, and src: […]

Read More

Installing Golang

Installing Golang is really easy, just following the instructions in the official guide. For example, for RHEL/CentOSm we would do something like: golang_archive_filename=go1.10.3.linux-amd64.tar.gz curl -o ${golang_archive_filename} https://dl.google.com/go/${golang_archive_filename} tar -C /usr/local -xzf ${golang_archive_filename} cd /usr/local/go/bin cp -rfp /usr/local/go/bin/* /usr/bin/ However here are a few other ways to install Golang: RHEL/CentOS install tips A quick way to […]

Read More

Golang Tutorial

What is Golang? Golang (aka G0) is a relatively new programming language Google that has taken the IT world by storm. It was released in 2009 and already some of the biggest applications are written in Go, including Docker, Terraform, and Kubernetes. This is a series of bitesize tutorials that’ll help you get comfortable with […]

Read More

AWS Cost Explorer CLI demo – filtering costs by cost allocation tags

Here’s a quick example: $ cat filter.json { “Tags”: { “Key”: “role”, “Values”: [“webserver”] } } $ aws ce get-cost-and-usage –time-period Start=$(date +”%Y-%m-%d” –date=”-24 hours”),End=$(date +”%Y-%m-%d”) –granularity=DAILY –metrics BlendedCost –filter file://filter.json RESULTSBYTIME True TIMEPERIOD 2018-08-09 2018-08-08 BLENDEDCOST 22.30 USD References: http://blog.xi-group.com/2015/01/small-tip-how-to-use-aws-cli-filter-parameter/ https://medium.com/@nachomillangarcia/prometheus-alerts-for-aws-daily-costs-3374137d1371

Read More

RHCE – rough notes

page 4: systemctl –type=service list all running services: systemctl –list-units –type=service list all services, running and not running: systemctl –list-units –type=service page 6: lists the units that this unit depends on: systemctl list-dependencies UNIT shows what other services depends on the following unit: systemctl list-dependencies UNIT –reverse this forcefully disables a unit, so that it […]

Read More