Skip to content

Instantly share code, notes, and snippets.

@mattgillard
Last active February 25, 2023 03:27
Show Gist options
  • Save mattgillard/018e4455fcfbc59354f51c7ed224a90a to your computer and use it in GitHub Desktop.
Save mattgillard/018e4455fcfbc59354f51c7ed224a90a to your computer and use it in GitHub Desktop.
Sample script to curl a url passed as first argument to an AWS API Gateway configured with IAM authentication (AWS_IAM)
#! /bin/bash
AWS_ACCESS_KEY_ID="$(aws configure get aws_access_key_id)"
AWS_SECRET_ACCESS_KEY="$(aws configure get aws_secret_access_key)"
AWS_SESSION_TOKEN=$(aws configure get aws_session_token)
AWS_REGION=$(aws configure get region)
# from https://gist.github.com/slawekzachcial/fe23184124763dfb82f233b5dde2394b?permalink_comment_id=4292171#gistcomment-4292171
curl --request GET -v \
"$1" \
--aws-sigv4 aws:amz:${AWS_REGION}:execute-api \
--user "${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}" \
--header "x-amz-security-token: ${AWS_SESSION_TOKEN}" \
--header 'Accept: application/json'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment