Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/Archives for aws cli

November 11, 2020

AWS CLI Using Query

Instead of using AWS and JQ to get the snapshot names, you can do it with a single command using –query.

Here are the previous commands.

/usr/bin/aws lightsail get-instance-snapshots --region us-east-1 --profile default > $snaps
cat $snaps | jq -r '.instanceSnapshots[] | .name' > $names

/usr/bin/aws lightsail get-instance-snapshots --region us-east-1 --profile default > $snaps cat $snaps | jq -r '.instanceSnapshots[] | .name' > $names

Using query.

aws lightsail get-instance-snapshots \
--query 'instanceSnapshots[*].[name]' \
--region us-east-1 \
--profile default \
--output text > $names

aws lightsail get-instance-snapshots \ --query 'instanceSnapshots[*].[name]' \ --region us-east-1 \ --profile default \ --output text > $names

August 17, 2020

AWS List of Application LB

Here’s how to display a list of application load balancers.

aws elbv2 describe-load-balancers --profile --region us-east-1

aws elbv2 describe-load-balancers --profile --region us-east-1

Here’s how to display classic load balancers.

aws elb describe-load-balancers --profile --region us-east-1

aws elb describe-load-balancers --profile --region us-east-1

August 2, 2019

AWS EFS List on AWS Backup

Here’s how to get a list of EFS on AWS Backup. Displays a list and looks for a specific tag.

#! /bin/bash
 
tmpfil="temp.txt"
output="efs-list.txt"
 
> $output
> $tmpfil
 
declare -a account=("default" "account1" "account2" "account3")
declare -a region=("us-east-1" "us-east-2" "us-west-1" "us-west-2")
 
for i in "${account[@]}"; do
  echo "===================" >> $output
  echo $i >> $output
  echo "===================" >> $output
  for j in "${region[@]}"; do
    echo $j >> $output
    echo "-------------------" >> $output
    aws efs describe-file-systems \
    --query 'FileSystems[*].[FileSystemId]' \
    --profile $i --region $j --output text >> $tmpfil
    while read -r efs; do
      echo $efs >> $output
      sleep 1s
      aws efs describe-tags --file-system-id $efs \
      --query 'Tags[?Key==`aws-backup`].{Name:Key,Value:Value}' \
      --profile $i --region $j --output text >> $output
      echo "..................." >> $output
    done < $tmpfil
    > $tmpfil
  done
done
rm $tmpfil

#! /bin/bash tmpfil="temp.txt" output="efs-list.txt" > $output > $tmpfil declare -a account=("default" "account1" "account2" "account3") declare -a region=("us-east-1" "us-east-2" "us-west-1" "us-west-2") for i in "${account[@]}"; do echo "===================" >> $output echo $i >> $output echo "===================" >> $output for j in "${region[@]}"; do echo $j >> $output echo "-------------------" >> $output aws efs describe-file-systems \ --query 'FileSystems[*].[FileSystemId]' \ --profile $i --region $j --output text >> $tmpfil while read -r efs; do echo $efs >> $output sleep 1s aws efs describe-tags --file-system-id $efs \ --query 'Tags[?Key==`aws-backup`].{Name:Key,Value:Value}' \ --profile $i --region $j --output text >> $output echo "..................." >> $output done < $tmpfil > $tmpfil done done rm $tmpfil

Output file is efs-list.txt

February 4, 2019

AWS Quarterly Report

AWS made more money than McDonalds and Qualcomm in 2018. And that’s not counting the retail business Amazon.com. For this fourth quarter, Amazon reported $7.43 billion in revenue from its cloud-computing business, up 45.3% from the same period a year earlier. For the full 2018 year, AWS brought in $25.7 billion, a 47% jump on the 2017 year.

January 4, 2019

Certificate Management Import

My previous post lightly talked about about adding SSL certificates via the AWS Console. This post talks about adding your own SSL certificate to Certificate Manager via the AWS CLI. The CLI which makes it super simple to manage. It also allows for automation as well.

aws acm import-certificate \
--certificate file://Certificate.pem \
--certificate-chain file://CertificateChain.pem \
--private-key file://PrivateKey.pem

aws acm import-certificate \ --certificate file://Certificate.pem \ --certificate-chain file://CertificateChain.pem \ --private-key file://PrivateKey.pem

If successful, it will return ARN or Amazon Resource Name.

  • 1
  • 2
  • 3
  • Next Page »
  • Cloud
  • Linux
  • Git

Copyright © 2012–2021