Example usage for com.amazonaws.services.cloudformation.model TemplateParameter getDefaultValue

List of usage examples for com.amazonaws.services.cloudformation.model TemplateParameter getDefaultValue

Introduction

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

Prototype


public String getDefaultValue() 

Source Link

Document

The default value associated with the parameter.

Usage

From source file:com.deploymentio.cfnstacker.CloudFormationClient.java

License:Apache License

/**
 * Validates the stack template with CloudFormation and ensure that values
 * were provided for all required parameters
 * //  w ww  .j a  va 2s .c o m
 * @param templateBody ClouadFormation JSON template
 * @param options options needed to validate the stack template
 * @return <code>true</code> if the stack is valid, <code>false</code>
 *         otherwise
 */
public boolean validateTemplate(JsonNode templateBody) throws Exception {

    boolean allOK = true;
    Map<String, JsonNode> stackProperties = config.getParameters();
    ValidateTemplateResult validationResult = client.validateTemplate(new ValidateTemplateRequest()
            .withTemplateURL(uploadCfnTemplateToS3(config.getName(), "validate", templateBody)));

    // check if the template has any parameters without defaults for which no stack properties were provided
    for (TemplateParameter param : validationResult.getParameters()) {
        String key = param.getParameterKey();
        if (StringUtils.isEmpty(param.getDefaultValue())) {
            JsonNode value = stackProperties.get(key);
            if (value == null) {
                logger.error("Missing template parameter value: Key=" + key);
                allOK = false;
            } else if (value.isContainerNode()) {
                logger.error("Template parameter can only be a scaler value: Key=" + key);
                allOK = false;
            }
        }
    }

    return allOK;
}

From source file:org.xmlsh.aws.util.AWSCFNCommand.java

License:BSD License

public void writeTemplateParameter(TemplateParameter p) throws XMLStreamException {
    startElement("parameter");
    attribute("key", p.getParameterKey());
    attribute("description", p.getDescription());
    attribute("no-echo", p.getNoEcho());
    attribute("default", p.getDefaultValue());
    endElement();//from w ww.jav a2 s  .  c  o m

}