-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new custom task type for multi-region sam deploy
- Loading branch information
Showing
6 changed files
with
84 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
group=com.fieldju | ||
artifactId=gradle-aws-sam-deployer-plugin | ||
version=1.3.1 | ||
version=1.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/groovy/com/fieldju/gradle/plugins/lambdasam/tasks/MultiRegionSamDeployTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.fieldju.gradle.plugins.lambdasam.tasks | ||
|
||
import com.fieldju.commons.StringUtils | ||
import org.gradle.api.GradleException | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.Optional | ||
|
||
class MultiRegionSamDeployTask extends SamTask { | ||
|
||
@Input | ||
@Optional | ||
String templatePath | ||
|
||
@Input | ||
@Optional | ||
def regionTemplatePathMap = [:] | ||
|
||
@Input | ||
def regions = [] | ||
|
||
@Input | ||
String stackName | ||
|
||
@Input | ||
Map<String, Map<String, String>> regionToParameterOverridesMap = [:] | ||
|
||
@Override | ||
void taskAction() { | ||
regions.each { region -> | ||
Map<String, String> parameterOverrides | ||
if (regionToParameterOverridesMap.containsKey(region)) { | ||
parameterOverrides = regionToParameterOverridesMap."${region}" | ||
} else { | ||
logger.lifecycle("regionToParameterOverridesMap does not contain an entry for region ${region} defaulting to empty map") | ||
parameterOverrides = [:] | ||
} | ||
|
||
String templatePath | ||
if (StringUtils.isNotBlank(this.templatePath)) { | ||
templatePath = this.templatePath | ||
} else if (regionTemplatePathMap.containsKey(region)) { | ||
templatePath = regionTemplatePathMap."${region}" | ||
} else { | ||
throw new GradleException("templatePath or regionTemplatePathMap.'\${region}' for " + | ||
"region: ${region} must be set") | ||
} | ||
|
||
DeploySamTask deploySamTask = new DeploySamTask() | ||
deploySamTask.region = region | ||
deploySamTask.stackName = stackName | ||
deploySamTask.parameterOverrides = parameterOverrides | ||
deploySamTask.templatePath = templatePath | ||
|
||
logger.lifecycle("Creating and executing changeset for ${templatePath} with stackname ${stackName} in region ${region} with overrides ${parameterOverrides}") | ||
deploySamTask.taskAction() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters