Skip to main content

Optional AWS LAM Configuration

The Secret Access Key and the Access Key are usually stated in the config file, but you can also connect to the AWS LAM using the following:

Using environment variables

You can use environment variables to connect to the LAM.

  1. Open the .bashrc file using an editor, for example vi /root/.bashrc.

  2. Enter the Access/Secret Access Key of your AWS account:

    # .bashrc
    # User specific aliases and functions
    alias rm='rm -i'
    alias cp='cp -i'
    alias mv='mv -i'
    # Source global definitions
    if [ -f /etc/bashrc ]; then
            . /etc/bashrc
    export AWS_ACCESS_KEY=<Your AWS Access Key>
    export AWS_SECRET_KEY=<Your AWS Secret Key>
    export MOOGSOFT_HOME=/usr/share/moogsoft
    export JAVA_HOME=/usr/java/latest
  3. Save the bashrc file.

  4. Enter the command source .bashrc.

You have successfully configured the Access/Secret Access Key for the LAM and now you don't have to enter it in the config file.

Entering the keys in the awslam file

You can enter the Access/Secret Access Key in the the awslam file.

  1. Go to $MOOGSOFT_HOME/bin.

  2. Open the awslam file using an editor, for example vi awslam.

  3. Enter the lines AWS_ACCESS_KEY and AWS_SECRET_KEY in the Set up the java environment section along with the Access/Secret Access Key:

    # Set up the java environment
    AWS_ACCESS_KEY="<Your AWS Access Key>"
    AWS_SECRET_KEY="<Your AWS Secret Key>"
  4. Enter the following lines in the Run app section:

    # Run app
    $java_vm ${JVM_OPTS[@]} -DprocName=$proc_name -DMOOGSOFT_HOME=$APP_HOME -classpath $java_classpath $java_main_class "$@" &
    #$java_vm ${JVM_OPTS[@]} -Daws.accessKeyId=$AWS_ACCESS_KEY  -Daws.secretKey=$AWS_SECRET_KEY  -DprocName=$proc_name -DMOOGSOFT_HOME=$APP_HOME -classpath $java_classpath $java_main_class "$@" &

You have successfully configured the Access/Secret Access Key for the LAM and now you don't have to enter it in the config file.

Using a credential file

You can use a credential file to store the Access/Secret Access Key at a predefined default location.

  1. Go to /root/.aws. If the .aws directory is not present then create the .aws directory using the mkdir command.

  2. Create a file named credentials using the command touch credentials .

  3. Enter the Access Key and Secret Access Key in the credentials file.

You have successfully configured the Access/Secret Access Key for the LAM and now you don't have to enter it in the config file.

Instance profile credentials delivered through the Amazon EC2 metadata service

See the AWS documentation for information on setting up roles to access AWS resources.