List of usage examples for com.amazonaws.services.cloudformation.model CreateStackRequest setStackPolicyBody
public void setStackPolicyBody(String stackPolicyBody)
Structure containing the stack policy body.
From source file:jp.classmethod.aws.gradle.cloudformation.AmazonCloudFormationMigrateStackTask.java
License:Apache License
private void createStack(AmazonCloudFormation cfn) throws IOException { // to enable conventionMappings feature String stackName = getStackName(); String cfnTemplateUrl = getCfnTemplateUrl(); File cfnTemplateFile = getCfnTemplateFile(); List<Parameter> cfnStackParams = getCfnStackParams(); List<Tag> cfnStackTags = getCfnStackTags(); String cfnStackPolicyUrl = getCfnStackPolicyUrl(); File cfnStackPolicyFile = getCfnStackPolicyFile(); String cfnOnFailure = getCfnOnFailure(); getLogger().info("create stack: {}", stackName); CreateStackRequest req = new CreateStackRequest().withStackName(stackName).withParameters(cfnStackParams) .withTags(cfnStackTags).withOnFailure(cfnOnFailure); // If template URL is specified, then use it if (Strings.isNullOrEmpty(cfnTemplateUrl) == false) { req.setTemplateURL(cfnTemplateUrl); // Else, use the template file body } else {//from ww w .j ava2s . co m req.setTemplateBody(FileUtils.readFileToString(cfnTemplateFile)); } if (isCapabilityIam()) { Capability selectedCapability = (getUseCapabilityIam() == null) ? Capability.CAPABILITY_IAM : getUseCapabilityIam(); getLogger().info("Using IAM capability: " + selectedCapability); req.setCapabilities(Arrays.asList(selectedCapability.toString())); } // If stack policy is specified, then use it if (Strings.isNullOrEmpty(cfnStackPolicyUrl) == false) { req.setStackPolicyURL(cfnStackPolicyUrl); // Else, use the stack policy file body } else if (cfnStackPolicyFile != null) { req.setStackPolicyBody(FileUtils.readFileToString(cfnStackPolicyFile)); } CreateStackResult createStackResult = cfn.createStack(req); getLogger().info("create requested: {}", createStackResult.getStackId()); }