The weird part of AWS bandwidth cost

I just got curious during handling the invoice of AWS. My gut feeling is that all inbound traffic are free (mostly), for example, you can see this in "Amazon EC2 On-Demand Pricing":

Data Transfer IN To Amazon EC2 From Internet
All data transfer in $0.00 per GB

But if you're dealing with inbound traffic across AZ in the same region:

Data transferred "in" to and "out" from Amazon EC2, Amazon RDS, Amazon Redshift, Amazon DynamoDB Accelerator (DAX), and Amazon ElastiCache instances, Elastic Network Interfaces or VPC Peering connections across Availability Zones in the same AWS Region is charged at $0.01/GB in each direction.

Yeah, inbound traffic across AZ is more expensive than the one from internet (which is free).

Also, inbound traffic to public IPv4 addresses and/or Elastic IP are not free:

IPv4: Data transferred “in” to and “out” from public or Elastic IPv4 address is charged at $0.01/GB in each direction.
IPv6: Data transferred “in” to and “out” from an IPv6 address in a different VPC is charged at $0.01/GB in each direction.

Anyway, this reminds me that I need to count US$0.02/GB instead of US$0.01/GB for such sort of traffic.

Golang software packaging for offline environment

Open build services like Launchpad PPA usually forbid internet connections during building, therefore it's impossible to download dependencies during building, and we need to include all dependencies into the source package.

Two things need to be done for building Golang softwares on no-internet building services:

  • Download all dependencies into vendor/ via go mod vendor command. This is usually done on the local machine with internet connections.
  • Ask Golang compiler to use vendor/ via go build -mod vendor command. Usually inside debian/rules file or Makefile.

If you're also working on Launchpad PPA like me, it's also suggested that add Simon Eisenmann's Golang Backports to the building dependency settings. This repository includes new Golang softwares so that you won't be hit by something like "syntax error".