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

Output file is efs-list.txt

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.

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

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

AWS EFS Userdata

If you want to auto mount the EFS volumes when the instance is created, add the following script to userdata:

#cloud-config
repo_update: true
repo_upgrade: all
 
packages:
- amazon-efs-utils
 
runcmd:
- file_system_id_01=fs-12345678
- file_system_id_02=fs-34593405
- efs_directory_01=/mnt/efs
- efs_directory_02=/mnt/efs2
 
- mkdir -p ${efs_directory_01}
- mkdir -p ${efs_directory_02}
 
- echo "${file_system_id_01}:/ ${efs_directory_01} efs tls,_netdev" >> /etc/fstab
- echo "${file_system_id_02}:/ ${efs_directory_02} efs tls,_netdev" >> /etc/fstab
 
- mount -a -t efs defaults

Just add more if you have more mounts.