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,

Why Does a User Not Have Access to a VPC when The Configuration Appears to Allow For Connectivity?

Problem scenario
A user has no access to a VPC from her workstation. What are three ways a user can be given access to resources in a VPC?

Four Possible, Independent Solutions

  1. Network Access Control lists. These are IP address firewalls for the VPCs themselves. Based on the IP address of the user’s workstation, Network Access Control lists can allow or disallow traffic to the VPC.

How Do You Troubleshoot the AWS CLI Error “Invalid Document Name”?

Problem scenario
You run an AWS SSM command. You receive “An error occurred (ValidationException) when calling the CreateDocument operation: Invalid document Amazon…” What do you do to get the command to work?

Solution
Document names cannot begin with three strings (regardless of capitalization): “aws”, “amazon”, or “amzn”.

Change the document name to not have a string such as one of the above.

How Do You Solve the AWS CLI Problem where You Get “aws: error: argument –name is required”?

Problem scenario
You run an “aws” command but receive “aws: error: argument –name is required”
What do you do to troubleshoot this?

You have the “–name” flag in the command, or you know the command should work as it is written.

Solution
Are you using the word “get” instead of the word “send”? Analyze your command closely. There may be a syntax error.

How Do You Write a Python Program to Print All the VPCs in Your AWS Account?

Problem scenario
You want to list all the VPCs in your account. You are using Boto3 and Python 3. What do you do?

Solution
Run this four-line program:

import boto3
client boto3.client(‘ec2’)
response = client.describe_vpcs()
print(response)

Citation: The above was adapted from https://stackoverflow.com/questions/47329675/boto3-how-to-check-if-vpc-already-exists-before-creating-it

How Do You Use the AWS CLI to View the Targets of Routes in Route Tables in a VPC?

Problem scenario
You have a VPC with route tables. You want to search the targets to find a given value. What should you do?

Solution
As of early 2020, the output of aws describe-route-tables –filters –route-table-id abcd1234 –region us-west-2 will not include the word “target”. The value of the target in the JSON output will be the ID of the given target.

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.