Example usage for com.amazonaws.services.cloudformation AmazonCloudFormationClientBuilder standard

List of usage examples for com.amazonaws.services.cloudformation AmazonCloudFormationClientBuilder standard

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudformation AmazonCloudFormationClientBuilder standard.

Prototype

public static AmazonCloudFormationClientBuilder standard() 

Source Link

Usage

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

License:Open Source License

public DeployService(SamConfig config, Logger logger) {
    this(config, config.getAwsClientFactory().create(AmazonCloudFormationClientBuilder.standard()), logger);
}

From source file:io.konig.maven.CreateCloudFormationStackAction.java

License:Apache License

public AwsDeployment from(String path) throws Exception {
    File jsonFile = deployment.file(path);
    ObjectMapper mapper = new ObjectMapper();
    CloudFormationTemplate cfTemplate = mapper.readValue(jsonFile, CloudFormationTemplate.class);
    Properties properties = System.getProperties();
    StringWriter result = new StringWriter();
    properties.setProperty("file.resource.loader.path", jsonFile.getParent());

    VelocityEngine engine = new VelocityEngine(properties);
    Template template = engine.getTemplate(cfTemplate.getTemplate(), "UTF-8");
    VelocityContext context = new VelocityContext();
    context.put("beginVar", "${");
    context.put("endVar", "}");
    for (Object key : properties.keySet()) {
        String k = (String) key;
        context.put(k, properties.getProperty(k));
    }//from   w ww  .ja va2  s.co m
    template.merge(context, result);
    String strResult = result.toString();

    CreateStackRequest request = new CreateStackRequest().withTemplateBody(strResult)
            .withStackName(cfTemplate.getStackName()).withCapabilities(Capability.CAPABILITY_IAM);

    AmazonCloudFormation amazonClient = AmazonCloudFormationClientBuilder.standard()
            .withCredentials(AWSCloudFormationUtil.getCredential())
            .withRegion(Regions.fromName(cfTemplate.getRegion())).build();
    CreateStackResult stackResult = amazonClient.createStack(request);
    List<Output> outputs = getOutputForRequest(cfTemplate.getStackName(), amazonClient);
    deployment.setResponse("Stack creation complete. Outputs::" + (outputs == null ? "" : outputs.toString()));
    return deployment;

}

From source file:io.konig.maven.DeleteCloudFormationStackAction.java

License:Apache License

public AwsDeployment from(String path) throws Exception {
    File jsonFile = deployment.file(path);
    ObjectMapper mapper = new ObjectMapper();
    CloudFormationTemplate cfTemplate = mapper.readValue(jsonFile, CloudFormationTemplate.class);
    DeleteStackRequest request = new DeleteStackRequest().withStackName(cfTemplate.getStackName());
    AmazonCloudFormation amazonClient = AmazonCloudFormationClientBuilder.standard()
            .withCredentials(AWSCloudFormationUtil.getCredential())
            .withRegion(Regions.fromName(cfTemplate.getRegion())).build();
    DeleteStackResult stackResult = amazonClient.deleteStack(request);
    deployment.setResponse("Stack deletion complete");
    return deployment;
}