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

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

Introduction

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

Prototype


public CreateStackRequest withTemplateBody(String templateBody) 

Source Link

Document

Structure containing the template body with a minimum length of 1 byte and a maximum length of 51,200 bytes.

Usage

From source file:br.com.ingenieux.mojo.cloudformation.PushStackMojo.java

License:Apache License

private CreateStackResult createStack() throws Exception {
    CreateStackRequest req = new CreateStackRequest().withStackName(stackName)
            .withCapabilities(Capability.CAPABILITY_IAM);

    if (null != this.destinationS3Uri) {
        req.withTemplateURL(generateExternalUrl(this.destinationS3Uri));
    } else {//  w  ww  . jav a 2s  .  c  o m
        req.withTemplateBody(templateBody);
    }

    req.withNotificationARNs(notificationArns);

    req.withParameters(parameters);
    req.withResourceTypes(resourceTypes);
    req.withDisableRollback(disableRollback);
    req.withTags(tags);
    req.withTimeoutInMinutes(timeoutInMinutes);

    return getService().createStack(req);
}

From source file:com.carrotgarden.maven.aws.cfn.CarrotCloudForm.java

License:BSD License

/**
 *///www .  j a va2s  . co m
public Stack stackCreate() throws Exception {

    final CreateStackRequest request = new CreateStackRequest();

    request.withStackName(name);
    request.withParameters(paramList);
    request.withTemplateBody(template);

    amazonClient.createStack(request);

    final Stack stack = waitForStackCreate();

    return stack;

}

From source file:com.tvarit.plugin.InfrastructureMojo.java

License:Open Source License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    getLog().debug("Starting " + this.getClass().getSimpleName() + " execution ");
    getLog().warn(//from w  ww.  j a  v a 2s . com
            "This goal has been deprecated and may be removed without notice. Please use the goal 'make-infrastructure' instead.");
    final BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
    AmazonCloudFormationClient amazonCloudFormationClient = new AmazonCloudFormationClient(awsCredentials);
    final com.amazonaws.services.cloudformation.model.Parameter domainNameParameter = new com.amazonaws.services.cloudformation.model.Parameter()
            .withParameterKey("domainName").withParameterValue(this.domainName);
    final com.amazonaws.services.cloudformation.model.Parameter projectNameParameter = new com.amazonaws.services.cloudformation.model.Parameter()
            .withParameterKey("projectName").withParameterValue(this.projectName);
    final com.amazonaws.services.cloudformation.model.Parameter bucketNameParameter = new com.amazonaws.services.cloudformation.model.Parameter()
            .withParameterKey("bucketName").withParameterValue("tvarit-" + this.bucketName);
    final CreateStackRequest createStackRequest = new CreateStackRequest()
            .withCapabilities(Capability.CAPABILITY_IAM).withStackName(projectName + "-infra")
            .withParameters(domainNameParameter, projectNameParameter, bucketNameParameter);
    if (templateUrl == null) {
        final String template = new TemplateReader().readTemplate("/cfn-templates/vpc-infra.template");
        createStackRequest.withTemplateBody(template);
    } else {
        createStackRequest.withTemplateURL(templateUrl);
    }
    new StackMaker().makeStack(createStackRequest, amazonCloudFormationClient, getLog());

    getLog().info("Finished completing stack");

}

From source file:de.taimos.pipeline.aws.cloudformation.CloudFormationStack.java

License:Apache License

public void create(String templateBody, String templateUrl, Collection<Parameter> params, Collection<Tag> tags,
        Integer timeoutInMinutes, long pollIntervallMillis, String roleArn, String onFailure)
        throws ExecutionException {
    if ((templateBody == null || templateBody.isEmpty()) && (templateUrl == null || templateUrl.isEmpty())) {
        throw new IllegalArgumentException("Either a file or url for the template must be specified");
    }/*w  w w . j ava2 s.co  m*/

    CreateStackRequest req = new CreateStackRequest();
    req.withStackName(this.stack).withCapabilities(Capability.CAPABILITY_IAM, Capability.CAPABILITY_NAMED_IAM);
    req.withTemplateBody(templateBody).withTemplateURL(templateUrl).withParameters(params).withTags(tags)
            .withTimeoutInMinutes(timeoutInMinutes).withRoleARN(roleArn)
            .withOnFailure(OnFailure.valueOf(onFailure));
    this.client.createStack(req);

    new EventPrinter(this.client, this.listener).waitAndPrintStackEvents(this.stack,
            this.client.waiters().stackCreateComplete(), pollIntervallMillis);
}