Example usage for com.amazonaws.services.cloudformation.model CreateChangeSetResult getId

List of usage examples for com.amazonaws.services.cloudformation.model CreateChangeSetResult getId

Introduction

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

Prototype


public String getId() 

Source Link

Document

The Amazon Resource Name (ARN) of the change set.

Usage

From source file:com.github.kaklakariada.aws.sam.service.CloudformationService.java

License:Open Source License

public String createChangeSet(String changeSetName, String stackName, ChangeSetType changeSetType,
        String templateBody, Collection<Parameter> parameters) {
    logger.info("Creating change set for stack {} with name {}, type {} and parameters {}", stackName,
            changeSetName, changeSetType, parameters);
    final CreateChangeSetRequest changeSetRequest = new CreateChangeSetRequest() //
            .withCapabilities(Capability.CAPABILITY_IAM) //
            .withStackName(stackName) //
            .withDescription(stackName) //
            .withChangeSetName(changeSetName) //
            .withChangeSetType(changeSetType) //
            .withParameters(parameters).withTemplateBody(templateBody);
    final CreateChangeSetResult result = cloudFormation.createChangeSet(changeSetRequest);
    logger.info("Change set created: {}", result);
    return result.getId();
}

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   w w w  .j  av  a 2 s .c om
        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());
}