AWS getVPCnameById

I was recently looking at retrieving a VPC’s Name based on its id. Here is the Python/Boto3 implementation

from boto3.session import Session
session = Session(aws_access_key_id='aaaa',aws_secret_access_key='XXX',region_name='eu-west-1')
ec2 = session.resource('ec2')

vpc = ec2.Vpc('vpc-6661b904')
vpc.tags[0]['Value']

The one liner version for AWS cli is

aws ec2 describe-vpcs --vpc-ids vpc-6188b904 --query "Vpcs[0].Tags[?Key=='Name'].Value[]" --output text