Home > Clouds > AWS > AWS FAQs > How can I export AWS environment variables to the shell?

Copyright (c) 2006-2014 MindTouch Inc.

This file and accompanying files are licensed under the MindTouch Master Subscription Agreement (MSA).

At any time, you shall not, directly or indirectly: (i) sublicense, resell, rent, lease, distribute, market, commercialize or otherwise transfer rights or usage to: (a) the Software, (b) any modified version or derivative work of the Software created by you or for you, or (c) MindTouch Open Source (which includes all non-supported versions of MindTouch-developed software), for any purpose including timesharing or service bureau purposes; (ii) remove or alter any copyright, trademark or proprietary notice in the Software; (iii) transfer, use or export the Software in violation of any applicable laws or regulations of any government or governmental agency; (iv) use or run on any of your hardware, or have deployed for use, any production version of MindTouch Open Source; (v) use any of the Support Services, Error corrections, Updates or Upgrades, for the MindTouch Open Source software or for any Server for which Support Services are not then purchased as provided hereunder; or (vi) reverse engineer, decompile or modify any encrypted or encoded portion of the Software.

A complete copy of the MSA is available at http://www.mindtouch.com/msa

How can I export AWS environment variables to the shell?

Table of Contents
Background Information

In some instances you may want to export all of the AWS environment variables, credentials, and key files to a running instance so you don't have to set them up manually.



The following RightScript will do this for you by creating a script in /root that will export all of the AWS environment variables as well as a key.pem and a cert.pem file.  To set the environment variables simply run this RightScript (or install it as a boot script).  When you ssh into the instance you will find setenv, key.pem, and cert.pem in /root.  You can then use this from the command line to set the environment variables in your shell by typing:


source /root/setenv

You can cut and paste the script below into a new RightScript and then install it on the template as an operational or boot script.


echo 'export AWS_ACCESS_KEY_ID='$AWS_ACCESS_KEY_ID > /root/setenv

echo 'export AWS_SECRET_ACCESS_KEY='$AWS_SECRET_ACCESS_KEY >> /root/setenv

echo 'export AWS_ACCOUNT_NUMBER='$AWS_ACCOUNT_NUMBER >> /root/setenv

echo 'export EC2_AMI_ID='$EC2_AMI_ID >> /root/setenv

echo 'export EC2_AKI_ID='$EC2_AKI_ID >> /root/setenv

echo 'export EC2_ARI_ID='$EC2_ARI_ID >> /root/setenv

echo 'export EC2_AMI_MANIFEST_PATH='$EC2_AMI_MANIFEST_PATH >> /root/setenv


echo 'export EC2_HOSTNAME='$EC2_HOSTNAME >> /root/setenv

echo 'export EC2_INSTANCE_ID='$EC2_INSTANCE_ID >> /root/setenv

echo 'export EC2_INSTANCE_TYPE='$EC2_INSTANCE_TYPE >> /root/setenv

echo 'export EC2_LOCAL_HOSTNAME='$EC2_LOCAL_HOSTNAME >> /root/setenv

echo 'export EC2_PUBLIC_HOSTNAME='$EC2_PUBLIC_HOSTNAME >> /root/setenv

echo 'export EC2_PUBLIC_IPV4='$EC2_PUBLIC_IPV4 >> /root/setenv

echo 'export EC2_RESERVATION_ID='$EC2_RESERVATION_ID >> /root/setenv

echo 'export EC2_SECURITY_GROUPS='$EC2_SECURITY_GROUPS >> /root/setenv

echo 'export RS_SERVER='$RS_SERVER >> /root/setenv

echo 'export RS_SKETCHY='$RS_SKETCHY >> /root/setenv

echo 'export RS_TOKEN='$RS_TOKEN >> /root/setenv


chmod 700 /root/setenv

echo "$AWS_X509_CERT" > /root/cert.pem

echo "$AWS_X509_KEY" > /root/key.pem
You must to post a comment.
Last modified
21:25, 16 May 2013



This page has no classifications.



Glossary | 用語용어 Site Map | Site Help Community Corporate Site Get Support Dashboard Login
Doc Feedback Product Feedback Resources MultiCloud Marketplace Forums

Dashboard Status

© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.