Why Would Boto3 Not Show a Peering Connection That the AWS CLI Shows?

Problem scenario
You have found an AWS CLI command that shows you output consistent with the console. You run this:

aws ec2 describe-vpc-peering-connection --region us-west-2 | grep pcx-abcd1234

The results show you a peering connection called pcx-abcd1234

You run this from a Python3 interpreter prompt:

import boto3
foo = boto3.resource('ec2')
foo.describe_vpc_peering.connections()
print(foo)

You then search the output for pcx-abcd1234. You do not see it. Using different methods and syntax, you can never see pcx-abcd1234 in Boto3.

Using the AWS CLI, you can readily find pcx-abcd1234. Using the web console you can find it too.

You can find other peering connections with Boto3. One peering connection is elusive however.

Why would Boto3 results be discrepant from the CLI?

Solution
In Python, you need a stanza like this with the region_name and the profile setting to make it consistent with your AWS CLI:

boto3.setup_default_session(profile_name="foobar", region='us-west-2')

If you want to see what your AWS CLI is using, see the .aws/config file. If the profile and region are not the same between the AWS CLI and Boto3, you could get seemingly inconsistent results in the output regarding VPC components.

How Do You Find the Minimum Password Length in AWS?

Problem scenario
You are now an AWS administrator for an existing company. You want to find out what the password requirements are (e.g., minimum length, maximum duration, complexity requirements etc.) for IAM users. What do you do to find the minimum length?

Solution
Log into the AWS console. Go to IAM -> Account Settings.

In DevOps, What Is a Manifest?

Problem scenario
You have read about manifests in books or articles that pertain to DevOps, but are not sure what they are. What is a manifest in the I.T. field?

Answer
Manifest: Syntactic text, usually a file with a variety of details, that is used for the purpose of convergence towards a desired state.

The definition above applies to a Puppet manifest or a Kubernetes manifest. A Puppet manifest is a .pp file with the desired state configuration listed using Puppet's domain-specific language. For more information about Kubernetes manifests, see this Kubernetes website article or this internal posting. In I.T., but not with DevOps specifically, a manifest may be defined differently. Here are some examples:

Merriam Webster's dictionary has different definitions for the noun "manifest". One considers a manifest to be a process of manifesting. This is similar to Kubernetes or Puppet manifests when they are being processed. Another definition of manifest is "a list of passengers or an invoice of cargo" on a transportation vehicle. This is similar to the HTML5 manifest.

How Do You Troubleshoot the Java Compilation Problem “error expected … illegal start of type”?

Problem scenario
When trying to compile a Java program, you get this output:

ContInt.java:15: error: expected
System.out.println("test");
^
ContInt.java:15: error: illegal start of type
System.out.println("test");
^

What do you do?

Solution
Create a class for the System.out.println statement to be in.

Here is code that would cause the error:

import java.util.Scanner;

public class TicTacToe {

public static void main(String[] args) {
   System.out.println("Please enter text, then press enter: ");
   Scanner x = new Scanner(System.in);
   String var1 = x.next();
   System.out.println(var1);
   }

class board {
   System.out.println("test");
  }

}

Here is code that would not cause the error:

import java.util.Scanner;

public class TicTacToe {

public static void main(String[] args) {
   System.out.println("Please enter text, then press enter: ");
   Scanner x = new Scanner(System.in);
   String var1 = x.next();
   System.out.println(var1);
   }

class board {
   board() {
   System.out.println("test");
   }
  }

}

How Do You Use Amazon Simple Queue Service?

Problem scenario
You want to use Amazon SQS. How do you use this in AWS?

Solution

  1. Log into the AWS console.
  2. Go here: https://console.aws.amazon.com/sqs/
  3. Click "Get Started"
  4. Enter a queue name (e.g., contintqueue)
  5. Click "Quick-Create Queue"
  6. Click the radio button associated with the queue. Then click "Queue Actions" (the button near the top left).
  7. Click "Send a message"
  8. Enter some text and click "Send Message."
  9. Click "Close."
  10. Click "Queue Actions" again.
  11. Click "View/Delete Messages"
  12. Click "Start Polling for Messages"
  13. Click on the message you want to view.

How Do You Troubleshoot “error: no suitable method found for toString(String)”?

Problem scenario
You are trying to print out a multi-dimensional array in Java. When you try to compile your program, you get this:

error: no suitable method found for toString(String)
System.out.println(Arrays.toString(Arrays.toString(var1)));
^
method Arrays.toString(long[]) is not applicable
(argument mismatch; String cannot be converted to long[])

What should you do?

Solution
You need to pass a one-dimensional array to Arrays.toString in the System.out.println statement.

Are you using Arrays.toString in a nested way?

