I'm using AWS IAM roles that allows an instance to have access to certain resources using temporary API credentials (access key, secret key and security token).
When I test the temporary credentials using this ruby script, it runs without any problems :
require 'rubygems'
require 'aws-sdk'
AWS.config(
:access_key_id => "MY ACCESS KEY GOES HERE",
:secret_access_key => "MY SECRET KEY GOES HERE",
:session_token => "MY TOKEN GOES HERE")
s3 = AWS::S3.new()
myfile = s3.buckets['My-Config'].objects["file.sh"]
File.open("/tmp/file.sh", "w") do |f|
f.write(myfile.read)
end
But when using command line to run cfn-describe-stacks I get an error:
export AWS_CREDENTIAL_FILE=aws_credentials.cfg
cfn-describe-stacks
cfn-describe-stacks: Refused: The security token included in the request is invalid
and here is my aws_credentials.cfg :
AWSAccessKeyId=MY ACCESS KEY
AWSSecretKey=My SECRET KEY
AWSToken="MY TOKEN=="
So what am i missing here ? Thank you!