Skip to content

Instantly share code, notes, and snippets.

@smellman
Created May 29, 2015 04:27
Show Gist options
  • Select an option

  • Save smellman/a148f40195af43f8d081 to your computer and use it in GitHub Desktop.

Select an option

Save smellman/a148f40195af43f8d081 to your computer and use it in GitHub Desktop.
awscliの設定をansibleに渡すための何か
#!/bin/bash
credentials=~/.aws/credentials
profile=$1
# ini parser: http://qiita.com/srea/items/28073bc90d65eed0856d
eval `sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \
-e 's/;.*$//' \
-e 's/[[:space:]]*$//' \
-e 's/^[[:space:]]*//' \
-e "s/^\(.*\)=\([^\"']*\)$/\1=\"\2\"/" \
< $credentials \
| sed -n -e "/^\[$profile\]/,/^\s*\[/{/^[^;].*\=.*/p;}"`
export AWS_DEFAULT_PROFILE=$1
export AWS_ACCESS_KEY_ID=$aws_access_key_id
export AWS_SECRET_ACCESS_KEY=$aws_secret_access_key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment