How Do You Retrieve an Application-Level Secret from AWS?

Problem scenario
You want to obtain a non-database secret from AWS and you know the name of the secret (in Secrets Manager) and the region it is in. What should you do?

Solution
Prerequisites
You have installed and configured the AWS CLI. If you need assistance with this, click on this posting if you can use pip or this posting if you cannot use pip.

Procedures
Modify the program so "foobar" is the name of the secret and "us-west-2" is the name of the region of the secret. Then run the Python 3.x program below:

import boto3
import base64
from botocore.exceptions import ClientError

secret_name = "foobar"
region_name = "us-west-2"
session = boto3.session.Session()
client = session.client(
      service_name='secretsmanager',
      region_name=region_name
    )

aa=client.get_secret_value(SecretId=secret_name)
print(aa)

# If you want to confirm it worked in the web console, go to AWS Secrets Manager -> Secrets.
# There is a column called "Last retrieved" that corresponds to each Secret.  
# The date you see will be the last time it was retrieved.

How Do You Troubleshoot the Error “Secrets Manager cannot invoke the specified Lambda function.”?

Problem scenario
You try to store a secret, but you see this message:

"Your secret was created successfully but configuring rotation has failed

Secrets Manager cannot invoke the specified Lambda function. Ensure that the function policy grants access to the principal secretsmanager.amazonaws.com. "

What do you do?

Solution
Try this posting.

What is the Default Password with a Raspberry Pi?

Problem scenario
Using Raspberry Pi, you do not know the root / administrator password. For example you go to Menu -> System Tools -> Root terminal. You are prompted with "Enter the administrative password." No password works. What should you do?

Solution
We do not know. We suggest you change it if you want to know for certain. Open a regular terminal. Run this:

sudo su -
passwd
# enter the password that you want. You will not be challenged for a current password.

Python Tips when Dealing with Lists

Here are some tips when using Python and dealing with lists.

  1. Use snake_case for list variable names. For more information on coding style in Python, see the PEP 8 style guide here.
  2. Never call a variable "list". (If you are using a variable for a list, use something like small_list or big_list -- not "list".) Any word that is not a reserved word and not a built-in data type will work. You need to know the reserved words in Python because if you accidentally use them, it can cause a problem. To see words you should not try to use as variables, click here.
  3. To create a multi-dimensional array based on a variable input "n", use syntax like this:
    cool_list = [[0 for x in range(n)] for y in range(n)]
  4. To print out the contents of each row of the multi-dimensional list, see this posting.

How Do You Get PowerShell to Run Scripts?

Problem scenario
One of the following apply to you.

Problem scenario #1
You try a PowerShell command but you get an error like this "The 'Login-AzureRmAccount' command was found in the module 'AzureRM.profile', but the module could not be loaded."

OR

Problem scenario #2
You try a PowerShell command but you get an error like this:

Files\WindowsPowerShell\Modules\AzureRM.profile\5.8.2\AzureRM.Profile.psm1 cannot be
loaded because running scripts is disabled on this system.

What should you do?

Solution
Warning: This makes your Windows computer less secure. But it will allow you to run PowerShell scripts.

Procedures

  1. Open PowerShell as administrator.
  2. Run this command: set-executionpolicy remotesigned

In Python How Do You Print Just The Values of The Two-dimensional List without The Quotes, Commas or Brackets?

Problem scenario
In Python your program has a two-dimensional list. It prints out like this:

[' ', 'X', ' ', ' ', ' ']
[' ', 'X', 'X', ' ', ' ']
[' ', 'X', 'X', 'X', ' ']
[' ', 'X', 'X', 'X', 'X']

You want it to print out like this:

 X 
 XX  
 XXX 
 XXXX

Solution
Assuming that there are n rows of your matrix (aka two-dimensional array), you can print out each row without quotes, commas or brackets if you iterate through the rows like this:

for x in range(0, n):
  str_a = ''.join(map(str, newlist[x]))
  print(str_a)

# Where newlist is the two-dimensional list you want to print

How Do You Troubleshoot a Java Compilation Error “class fooBar is public, should be declared public class…”?

Problem scenario
You try to compile a java program, but you get this error:

hello.java:1: error: class HelloWorld is public, should be declared in a file named HelloWorld.java
public class HelloWorld {
^
1 error

What is wrong?

Solution
The .java file must have a name of "HelloWorld" like the public class in the error. If the .java file is called something else, it will not compile. The name must be case sensitively the same.

If you want to purchase a book on Java, you can click here.

How Do You Troubleshoot SonarQube Not Starting up Properly?

Problem scenario
SonarQube is not starting up properly. What should you do?

Possible Solution #1
For the sonar.properties file do not put "#" symbols on lines that are not completely commented out. They can cause you problems.

Possible Solution #2
You may want to click here to see more about re-installing it or troubleshooting the error.

Possible Solution #3
You may want to purchase a book on SonarQube, but we cannot guarantee these books necessarily will help you with SonarQube not starting up properly.
Sonar Code Quality Testing Essentials
SonarQube in Action
SonarQube Toolkit: best-practice templates, step-by-step work plans and maturity diagnostics

What Does SLS Stand for?

Question
You often see the initialism SLS. What does it stand for?

Answers
SLS disambiguation

1. Salt State System. SaltStack uses .sls files. "The core of the Salt State system is the SLS, or SaLt State file." (This quote was taken from this site.)

2. Scheduler Load Simulator (as in YARN SLS). To read more about this, try this website.

3. Softlanding Linux System

4. Spacelab Life Sciences

5. Service Level Specification

6. It is an alias for select-string in PowerShell.

7. It can stand for scalable login sequence.

8. Outside of I.T. SLS can stand for service, luxury, and style.

How Do You Troubleshoot an External Monitor That Does Not Work and You Cannot See Any Reference to It in the Windows Control Panel?

Problem scenario
With an HDMI cable you cannot get an external monitor that is connected to your Windows computer to work. In the Control Panel section for "Screen Resolution" there is a drop down menu for "Display." This will give some descriptive identification of your monitor when the monitor is working properly. It does not show an attached monitor. What should you do if the "Display" drop down in Screen Resolution (in the Windows Control Panel) does not show your monitor and the external monitor is not working to display any output?

Possible solution #1
Can you test the monitor and cable with another computer? The cable could be bad.

Possible solution #2
Assuming the monitor and cable work, open File Explorer and browse to "This PC". Right click "This PC" and go to "Manage". Go to Computer Management -> System Tools -> Device Manager -> Display Adapters. Double click the item underneath "Display Adapters" (e.g., "Intel HD Graphics). Go to the "Drivers" tab. Click "Rollback Driver". If "Rollback Driver" is grayed out, try "Update Driver" -- even if you have no access to a network or the internet. Changing the driver here can enable the external monitor to work.

Possible solution #3
If you need a new monitor, you can purchase one here.