Moogsoft Docs

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
    fi
    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>"
    
    java_classpath="$APP_HOME/lib/lam_components-1.0.jar:$APP_HOME/lib/cots/httpmime-4.3.1.jar:$APP_HOME/lib/cots/httpcore-4.4.5.jar:$APP_HOME/lib/cots/httpclient-4.5.2.jar:$APP_HOME/lib/cots/commons-codec-1.10.jar:$APP_HOME/lib/cots/joda-time-2.8.2.jar:$APP_HOME/lib/cots/aws-java-sdk-1.11.158.jar:$APP_HOME/lib/cots/aws-java-sdk-cloudwatch-1.11.158.jar:$APP_HOME/lib/cots/aws-java-sdk-logs-1.11.158.jar:$APP_HOME/lib/cots/aws-java-sdk-core-1.11.158.jar:$APP_HOME/lib/cots/aws-java-sdk-ec2-1.11.158.jar:$APP_HOME/lib/cots/aws-java-sdk-s3-1.11.158.jar:$APP_HOME/lib/bot.jar:$APP_HOME/lib/mooms.jar:$APP_HOME/lib/dao.jar:$APP_HOME/lib/security.jar:$APP_HOME/lib/utilutils.jar:$APP_HOME/lib/servletutils.jar:$APP_HOME/lib/cots/commons-lang3-3.4.jar:$APP_HOME/lib/cots/commons-io-1.2.jar:$APP_HOME/lib/cots/commons-cli-1.2.jar:$APP_HOME/lib/cots/jackson-annotations-2.8.1.jar:$APP_HOME/lib/cots/jackson-core-2.8.1.jar:$APP_HOME/lib/cots/jackson-databind-2.8.1.jar:$APP_HOME/lib/cots/rhino-1.7R4.jar:$APP_HOME/lib/cots/mysql-connector-java-5.1.37.jar:$APP_HOME/lib/cots/amqp-client-3.6.5.jar:$APP_HOME/lib/cots/javax.servlet-api-3.1.0.jar:$APP_HOME/lib/cots/shiro-core-1.2.4.jar:$APP_HOME/lib/cots/snmp4j-2.5.2.jar:$APP_HOME/lib/cots/antlr4-runtime-4.5.3.jar:$APP_HOME/lib/cots/slf4j-api-1.6.4.jar:$APP_HOME/lib/cots/commons-logging-1.2.jar:$APP_HOME/lib/aws_lam-1.1.jar:$APP_HOME/lib/cots/nonDist/*"
    java_vm=$JAVA_HOME/bin/java
  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.