Is It a Best/Recommended Practice to Use AWS VPC Peering Connections?

Problem scenario
You have heard about AWS VPC Peering Connections. Should you use them?

Solution
The short answer is "yes."

Some "best practices" for VPCs are merely step-by-step directions for setting it up while describing options that you may or may not want to take. This posting, on a technical blog of a large reputable company, was cited in The DevOps Handbook (on page 404). It provides numerous options as opposed to many hard-and-fast rules. Unfortunately, it was published in 2014. VPC Peering connections were widely available as of 2018 (according to Amazon).

Newer VPC "best practices" guides mention and suggest encouragement of peering connections:
https://cloudacademy.com/blog/top-13-amazon-virtual-private-cloud-best-practices/
https://www.buurst.com/2019/04/17/blog-aws-vpc-best-practices/
https://searchcloudsecurity.techtarget.com/feature/VPC-security-best-practices-and-how-to-implement-them-in-AWS

CockroachDB recommends peering connections to improve security. Another source recommends VPC peering connections.

In some instances, peering connections could be a security problem (according to stackarmor.com). In theory your VPC could be exposed to attacks from the intruders in other VPCs connected via peering connections. "Attack surface reduction is a cyber security best practice." (This quote was taken from https://www.anetworks.com/attack-surface-reduction/.)

We think VPC Peering Connections are great, but you always have to be reasonably sure each VPC is also properly configured because they could potentially increase your attack surface.

Python Challenge of the Day (2/17/22)

Problem scenario
You have a program as follows:

class Location:
    def __init__(self, country="US", state="CA", city="Los Angeles"):
        self.country = country
        self.state = state
        self.city = city

    def printer(self):
        return [self.country, self.state, self.city]

new_loc = Location("Mexico", "Mexico City", "Mexico City", "good neighborhood")
print(new_loc.printer())

Here are your choices of what it could print out:

a. TypeError: init() takes from 1 to 4 positional arguments but 5 were given
b. TypeError: init() takes from 1 to 3 positional arguments but 4 were given
c. ['Mexico', 'Mexico City', 'Mexico City']
d. None of the above

Which one does it print?

Scroll down to see the answer.


Answer
A. The reason is that the class methods always pass the self when there are stanzas like this:

new_loc = Location("Mexico", "Mexico City", "Mexico City", "good neighborhood")

The self is invisible, but behind-the-scenes, it is there.

It accepts four positional arguments: country, state, city, and self. The line causing the error includes "good neighborhood". To read more about this, see this StackOverflow posting.

The arity of the __init__ constructor (in the class Location) is variable -- but passing four arguments is excessive. It can handle three explicit parameters as "self" is passed implicitly. Python will print out "__init__() takes from 1 to 4 positional arguments but 5 were given"

Is It Possible for an I.T. Staffing Company to Provide Notice that Your Contract Will End?

Problem scenario
A staffing company wants you to agree to give a 15 or 30 day notice before you voluntarily leave. But they have to give you no notice. One attorney said that in that business model, this is common. Another attorney says that it is not unreasonable to ask for this clause to be reciprocal. You do not think that the company will agree to making it reciprocal. Is it possible for the project owner to give a contractor advance notice that the contract will end sooner than expected?

Answer
Yes. Ask for the clause to be reciprocal or ask for the clause to be removed. If you are constructively terminated in certain jurisdictions, quitting without notice is acceptable. Some staffing companies will either remove the clause or make the notice reciprocal. You should always ask for the staffing company to provide notice as soon as they hear from the client that your contract will end. Even if they won't concede to the notice in the contract, they will likely tell you via email (during this negotiation phase) that they will let you know as soon as possible. Ideally it will be in the contract. But sudden terminations can happen even when there is no indication from the interviewer or staffing company that they would do such a thing. This way a sudden termination may be less sudden. It can be easier to secure employment when you have a job.

You may or may not want to insist that the "as much notice as possible" clause is in the contract. Many contracts have an "entire agreement" clause which says if the agreement between the parties is not in the contract, it is probably not enforceable. Emails can form a basis of fraudulent attempt by one party to induce you to signing a contract, but this collateral evidence may or may not withstand the "entire agreement" clause. In other words such pre-execution-of-the-contract emails may not be enforceable if a subsequent contract was signed with an "entire agreement" clause, but those emails could still provide some assistance to you in a legal proceeding. You never know when an end client may want to the end the contract, but the staffing company does not think you will need to know right away that your work is ending. If you express your interest in learning right away that it is ending, they may fit protective language into the contract to give you a right to know immediately. The end client may share with you their advance notice to the staffing company. Some staffing companies will pay you for the notice period without having you work for any end client if the clause is in the contract.

Do PostgreSQL Tables Have Clustered Indexes like SQL Server Database Tables Have?

Problem scenario
You are curious if a clustered index is the same as the table in PostgreSQL. You are familiar with SQL Server tables. Do PostgreSQL tables have clustered indexes like SQL Server tables have?

Answer
No. The source is here.

What is a Validation Webhook?

Question
In the context of Kubernetes, what is a validation webhook?

Answer
They are an API invocation to confirm a resource was created properly. Unlike a mutating webhook, validation webhooks make no changes to resources deployed in Kubernetes. Also unlike a mutating webhook, validation webhooks happen at a different step in the admission controller process. The admission controller process starts with an API request and ends with persisting data to etcd.

See the diagram here and visually search for "diagram representing."

Object schema validation precedes validation webhooks; object schema validation happens after mutating webhooks.

See also https://banzaicloud.com/blog/k8s-admission-webhooks/.

Do Ordered Dictionaries in Python Consume More Memory than Regular Dictionaries?

Question
You are considered using ordered dictionaries in Python (e.g., because of the way they handle temporal data). Will your program use more memory this way compared to using a regular dictionary?

Answer
Yes. All things being equal, ordered dictionaries use more memory than normal dictionaries.

# You will see that Python 3's ordered dictionaries consume more memory than regular dictionaries
# This was adapted from https://lerner.co.il/2019/05/12/python-dicts-and-memory-usage/

import sys
from collections import OrderedDict

x = OrderedDict()
y = {}

for i in range(1, 123456):
    x[i] = "filler text"
    y[i] = "filler text"


print(sys.getsizeof(x))
print("The size of the ordered dictionary is above and the regular dictionary is below.")
print(sys.getsizeof(y))

Amazing Growth for I.T. Jobs in Security

In November of 2017 Continualintegration.com posted What is DevSecOps (or DevOpsSec, SecDevOps, or rugged DevOps)?. At the time, Indeed found 192 jobs with a search for "devsecops". Today, 2/10/22, in four years and three months later, Indeed returns 19,002 jobs for a search of "devsecops." There are roughly 100x as many jobs now that include the word "devsecops" on Indeed. The website has grown, but this is still an amazing finding.

How Do You Troubleshoot Automation?

Problem scenario
You have a task that is supposed to redirect the output to a file. The command produces output when you manually run it. But the output is not getting to the file. What could be wrong?

Possible Solution #1
If there is an error message, Google the error message. If that does not help, scrutinize the command before the error.

Possible Solution #2
Manually run the automation line-by-line if possible. Be aware of the different environment variables, current working directories, and user contexts associated with the automation. The small differences are not inconsequential.

Possible Solution #3
Has the automation ever worked? If so was a change made that broke it? To execute the script a triggering event needs to happen. Are you 100% sure that the initiating event happened? User authentication and network ports being blocked are two common problems that stymie automation. To troubleshoot network problems, see this posting.

Possible Solution #4
The user running the script does not have permissions to write to the destination location (e.g., of the file).

Possible Solution #5
If the automation is a crontab job, see this posting.

Possible Solution #6
If the automation involves a Linux command not writing/redirecting to a target file, see this posting.

How Do You Use gRPC to Learn More about It?

Problem scenario
You want to use gRPC as a proof of concept. What should you do?

Solution
Go here: https://chromium.googlesource.com/external/github.com/grpc/grpc/+/chromium-deps/2016-08-17/examples/python/README.md

You may want to clone this repository:
https://github.com/grpc/grpc

(Look in the directory for the language of your choice; it should have an "examples" directory.)

For using gRPC with Python you can install a certain package; for assistance with this, see this posting.