Skip to content

Commit

Permalink
Add script and instructions to setup AWS env
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenbeam committed Sep 19, 2024
1 parent 1b90512 commit 47eea5a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ for the details.

* Process science data and stage it for Cumulus:

# Source the AWS profile (once) before running 'process'-- use 'default' or a named profile
$ source scripts/env.sh default
$ instameta process --config example/modscg.ini

* Exit the Poetry shell:
Expand Down
25 changes: 25 additions & 0 deletions scripts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

if (( $# != 1 )); then
echo "Usage: source env.sh aws_profile_name"
echo " where aws_profile_name is an AWS CLI named profile"
echo " https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html"
exit 1
else
export AWS_PROFILE=$1

AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id --profile "$AWS_PROFILE")
AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key --profile "$AWS_PROFILE")
AWS_REGION=$(aws configure get region --profile "$AWS_PROFILE" || echo "$AWS_DEFAULT_REGION")
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text)

export AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY
export AWS_REGION
export AWS_ACCOUNT_ID

echo "AWS environment:"
echo " AWS_PROFILE: $AWS_PROFILE"
echo " AWS_REGION: $AWS_REGION"
echo " AWS_ACCOUNT_ID: $AWS_ACCOUNT_ID"
fi

0 comments on commit 47eea5a

Please sign in to comment.