How Do You Configure an External Monitor’s Placement with a Macbook Pro?

Problem scenario
You have a Mac laptop. You have connected a separate monitor. To get your mouse one the screen, you have to move the direction of the mouse in a different direction relative to the physical location of where you see this external monitor. You have to commit to memory where to move the mouse. You want the external monitor to be mouse-reachable in the direction that it is in front of you. How can you get the position to match?

Solution
Go to the Apple symbol in the upper-right hand corner. Go to System Preferences -> Displays. Click on "Gather Windows." Go to Arrangement. Click on the blue rectangles to identify which monitor is which. Move the rectangles in a way that reflects their physical location.

How Do You Create a Callable Function in Java outside of the “main” Section?

Problem scenario
You have a public static void main (String[] args) portion of your Java program. You want to have a subroutine such as a function outside of this section. How do you code this?

Solution
In Java methods are components of an object that perform an action on the object themselves. We therefore use the term "method" here and not "function". Here is an example of a method inside a class that runs from the public static void main(String[] args) section of code:

public class ContClass {
  static void contMethod() {
    System.out.println("I just got executed!");
  }

  public static void main(String[] args) {
    contMethod();
  }
}

Call the above file ContClass.java. Run these commands:

javac ContClass.java
java ContClass

How Do You Troubleshoot the Error “Could not find suitable distribution for Requirement.parse(‘botocore==2.0.0dev11’)”?

Problem scenario
You try to install the AWS CLI version 2.x

You run this command:

$ sudo python3 setup.py install

You get a message like this:

Processing dependencies for awscli==2.0.7
Searching for botocore==2.0.0dev11
Reading https://pypi.org/simple/botocore/
No local packages or working download links found for botocore==2.0.0dev11
error: Could not find suitable distribution for Requirement.parse('botocore==2.0.0dev11')

What should you do?

Possible solution (or workaround)
Abort. Try installing AWS CLI 1.x. You can use these directions as a guide.

How Do You Use a New IAM User Account?

Problem scenario
You want to assume an IAM user from a command line of an EC-2 instance. What do you do?

Solution
Prerequisite
This solution requires you have the access key and its secret key in text.

Procedures

  1. Run this command: aws configure
  2. Respond to the next two prompts accordingly (so that it will be configured to use the IAM user account of your choice). You may want to view an article about creating a new IAM user.

How Do You Install Django on a CentOS/RHEL/Fedora server?

Problem scenario
You want to install Django and have it working for browsing from a desktop workstation. You do not want to leverage Django's API functionality. How do you install and configure Django from scratch?

Prerequisite
pip3 is probably installed. If you are not sure, you could run this: sudo find / -name pip3

You must have pip or pip3 installed. If you need assistance, see this posting.

Procedures

  1. Run these two commands:
sudo yum -y install python3 mod_wsgi httpd
sudo python3 -m pip install Django
  1. Find where the core subdirectory of Django is with this command:
    sudo find / -name core -type d | grep django
  2. The parent directory, of the "core" directory found above, should have permissions configured such that the user who will start and stop Django services has the ability to write to it. Here is an example (but your path and method may vary):

sudo chown -R ec2-user:ec2-user /usr/local/lib/python3.6/site-packages/django/

  1. Run this command but change "contint" to the name your project:

django-admin startproject contint

  1. Find the external IP address of the server with this command: curl icanhazip.com
  2. Back up the settings.py file that was created from the django-admin command. Find it (e.g., with sudo find / -name settings.py | grep contint). After it is backed up, change the original.
  3. Edit the file (with the details in the step below). Here is an example of how to edit it:
    vi /usr/local/lib/python3.6/site-packages/django/mysite/mysite/settings.py
  4. Find the ALLOWED_HOSTS stanza. Change it to look like this but replace "x.x.x.x" with the external IP address of the server:

ALLOWED_HOSTS = ['x.x.x.x']

Add or keep the single quotes inside the brackets. Save the changes and exit the file.

  1. Start the Django server (you may or many not need to change the path to the manage.py file):

python3 /usr/local/lib/python3.6/site-packages/django/contint/manage.py runserver 0.0.0.0:4466

  1. Draft this URL, but replace x.x.x.x with the external IP address of the server: http://x.x.x.x:4466
  2. Open a web browser and go to the URL.

How Do You Troubleshoot “error occurred (AccessDeniedException) when calling the CreateCluster operation: User: … is not authorized to perform: iam:PassRole on resource:…”?

Problem scenario
You run this command:

aws eks create-cluster --name contint --role-arn arn:aws:iam::12345678910:role/contintrole --resources-vpc-config subnetIds=subnet-a123456,subnet-b77777777,securityGroupIds=sg-2e324234254

You get this error:

An error occurred (AccessDeniedException) when calling the CreateCluster operation: User: arn:aws:iam::12345678910:user/contintuser is not authorized to perform: iam:PassRole on resource: arn:aws:iam::12345678910:role/contintrole

What should you do?

Solution
1. Log into the AWS Console.
2. Go to IAM -> Users
3. Click on the user in question
4. Click on "Add Inline Policy"
5. Add this policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "iam:GetRole",
                "iam:PassRole"
            ],
            "Resource": "arn:aws:iam::12345678910:role/contintrole"
        }
    ]
}

6. Click "Review Policy"
7. Enter a name
8. Click "Save policy". Wait 10 minutes for the changes to take effect.

How Do You Troubleshoot the AWS CLI Message “An error occurred (AccessDeniedException) when calling the ListClusters operation”?

Problem scenario
You run this command aws eks list-clusters, but you get this message:

"An error occurred (AccessDeniedException) when calling the ListClusters operation: User: arn:aws:iam::12345678910:user/jdoe is not authorized to perform: eks:ListClusters on resource: arn:aws:eks:us-west-1:12345678910:cluster/*"

What should you do?

Solution
1. Go to the AWS Console and log in.
2. Go to IAM -> Users
3. Click on the user's account.
4. Click on "Add Inline Policy"
5. Click on the JSON tab
Add this content:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "ekscontintadmin",
            "Effect": "Allow",
            "Action": "eks:*",
            "Resource": "*"
        }
    ]
}

6. Click "Review policy"
7. Give a name to it
8. Click "Save policy". Adding an inline policy to a role in AWS IAM can take 10 minutes to take effect. (It is not like Security Groups.)

How Do You Troubleshoot the EKS Error “AccessDeniedException…Clusters operation: Account …is not authorized to use this service”?

Problem scenario
In one region, but not another, you get this error with an "aws eks list-clusters" command:

"An error occurred (AccessDeniedException) when calling the ListClusters operation: Account 12345678910 is not authorized to use this service"

You know that IAM does not require region selection. What is causing this eks error?

Solution
Is your AWS CLI configured to use a region that eks does not support? To find out, try changing the region to us-east-1 (e.g., by running the "aws configure" command and responding to the prompts). If you change it to "us-east-1" and do not see the above error messages when you run the command(s) that created those messages, you should be ok.