This shell script snapshots the current state of AWS resources and writes it to JSON files
This utility produces snapshots that:
- Answer the question: "What do we have in this AWS account?"
- Provide disaster recovery data source capability from account or service deletion or other causes
- Provide data source capability for account or service clone/backup
- Create an audit trail of AWS service(s) state
This utility provides service snapshot functionality unavailable in the AWS console or directly via the AWS CLI API.
This utility can:
- Capture the current state of selected or all AWS Services in a selected or all AWS regions
- Write the current service state to JSON files
This utility produces a summary report listing:
- AWS account and alias
- AWS region
- Driver file name
- The number of regions snapshotted
- The number of services snapshotted
- Snapshot files location
- List of regions snapshotted
- List of services snapshotted
- Instantiate a local or EC2 Linux instance
- Install or update the AWS CLI utilities
- The AWS CLI utilities are pre-installed on AWS EC2 Linux instances
- To update on an AWS EC2 instance:
$ sudo pip install --upgrade awscli
- Create an AWS CLI named profile that includes the required IAM permissions
- See the "Prerequisites" section for the required IAM permissions
- To create an AWS CLI named profile:
$ aws configure --profile MyProfileName
- AWS CLI named profile documentation is here: Named Profiles
- Install the bash shell
- The bash shell is included in most distributions and is pre-installed on AWS EC2 Linux instances
- Install jq
- To install jq on AWS EC2:
$ sudo yum install jq -y
- To install jq on AWS EC2:
- Download this utility script or create a local copy and run it on the local or EC2 Linux instance
- Example:
$ bash ./aws-services-snapshot.sh -p AWS_CLI_profile -d MyDriverFile -r AWS_region
- Example:
- bash - Linux shell
- jq - JSON wrangler
- AWS CLI - command line utilities (pre-installed on AWS AMIs)
- File 'aws-services-snapshot-driver.txt' or custom driver file containing AWS describe/list commands
- File 'aws-services-snapshot-driver-global.txt' containing AWS global services (services that are not limited to an AWS region, e.g. IAM, S3, cloudfront, etc.)
- AWS CLI profile with IAM permissions for the AWS CLI commands:
- aws ec2 describe-instances (used to test for valid -r region )
- aws sts get-caller-identity (used to pull account number )
- aws iam list-account-aliases (used to pull account alias )
- AWS CLI profile with IAM permissions for the AWS CLI 'service describe' and 'service list' commands included in the aws-snapshot-services-driver.txt file or custom driver file
To execute the utility:
- Example:
$ bash ./aws-services-snapshot.sh -p AWS_CLI_profile -d MyDriverFile -r AWS_region
To directly execute the utility:
- Set the execute flag:
$ chmod +x aws-services-snapshot.sh
- Execute the utility
- Example:
$ ./aws-services-snapshot.sh -p AWS_CLI_profile -d MyDriverFile -r AWS_region
- Example:
- Summary report
- JSON 'all regions - all services' file
- JSON 'all services' file for each region
- JSON snapshot files for each service
- Info log (execute with the
-g y
parameter)- Example:
$ bash ./aws-services-snapshot.sh -p AWS_CLI_profile -d MyDriverFile -r AWS_region -g y
- Example:
- Debug log (execute with the
-g z
parameter)- Example:
$ bash ./aws-services-snapshot.sh -p AWS_CLI_profile -d MyDriverFile -r AWS_region -g z
- Example:
- Console verbose mode (execute with the
-b y
parameter)- Example:
$ bash ./aws-services-snapshot.sh -p AWS_CLI_profile -d MyDriverFile -r AWS_region -b y
- Example:
Please read CONTRIBUTING.md for the process for submitting pull requests to us.
We use SemVer for versioning.
- Douglas Hackney - dhackney
This project is licensed under the MIT License - see the LICENSE.md file for details
- Key jq answers by jq170727
- Progress bar
- Dynamic headers fprint
- Menu
- Remove duplicate lines and retain line order
- Countless other jq and bash/shell man pages, Q&A, posts, examples, tutorials, etc. from various sources