Assuming you have a two-dimensional array called "arr2d_var1", you may have tried this:

System.out.println(Arrays.toString(Arrays.toString(arr2d_var1)));

Instead of using Arrays.toString in a nested way, make sure you have a single-dimensional array as the argument for Arrays.toString. Here is a corrected example:

System.out.println(Arrays.toString(arr2d_var1[0]));

How Do You Install Apache Presto on Any Type of Linux?

Problem scenario
You want to install Apache Presto to try it out. How do you do this with a script that will work on Debian/Ubuntu, CentOS/RHEL/Fedora and/or SUSE?

Solution
Prerequisites
i. You have Python installed as "python" (not just python3). If you need assistance installing Python, see this posting. Verify that python --version works. You may need to use sudo ln -s $(which python) /bin/python

ii. You have Java installed. If you need assistance, see this posting.

Procedures
1. Use this script (e.g., like "sudo bash /tmp/presto.sh" and read the last few lines as they provide for manual steps done from different terminal windows):

version=0.240
#0.149 was a stable version
# The next version of this should be .343.  It doesn't have a launcher.py file.  It was seriously refactored. 
# Some lines will have to be commented out or deleted.  The future URLs will be like this:
# https://repo1.maven.org/maven2/io/prestosql/presto-server/343/presto-server-343.tar.gz
# https://repo1.maven.org/maven2/io/prestosql/presto-cli/343/presto-cli-343-executable.jar


echo "This assumes that Python and Java have already been installed"
echo "This script requires Python 3 unlike normal versions of Presto.  You could modify the script where it downloads the launcher.py file"
echo "That launcher.py file is the only thing that requires Python 3.  The installation media it uses would otherwise default to utilize Python 2"
echo "**************************************************************************************"
echo "This script needs access to the internet to download the installation media for Presto"
curl https://repo1.maven.org/maven2/com/facebook/presto/presto-server/$version/presto-server-$version.tar.gz > /tmp/presto-server-$version.tar.gz
cp /tmp/presto-server-$version.tar.gz /opt/
cd /opt/
sudo tar -xvf presto-server-$version.tar.gz
cd presto-server-$version
mkdir /data # With RHEL servers, this is unnecessary.
cd /data
mkdir presto
cd /opt/presto-server-$version
mkdir etc
echo "Getting special files from GitHub.  If the .config and .properties files have trailing spaces or spaces near = signs, there can be issues."
echo "That is why we get the special files known to work from GitHub"
curl https://raw.githubusercontent.com/ContinualIntegration/presto/master/config.properties > /tmp/config.properties
curl https://raw.githubusercontent.com/ContinualIntegration/presto/master/jvm.config > /tmp/jvm.config
curl https://raw.githubusercontent.com/ContinualIntegration/presto/master/log.properties > /tmp/log.properties
curl https://raw.githubusercontent.com/ContinualIntegration/presto/master/node.properties > /tmp/node.properties
curl https://raw.githubusercontent.com/ContinualIntegration/presto/master/launcher.py > /tmp/launcher.py

mv /tmp/config.properties /opt/presto-server-$version/etc/config.properties
mv /tmp/jvm.config /opt/presto-server-$version/etc/jvm.config
mv /tmp/log.properties /opt/presto-server-$version/etc/log.properties
mv /tmp/node.properties /opt/presto-server-$version/etc/node.properties
mv /tmp/launcher.py /opt/presto-server-$version/bin/launcher.py

curl https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/$version/presto-cli-$version-executable.jar > /tmp/presto-cli-$version-executable.jar

cp /tmp/presto-cli-$version-executable.jar /bin/presto
chmod +x /bin/presto
chmod +x /opt/presto-server-$version/bin/launcher.py
echo "*************************************"
echo "The installation script has finished."
echo "*************************************"
echo "Run these five Linux commands and the last Presto SQL-like command:
cd /opt/presto-server-$version/bin
sudo ./launcher start
sudo ./launcher run -Djdk.attach.allowAttachSelf=true
cd /bin/
./presto --server localhost:8080 --catalog jmx --schema default
You should see the last line look like this:   com.facebook.presto.server.PrestoServer ======== SERVER STARTED ========
If the last line does not look like that, try to "./presto --server localhost:8080 --catalog jmx --schema default" command again.

After you have run those commands and are at the Presto CLI, run this command:
SELECT * FROM system.runtime.nodes;
"

2. Most likely you will need a second terminal to issue the final two Linux commands and the Presto SQL-like command as described at the bottom of the script above. Some error messages are ignorable, while sometimes you have to run the ./presto --server localhost:8080 --catalog jmx --schema default command twice.

FFR
This link may be of assistance to you for more installation media and peripherals: