0

I'm trying to upload some files from Bitrise CI to AWS S3 bucket.

When I try to configure AWS on my laptop, I have no problem

$ aws configure
$ AWS Access Key ID [None]: MY_KEY
$ AWS Secret Access Key [None]: MY_ACCESS_KEY
$ Default region name [None]: MY_REGION_NAME
$ Default output format [None]:  

My problem is how to assign MY_KEY, MY_ACCESS_KEY, MY_REGION_NAME and EMPTY to above requests (via script)?

I tried to cheat! in this way but I wasn't successful.

echo "[default]" > ~/.aws/config
echo "aws_access_key_id = MY_KEY" >> ~/.aws/config
echo "aws_secret_access_key = MY_ACCESS_KEY" >> ~/.aws/config
echo "region = MY_REGION_NAME" >> ~/.aws/config
cat ~/.aws/config

I'm getting following error:

echo '[default]' /tmp/bitrise316130716/step_src/._script_cont: line 16: /root/.aws/config: No such file or directory

halfer
  • 19,824
  • 17
  • 99
  • 186
Hesam
  • 52,260
  • 74
  • 224
  • 365

2 Answers2

1

You don't have to write the configuration into file, you can supply the credentials as Environment Variables:

export AWS_ACCESS_KEY_ID=..
export AWS_SECRET_ACCESS_KEY=..
export AWS_DEFAULT_REGION=..

You can check how we implemented this in our amazon-s3-upload step.

Viktor Benei
  • 3,447
  • 2
  • 28
  • 37
0

Thanks to the answer https://stackoverflow.com/a/3804645/513413

I changed my above code to this and I'm able to upload my files to S3.

yes Y | sudo apt-get install awscli
printf 'MY_KEY\nMY_ACCESS_KEY\nMY_REGION_NAME\njson' | aws configure
Community
  • 1
  • 1
Hesam
  • 52,260
  • 74
  • 224
  • 365