Skip to content

Commit

Permalink
Fixes issue #12 - Added support for AWS's new Capabilities parameter.…
Browse files Browse the repository at this point in the history
… Added FAQ to document some unexpected consequences of this AWS API change.
  • Loading branch information
johntrimble committed Nov 19, 2013
1 parent 869b02e commit cae1609
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## FAQ
### Why do I get an "Requires capabilities : [CAPABILITY_IAM]" error when creating a stack?
On 11/8/2013, Amazon updated the CreateStack operation to take an optional `Capabilities` parameter which should be set to `CAPABILITY_IAM` if the given template creates any IAM resources. However, it appears that even when a template does not contain any IAM resources that it is sometimes necessary to set the `Capabilities` parameter to `CAPABILITY_IAM` anyways. To do so, add the following configuration for the plugin to the POM.xml:

```
<capabilities>
<capability>CAPABILITY_IAM</capability>
</capabilities>
```

This should work even if the AWS account used by the plugin does not have any IAM permissions, so long as the template does not actually specify any IAM resources.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ class CreateStackMojo extends AbstractMojo {
@MojoParameter(defaultValue='30')
public int cloudFormationTimeout

/**
* The list of capabilities for the stack. You should include CAPABILITY_IAM if
* you're creating any IAM resources in this stack.
*/
@MojoParameter
public List capabilities

void execute() throws MojoExecutionException, MojoFailureException {
if( !stackName )
stackName = "${stackNamePrefix}${new Date().format('yyyyMMddHHmmss')}"
Expand All @@ -92,9 +99,20 @@ class CreateStackMojo extends AbstractMojo {
// Create stack parameters
List cfParameters = []
this.parameters.collect cfParameters, { key, value -> new Parameter(parameterKey:key, parameterValue: value) }


// Get capabilities
List capabilities = this.capabilities ?: []

// Build stack request
def stackRequest = new CreateStackRequest(
stackName:stackName,
templateBody:template.text,
timeoutInMinutes: cloudFormationTimeout,
parameters: cfParameters,
capabilities: capabilities)

// Create stack
String stackId = cloudFormation.createStack(new CreateStackRequest(stackName:stackName, templateBody:template.text, timeoutInMinutes: cloudFormationTimeout, parameters: cfParameters)).stackId
String stackId = cloudFormation.createStack(stackRequest).stackId
log.info "Creating stack: ${stackId}"

// Poll stack until created
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.3.27</version>
<version>1.6.6</version>
</dependency>

<!-- Pin down versions for aws-java-sdk dependencies -->
Expand Down

0 comments on commit cae1609

Please sign in to comment.