How Do You Connect to an EC-2 Instance in a VPC?

Problem scenario
You cannot reach the public IP address of an EC-2 instance. You get “Network connection timed out” errors. The EC-2 instance is in a VPC. You have configured the relevant Network ACLs of the VPC and the EC-2 instance’s Security Groups to allow connectivity from your workstation. What could be wrong?

Solution

  1. Make sure you have an Internet Gateway that has been created and attached to the relevant VPC.

How Do You Troubleshoot “config.status: error: Something went wrong bootstrapping makefile fragments”?

Problem scenario
You run this command: sudo ./configure –prefix=/usr/local

But you see this:

config.status: error: in `/usr/bin/make-4.3′:
config.status: error: Something went wrong bootstrapping makefile fragments
for automatic dependency tracking. Try re-running configure with the
‘–disable-dependency-tracking’ option to at least be able to build
the package (albeit without support for automatic dependency tracking).

What should you do?

Solution
Run this: sudo bash build.sh

How Do You Read a JSON File to Extract the Value of a Given Key in a JSON File?

Problem scenario
You want to print the value of a given non-nested key in a JSON value. How can Python help you achieve this?

Solution
Here is an illustrative example. Create a file called reader.py with the following lines of code:

import json
with open(“first.json”, “r”) as reading_content:
i = reading_content.read()
j = json.loads(i)
print(j[“bird”])

Have the JSON file look like this:

cat first.json

{“bird”: {“name”: “singy”, …

What Is the Syntax for Viewing ec2_instance_info Return Values in Ansible?

Problem scenario
You read about a supported data type (defined keys) in Ansible playbooks related to EC-2 servers in AWS. How do you view this data?

Solution

  1. Have a playbook (.yaml file) with the following syntax:

ec2_instance_info:
region: us-west-1
register: vara

  1. Refer to vara as a variable. Here is an example of how to see it:

debug:
msg: “{{ item.instance_id }}”
loop: “{{ vara.instances }}”

How Do You Get xargs to Execute Rather Than Print a Command?

Problem Scenario
You are writing a Bash command to craft AWS CLI commands. But the commands are not running with your xargs command. You created something like this:

aws s3 ls s3://bucketname/ | awk ‘{print “/usr/local/bin/aws s3 rm s3://bucketname/”$4}’ | xargs -L 1

But it merely displays the well-crafted AWS CLI commands. You want the commands to execute.

You tried a variation but received “xargs: awscli: No such file or directory.”

What should you do?

How Do You Unhighlight Text in Mac’s TextEdit program?

Problem scenario
You are using a Mac and modifying text with TextEdit. Some text you copied is highlighted. How do you unhighlight the text?

Solution
Highlight the text that is highlighted with the mouse. There should be two pallettes at the top of the TextEdit application. These are solid-color rectangular icons to the right of the font size and to the left of the BIU (bold,

How Do You Troubleshoot the CloudWatch Command Line Error “no outputs found, did you provide a valid config file”?

Problem scenario
You think your amazon-cloudwatch-agent.toml file has been misconfigured. You run “amazon-cloudwatch-agent-ctl” but you get an error about “no outputs found, did you provide a valid config file.” What should you do about this error?

Solution

  1. Use amazon-cloudwatch-agent-config-wizard to create the configuration file. From the command line it will walk you through step-by-step directions in text.
  2. Assuming the default configuration has been saved as “AmazonCloudWatch-linux” (based on how you responded above),

Does Automation Subsume DevOps or Does DevOps Subsume Automation?

Question
Is automation bigger than DevOps?

Answer
We think that the canonical answer is yes, automation subsumes DevOps. Some professionals think in terms of automation, and automation existed before DevOps was a word. It is well known that the Toyota Production System has influenced DevOps. Automation played a big role in the success of Sakichi Toyoda.

His “most famous invention was the automatic power loom [“a hand-operated or power-driven apparatus for weaving fabrics”,

How Do You Create a Class That Is an Iterator in Python?

Problem scenario
You want to implement an object that is an iterator in Python. What do you do to implement iterator behavior in the class?

Solution
Run this program as an example:

class Computation:

def __init__(self, max = 0):
self.max = max

def __iter__(self):
self.n = 0
return self

def __next__(self):
if self.n <= self.max:
product = 2 * self.n
self.n += 1
return product

objecta = Computation(4) # The number must be 3 or greater if you want to print something other than “None” with this program. …

How Do You Install the make Utility on Any Type of Linux?

Problem scenario
You want to install make on Linux. You want it to work on any type of Linux (e.g., Red Hat, Debian and SUSE derivatives). What should you do?

Solution
Prerequisite

Install the C language compiler. If you need assistance, see this posting: How Do You Install a C Compiler on Linux?

Procedures
Run this script:

a=$(which gcc)
echo $a” was found.”
echo “This will fail if no c compiler is installed.”
sleep 2
version=4.3
curl -L http://ftp.gnu.org/gnu/make/make-$version.tar.gz /tmp/make-$version.tar.gz
mv /tmp/make-4.3.tar.gz /usr/bin/
cd /usr/bin
tar xf make-$version.tar.gz
cd make-$version
./configure –prefix=/usr/local
rm make
bash build.sh
rm /usr/bin/make
echo “Ignore a message like this:”
echo “rm: cannot remove ‘/usr/bin/make’: No such file or directory”
echo “That message can be safely disregarded.”
ln -s /usr/bin/make-$version/make /usr/bin/make …