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

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

Introduction

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

Prototype


public String getParameterKey() 

Source Link

Document

The name 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
 * /*from   ww  w. ja va 2  s .co  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();// w w w  . j  a va  2  s. com

}