How Do You Grant a Role The Ability to Run a Lambda Function?

Problem scenario
You have a role that you want to execute a Lambda function. What do you do?

Solution
1. Log into the AWS console.
2. Go to IAM -> Roles
3. Click on the role you want to change.
4. Click on "Attach policies"
5. In the "Filter policies" field search for "lambda" with no quotes
6. Check the box "AWSLambdaFullAccess"
7. Click "Attach Policy"

What Database Does Elastic Search Use?

Question
What SQL database underlies Elastic Search?

Answer
There is no relational database for Elastic Search.

Elastic Search will have a cluster that is composed of nodes. Nodes are composed of indexes. Indexes are supported by shards. Shards have primary and replica copies. The replica copies vary. The shards are essentially Lucene indexes (according to this site).

In the Context of Linux, what is a System Call?

Question
In the context of Linux, what is a system call?

Answer
A system call is a special OS function with a human-readable name (according to page 11 of Sobell's A Practical Guide to Fedora and RedHat Enterprise Linux). Such a function allows for programs to interact with the kernel (according to page 11 of Sobell's A Practical Guide to Fedora and RedHat Enterprise Linux). The kernel facilitates getting resources or interacting with the devices (according to page 11 of Sobell's A Practical Guide to Fedora and RedHat Enterprise Linux).

Examples of system calls include exec(), fork(), gethostbyname(), isatty(), setlocale(), sleep(), strtok(), and write(). (All of these except write() were taken from page 1333 of Sobell's A Practical Guide to Fedora and RedHat Enterprise Linux).

A system call is traditionally made from userspace into kernelspace (according to IBM). To learn more about the differences between userspace and kernelspace, see this posting "Can the Kernel Access Hardware Directly?"

A useful way to debug system calls is with the strace command.

To view the man page of system calls, from a Linux command prompt use man 2 nameofsystemcall (where "nameofsystemcall" is the system call you want to read about).

The man syscalls page says "[t]he system call is the fundamental interface between an application and the Linux kernel."

To learn more about system calls (such as exit, ulimit, umask, chown, mount, and nice), run this command: man syscalls

Using man syscall is also helpful.

How Do You Troubleshoot the boto Message “NoRegionError”?

Problem scenarios (one or both of the following are happening)
#1 You are getting "botocore.exceptions.NoRegionError: You must specify a region" when you run a Python program (that involves boto and AWS).

#2 You are trying to create a session with a Python/boto program. You are printing out the Session information in your Python program using boto but you see this:

Session(region_name=None)

What should you do?

Possible Solution #1
If the AWS CLI has been installed, do the following as the user who tried to run the program that caused this problem:

cd ~
ls -lhd .aws

How are the permissions set? If you see drw-------, then the error can happen. Those settings will cause the problem. To fix the problem you may need to run this: chmod u+x .aws

A less secure alternative solution would be to run this command: sudo chmod 755 .aws

Possible Solution #2
A pragmatic solution is to install and configure the AWS CLI. Once that is working, the problem should not happen. If you are using pip, see these instructions to install the AWS CLI. Otherwise see these instructions to install the AWS CLI. You may want to try to reinstall or reconfigure the AWS CLI.

Possible Solution #3
Examine the .aws/config file. Run these commands:

cd ~
cd .aws
cat config

If there is no "region =" stanza, that can cause the "NoRegionError" problem. Here is an example of a correctly configured config file:

[default]
region = us-east-2

Possible Solution #4
Are the credentials to interact with your AWS instance correct? Your Python program may use an IAM user that you do not realize it is using. Or those credentials are insufficient. Do the credentials have the ability to fetch the region you assigned?

You can test what the variable region_name is being assigned to. It is possible the logic is not assigning it to a value when the Session function is invoked.

Once the AWS CLI has been installed and configured, your Python program should recognize the region in the session. Here is a Python 3 program that can determine the AWS IAM user context your boto program would run as:

import subprocess
subprocess.run(["aws", "sts", "get-caller-identity"])

How Do You Install and Configure the rdf4j Server and Workbench GUI?

Problem scenario
You want to use the rdf4j (Resource Description Framework for Java). You want to install the rdf4j server and workbench. You are using Debian 9 Linux. What should you do?

Solution
Prerequisites
i. We recommend having a 30 GB of hard disk free.

ii. We recommend having 5.75 GB of RAM (it can be a combination of RAM and swap space). If you need assistance with creating more swap space, see this posting.

iii. Install Java. Run this: sudo apt -y install default-jdk

iv. Install Tomcat. We have not had good luck with installing Tomcat from binary installation media; if you want directions for installing Tomcat from source installation media, see this posting "How Do You Get Apache Tomcat to Work from the Source Installation Media?"

v. You have unzip installed. For Debian or Ubuntu Linux, run this: sudo apt -y install unzip

Procedures
1.a. Install the RDF4J. Bring the .zip file over from here https://rdf4j.eclipse.org/download/

Click on the SDK that has a .zip extension near the top. You will have to make some more clicks and download it to your workstation (as we do not know how to download it directly to your Linux server). Using WinSCP you can bring it over to the Linux server.

1.b. Place the file in the webapps directory of the Tomcat installation. It may be here: /opt/tomcat9/webapps/

1.c. Run this command: sudo unzip nameOffile.zip

2.a. Go into the newly created directory from this eclipse zipped file. Go into the war directory. Copy the two .war files to the webapps directory (e.g., /opt/tomcat9/webapps/).

3.a. Start Tomcat if it was not running (e.g., sudo bash /opt/tomcat9/bin/catalina.sh start). (If it was running, wait a minute for it to create rdf4j-workbench and rdf4j-server directories in webapps. Tomcat will automatically do this from the .war files placed in it; Tomcat does not need to be restarted.)

3.b. Make a note of the external IP address of the Linux server. If you don't know it, run this command (with no quotes): curl icanhazip.com

4.a. Compose two URLs like these but substitute x.x.x.x with the IP address of the server:

http://x.x.x.x:8080/rdf4j-workbench

http://x.x.x.x:8080/rdf4j-server

4.b. Open a web browser. Go to each URL. You should see a dashboard with some orange font for each one.

FYI

  • "Rya is a scalable RDF data management system built on top of Apache Accumulo®." (Taken from https://rya.apache.org/)
  • If you want directions on how to install Rya, see this posting.

Why Does Your Python Program Return “function at” with a Hexadecimal?

Problem scenario
You run a Python program. A value of a variable is printing "function at" with a hexadecimal. How can the variable be the intended value of the function and not this meta data of the Python interpreter or just-in-time compiler?

Solution
Use "()" at the end of the function invocation. This syntax is necessary. Here is an example that will cause the problem:

def cool():
   a = "foobar"
   return a

q = cool
print(q)

Here is an example that will not cause the problem:

def cool():
   a = "foobar"
   return a

q = cool()
print(q)

What Utility Can Provide Encryption and High Compression for Files on Linux and How Would You Use It?

Problem scenario
You want to use the same command for encryption and compression. You want the compression to be high (for maximum data density for backups and storage purposes). You can install a new package. What should you do?

Solution
Use 7zip.

Prerequisite
Try whereis 7z to see if 7zip is installed. If it is not, install 7zip.

If you are using Debian or Ubuntu Linux, run this: sudo apt-get -y install p7zip-full

If you are running Linux SUSE, run this: sudo zypper -n install p7zip

If you are using CentOS or Fedora, run these three commands:

curl -s https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-16.02-10.el7.x86_64.rpm > /tmp/p7zip-16.02-10.el7.x86_64.rpm

curl -s https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-plugins-16.02-10.el7.x86_64.rpm > /tmp/p7zip-plugins-16.02-10.el7.x86_64.rpm

sudo rpm -i /tmp/p7zip-plugins-16.02-10.el7.x86_64.rpm /tmp/p7zip-16.02-10.el7.x86_64.rpm

Procedure
Use tar before you use 7zip if you want to retain the user and group of the files that will be compressed. The 7z man page says " DO NOT USE the 7-zip format for backup purpose on Linux/Unix because : - 7-zip does not store the owner/group of the file."

If you do not need to retain the user and group associated with the file named goodfile and you want to create a compressed copy of it that is encrypted called good.7z, run this command:

7z a -p -mx=9 -mhe -t7z good.7z goodfile

We find the 7zip excels in the compression ratio compared to the zip utility.

You can move a copy to a different directory, then run this command to extract a regular version of this file that was encrypted and compressed in good.7z:
7z e good.7z

If you only need to encrypt, see this external page for examples of different tools. (However, beware of drawbacks of GPG and openssl. This external posting provides some relevant warnings.)

If you only need to compress, see this external page for examples of different tools.

How Do You Create a Windows VM in Google Cloud Platform with the Console?

Problem scenario
You want to create a Windows server in Google Cloud Platform. How do you do this?

Solution
1. Log into Google Cloud Platform.
2. Click the hamburger icon in the upper left hand corner (the icon with three horizontal bars stacked onto each other).
3. Go to Compute Engine -> VM Instances
4. Click "Create Instance"
5. Fill out the options you want. Under "Boot disk" click "Change." Remember that Windows Core has no GUI desktop. It is a command line version of Windows (with just a character prompt). For a more common Windows server, you may want to use the Windows Server 2016 with the Desktop Experience.
6. Click "Create".
7. Wait for it to finish being created. When you want to log into it, click the black arrow pointing down under the "Connect" column.
8. Click "Set Windows password".
9. Enter the username for which you want to change the password for. (Remember this username for later.) Then click "Set."
10. Copy the password.
11. Open Remote Desktop (e.g, open a command prompt and type "mstsc.exe" with no quotes and press enter).
12. Enter the external IP address of the VM.
13. Enter the username and password involved above.