#!/usr/bin/env bash # # AWS ENV vars for your project (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html) # # AWS_PROFILE – Specifies the name of the CLI profile with the credentials and options to use. # This can be the name of a profile stored in a credentials (~/.aws/credentials) or config (~/.aws/config) # file, or the value default to use the default profile. If you specify this environment variable, # it overrides the behavior # of using the profile named [default] in the configuration file. # # AWS_DEFAULT_REGION – Specifies the AWS Region to send the request to. # AWS_REGION="us-east-1" AWS_PROFILE="default" #==============================================================# # LISTING CLOUDFRONT DISTROS WITH Restrict Bucket Access == NO # #==============================================================# func_aws_cloudfront_origin_access_id(){ echo "#================================================================#" echo "# LIST ALL CLOUDFRONT DISTRIBUTIONS #" echo "#================================================================#" aws cloudfront list-distributions --output table \ --query "DistributionList.Items[].[Id,DomainName,Origins.Items[].[Id]]" \ --profile ${AWS_PROFILE} --region ${AWS_REGION} aws cloudfront list-distributions --output text \ --query "DistributionList.Items[].[Id]" \ --profile ${AWS_PROFILE} --region ${AWS_REGION} > temp_aws_out.txt echo "#================================================================#" echo "# LIST ALL CLOUDFRONT ORIGIN ACCESS IDENTITY CONFIG #" echo "#================================================================#" for line in $(cat temp_aws_out.txt) do echo "#================================================================#" echo "# CLOUDFRONT DISTRIBUTION: ${line} #" echo "#================================================================#" aws cloudfront get-distribution-config --id ${line} \ --output table --query "DistributionConfig.Origins.Items[].[S3OriginConfig]" \ --profile ${AWS_PROFILE} --region ${AWS_REGION} echo "" echo "#================================================================#" echo "# PLEASE PRESS ENTER TO CONTINUE WITH THE NEXT CLOUDFRONT DISTRO #" echo "#================================================================#" read done echo "" } # main func_aws_cloudfront_origin_access_id