(Quick Reference)

1 Introduction to Grails AWS Plugin - Reference Documentation

Authors: Lucas Teixeira, Jay Prall

Version: 1.2.12.4

1 Introduction to Grails AWS Plugin

Grails AWS plugin intends to provide most of any other reason, an EASY WAY to access and use AWS services.

Not all services are included in the plugin, you can check this guide to see what you can do and how. If you want to contribute with another service that is not implemented yet, check Section "Contributions ad Reporting Bugs" of this guide.

1.1 Installing Grails AWS Plugin

As other grails plugins you can install it using the install-plugin command like this:

grails install-plugin aws

But since Grails 1.3.x, it is possible (and I really encourage you doing this) to declare the plugin dependency in the BuildConfig.groovy file, as shown here:

grails.project.dependency.resolution = {
    inherits("global") { }
    log "info"
    repositories {
        //your repositories
    }
    dependencies {
        //your regular dependencies
    }
    plugins {
        //here go your plugin dependencies
        runtime ':aws:1.2.12.3'
    }
}

Note the aws as the plugin name, and the 1.2.12.3 as the plugin version. As the time you're reading this, 1.2.12.3 won't probably be the last version, so change it for the correct version you want to grab, or use latest.release as version to grab the latest one.

1.2 Getting the source code

The source code for the plugin is available on Github. http://github.com/grails-aws/grails-aws

1.3 Configuring the plugin in your application

You'll have to configure the plugin in Config.groovy to set AWS credentials and other properties specifically to each AWS service you may use.

1.3.1 Setting AWS Credentials

Setting AWS Credentials

You can set your access-key and secret-key in two different manners as below

Property-file credentials configuration

As recommended by Amazon, you can use a .properties file to handle your secret and access keys for this plugin.

You'll have to create some properties file with the content as show below:

accessKey = your-access-key
secretKey = your-secret-key

And then, you will have to tell your application in Config.groovy to read this property file:

grails {
   plugin {
      aws {
         credentials {
            properties = "/my/path/to/AwsCredentials.properties"
         }
      }
   }
}

Plain-text credentials configuration

If you don't have access to the filesystem in someway, or prefer to set the access and secret key directly in Config.groovy, you can do it this way:

grails {
   plugin {
      aws {
         credentials {
            accessKey = "your-access-key"
            secretKey = "your-secret-key"
         }
      }
   }
}

Remember, if you set a properties file, it will take priority over this way.

Using System Properties as credentials

Sometimes, you still don't have access to filesystem, but don't want to store your credentials wide open in your configuration file, or you want to deploy the same app in more than one place, and use different credentials for each one. So, in these cases, the best approach to solve this, is to pass them as -D params to your application server. It is easy and the plugin will understand this as a plain text credential, but with nothing hardcoded in your app.

You'll have to start your console passing the accessKey and secretKey as param values. In the dev environment, would be like this:

grails -DawsAccessKey=xxxxxx -DawsSecretKey=yyyyyy run-app

After this, just setup your credentials as described below:

grails {
   plugin {
      aws {
         credentials {
            accessKey = System.properties['awsAccessKey']
            secretKey = System.properties['awsSecretKey']
         }
      }
   }
}

We shall thank groovy config files, that allow directly programming into it!

1.4 Gant scripts

Grails AWS Plugin brings some scripts to use in your app, all scripts names follow this rule:

aws-[service]-[operation]

So, all scripts are prefixed with 'aws', followed by its service code, and then the operation name, almost always the same operation name in the corresponding WSDL. For example, to connect with SES and check your sending email statistics (GetSendStatistics operation), you'll have to execute:

grails aws-ses-get-send-statistics

All information are printed in your screen, and when you need to interact with parameters, the script will prompt you.

More detailed information on scripts can be found in the left frame of the screen.