How Do You Filter the Output of an AWS CLI Command?

Problem scenario
You want to return only the JSON of the output that is related to a specific role — not the entire list of an “aws iam list-roles” command. What do you do?

Solution
Use the “–query” flag. Often the syntax to structure a query in the results is the word to the right of the “list-” in an AWS CLI command.

 » Read more..

How Do You Troubleshoot the kubectl ‘version “extensions/v1beta1″‘ Error Message?

Problem scenario
You run a kubectl command, but you get this problem: ‘error: unable to recognize “foobar.yaml”: no matches for kind “Deployment” in version “extensions/v1beta1″‘

What should you do?

Solution
Change your yaml file so the apiVersion setting/value works. To learn more about the acceptable values, see this posting.

 » Read more..

How Do You Create an IAM Role in AWS to Allow for Nodegroups to Be Created in EKS?

Problem scenario
In the AWS Management Console, you cannot add a Node to an EKS cluster. The “Node IAM Role” never has any option. You click the “refresh” arrow, but all you see is “No roles found. Follow the link above to create a new role.” What should you do?

Solution

  1. Install and configure the AWS CLI. If you need assistance with this,

 » Read more..

How Do You Tell If the .yaml File for a kubectl Command Will Work?

Problem scenario
You want to do some pre-testing on the .yaml file(s) you will use with kubectl. How do you validate a .yaml file has correct syntax for Kubernetes?

Possible Solution #1
Try this command:
kubectl apply –validate=true –dry-run=true –filename=nameofyourfile.yaml

Possible Solution #2
Try this website:
https://www.kubeyaml.com/

Possible Solution #3
Try kubeval: https://www.kubeval.com/

Possible Solution #4
Use Copper: https://copper.sh/

 » Read more..

How Do You Know the Syntax of the JSON for the –policy-document Flag for Adding Policies to a Role in AWS?

One of the following scenarios apply:

Problem scenario #1
You want to run a command like this:
aws iam put-role-policy –role-name contintdelete-role –policy-name DELETEPOLICY –policy-document file://adminPolicy.json

But you do not know the syntax of the adminPolicy.json.

Problem scenario #2
You are trying to use the –policy-document flag with the command “aws iam put-role-policy”. But you get this error:

An error occurred (MalformedPolicyDocument) when calling the PutRolePolicy operation: Syntax errors in policy.

 » Read more..

How Do You Read a JSON File to Extract the Value of a Given Key in a JSON File?

Problem scenario
You want to print the value of a given non-nested key in a JSON value. How can Python help you achieve this?

Solution
Here is an illustrative example. Create a file called reader.py with the following lines of code:

import json
with open(“first.json”, “r”) as reading_content:
i = reading_content.read()
j = json.loads(i)
print(j[“bird”])

Have the JSON file look like this:

cat first.json

{“bird”: {“name”: “singy”,  » Read more..

What Do You Do If CloudWatch Metrics Are Not Showing Up in the Dashboard?

Problem scenario
You used a .json file and the AWS CLI to configure customized metrics. When you go to the GUI you do not see the graphs. The commands that were run with the .json file completed without errors or problems. How do you get the web console to show the metrics you configured for various AWS components?

Possible Solution #1
CloudWatch metrics are not all necessarily graphed.

 » Read more..

How Do You Troubleshoot “The filter VolumeId” is invalid?

Problem scenario
You run an aws ec2 command and you get use the –filters flag with Name=VolumeId (consistent with the casing that you see in other AWS CLI contexts). You receive a message about “the filter VolumeId” being invalid. What should you do?

Solution
Use “volume-id” instead of “VolumeId”.

In general we find that the syntax of the name itself,

 » Read more..

How Do You Troubleshoot the Message “jq: error…Cannot iterate over null”?

Problem scenario
You are running a jq command (e.g., piping output to jq). You receive message “jq: error…Cannot iterate over null.” What should you do?

Solution
Change the word “Parameters” to “Parameter”. By omitting an “s” from “Parameters”, the error may go away.

Verify there is output. Try running the command without the “jq” utility if possible. This error can happen if there is no output to parse.

 » Read more..

How Do You Troubleshoot the Ansible Message “ERROR! the field hosts is required but was not set”?

Problem scenario
You run an ansible-playbook command, but you get “ERROR! the field hosts is required but was not set”. What should you do?

Solution
Find the hyphens beneath the top “- name” stanza. Eliminate them. For example, if your playbook looks like this:

– name: Foobar
hosts: localhost
– vars:
goodone: “blahblah”
-tasks:

Make it look like this:

– name: Foobar
hosts: localhost
vars:
goodone: “blahblah”
tasks:

Now re-run it.

 » Read more..