Example usage for com.amazonaws.services.cloudformation.model Capability toString

List of usage examples for com.amazonaws.services.cloudformation.model Capability toString

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudformation.model Capability toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:jp.classmethod.aws.gradle.cloudformation.AmazonCloudFormationCreateChangeSetTask.java

License:Apache License

private void createChangeSet(AmazonCloudFormation cfn) throws IOException {
    // to enable conventionMappings feature
    String stackName = getStackName();
    String cfnTemplateUrl = getCfnTemplateUrl();
    List<Parameter> cfnStackParams = getCfnStackParams();
    List<Tag> cfnStackTags = getCfnStackTags();
    File cfnTemplateFile = getCfnTemplateFile();

    String changeSetName = changeSetName(stackName);
    getLogger().info("Create change set '{}' for stack '{}'", changeSetName, stackName);
    CreateChangeSetRequest req = new CreateChangeSetRequest().withChangeSetName(changeSetName)
            .withStackName(stackName).withParameters(cfnStackParams).withTags(cfnStackTags);

    // If template URL is specified, then use it
    if (Strings.isNullOrEmpty(cfnTemplateUrl) == false) {
        req.setTemplateURL(cfnTemplateUrl);
        // Else, use the template file body
    } else {//from www.j  a  v  a  2 s .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()));
    }
    CreateChangeSetResult createChangeSetResult = cfn.createChangeSet(req);
    getLogger().info("Create change set requested: {}", createChangeSetResult.getId());
}

From source file:jp.classmethod.aws.gradle.cloudformation.AmazonCloudFormationMigrateStackTask.java

License:Apache License

private void updateStack(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();

    getLogger().info("Update stack: {}", stackName);
    UpdateStackRequest req = new UpdateStackRequest().withStackName(stackName).withParameters(cfnStackParams)
            .withTags(cfnStackTags);/*from  w w w  .jav a 2s .c om*/

    // If template URL is specified, then use it
    if (Strings.isNullOrEmpty(cfnTemplateUrl) == false) {
        req.setTemplateURL(cfnTemplateUrl);
        getLogger().info("Using template url: {}", cfnTemplateUrl);
        // Else, use the template file body
    } else {
        req.setTemplateBody(FileUtils.readFileToString(cfnTemplateFile));
        getLogger().info("Using template file: {}", "$cfnTemplateFile.canonicalPath");
    }
    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 if present
    } else if (cfnStackPolicyFile != null) {
        req.setStackPolicyBody(FileUtils.readFileToString(cfnStackPolicyFile));
    }

    UpdateStackResult updateStackResult = cfn.updateStack(req);
    getLogger().info("Update requested: {}", updateStackResult.getStackId());
}

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 a  va2s .  c o 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());
}