AWS CLI EC2 Describe Tags

Here’s how to get a list of EC2 tags.

aws ec2 describe-tags \
--filters "Name=resource-id,Values=i-xxxxxxxxxxxxx" \
--query 'Tags[][Key,Value]'  \
--profile default \
--region us-east-1 \
--output text

Install AWS CLI on Ubuntu 16.04

I ran into an issue with AWS CLI on Ubuntu 16.04. I was getting this error, “AWSHTTPSConnection’ object has no attribute ‘ssl_context” every time I try to do a simple “aws s3 ls” command. So, here’s the fix.

Assuming you installed “awscli” using apt. Go ahead and uninstall it.

apt remove awscli

Install awscli using pip instead.

apt install python-pip
pip install awscli
aws --version

If this is a fresh install, you may have to run “aws configure.”

AWS ACM Certificate Import

Here’s how to import a SSL certificate into AWS Certificate Manager.

aws acm import-certificate \
--certificate file://example.crt \
--private-key file://example.key \
--certificate-chain file://example-bundle.crt

AWS CLI List ACM Certificates

If you’ve imported or created a SSL certificate via AWS Certificate Manager, here’s the CLI to display a list of certificates.

aws acm list-certificates

Once you have the arn, you can describe certificate. Get the arn from the output above.

aws acm describe-certificate --certificate-arn arn-xxxxxxxxxxxxxxxxxx