Example usage for com.amazonaws.services.cloudformation.model CreateStackRequest setTags

List of usage examples for com.amazonaws.services.cloudformation.model CreateStackRequest setTags

Introduction

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

Prototype


public void setTags(java.util.Collection<Tag> tags) 

Source Link

Document

Key-value pairs to associate with this stack.

Usage

From source file:org.xmlsh.aws.cfnCreateStack.java

License:BSD License

private int createStack(Options opts) throws IOException, XMLStreamException, SaxonApiException, CoreException {

    OutputPort stdout = getStdout();/*  ww w .j av  a2 s  .  c  o m*/
    mWriter = new SafeXMLStreamWriter(stdout.asXMLStreamWriter(getSerializeOpts()));

    startDocument();
    startElement(getName());

    CreateStackRequest request = new CreateStackRequest();

    // "capability:+,disable-rollback,notification-arn:+,name:,template:,timeout:,tag:+");

    if (opts.hasOpt("capability"))
        request.setCapabilities(Util.toStringList(opts.getOptValues("capability")));

    String onFail = opts.getOptString("on-failure", null);
    if (onFail != null)
        request.setOnFailure(OnFailure.fromValue(onFail));
    else
        request.setDisableRollback(opts.getOptFlag("disable-rollback", false));

    if (opts.hasOpt("notification-arn"))
        request.setNotificationARNs(Util.toStringList(opts.getOptValues("notification-arn")));

    request.setStackName(opts.getOptStringRequired("name"));

    if (opts.hasOpt("template-file"))
        request.setTemplateBody(Util.readString(mShell.getFile(opts.getOptValue("template-file")),
                getSerializeOpts().getInput_text_encoding()));
    else
        request.setTemplateURL(opts.getOptStringRequired("template-url"));

    if (opts.hasOpt("timeout"))
        request.setTimeoutInMinutes((int) opts.getOptLong("timeout", 10));
    if (opts.hasOpt("tag"))
        request.setTags(getTags(opts.getOptValues("tag")));

    request.setParameters(getParameters(opts));

    traceCall("createStack");

    CreateStackResult result = getAWSClient().createStack(request);

    writeStackResult(result, request.getStackName());

    endElement();
    endDocument();
    closeWriter();

    stdout.writeSequenceTerminator(getSerializeOpts());

    return 0;

}