What Should The Permissions of the kubectl File Be on a Linux server?

Problem scenario
You copied the kubectl file. You are not sure what the permissions it should have. When you try to execute it, you get "Permission denied". What should you do?

Solution
We recommend using this (after you change directories to the one that has the kubectl file): sudo chmod 777 kubectl

When you use conjure-up, it makes kubectl have 777 permissions. We find this to be a reasonable standard that works. It allows for other users to use it. The ownership and group associated with the kubectl file is root by default when you deploy kubernetes with conjure-up. A disadvantage of this solution is that the kubectl command is important and powerful, and any user will be able to run it after you make this change. Any user could also delete the kubectl file if you run the command above.

In AWS’ KMS What Is the Difference between Administrative Permissions and Usage Permissions of a CMK?

Question
A CMK is an encryption key. In Amazon Web Services, for CMKs (Customer Master Keys) in KMS (Key Management Service), what is the difference between administrative permissions and key usage permissions?

Answer
Usage permissions enable (either IAM users or roles) to encrypt and decrypt data with the AWS KMS API.

Administrative permissions for a CMK allows either an IAM user or role to give usage permissions to other IAM users or roles through the API (and sometimes the web console).

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.