List of usage examples for com.amazonaws.services.cloudformation.model AmazonCloudFormationException getErrorCode
public String getErrorCode()
From source file:de.taimos.pipeline.aws.cloudformation.CloudFormationStack.java
License:Apache License
public boolean exists() { try {/*from w w w .j a v a 2 s. c om*/ DescribeStacksResult result = this.client .describeStacks(new DescribeStacksRequest().withStackName(this.stack)); return !result.getStacks().isEmpty(); } catch (AmazonCloudFormationException e) { if ("AccessDenied".equals(e.getErrorCode())) { this.listener.getLogger().format("Got error from describeStacks: %s %n", e.getErrorMessage()); throw e; } else if ("ValidationError".equals(e.getErrorCode()) && e.getErrorMessage().contains("does not exist")) { return false; } else { throw e; } } }
From source file:de.taimos.pipeline.aws.cloudformation.CloudFormationStack.java
License:Apache License
public boolean changeSetExists(String changeSetName) { try {//from w ww .j a v a 2 s.c o m this.client.describeChangeSet( new DescribeChangeSetRequest().withStackName(this.stack).withChangeSetName(changeSetName)); return true; } catch (AmazonCloudFormationException e) { if ("AccessDenied".equals(e.getErrorCode())) { this.listener.getLogger().format("Got error from describeStacks: %s %n", e.getErrorMessage()); throw e; } return false; } }
From source file:de.taimos.pipeline.aws.cloudformation.stacksets.CloudFormationStackSet.java
License:Apache License
public boolean exists() { try {//w w w. j a va 2 s. c o m this.client.describeStackSet(new DescribeStackSetRequest().withStackSetName(this.stackSet)); return true; } catch (AmazonCloudFormationException e) { if ("StackSetNotFoundException".equals(e.getErrorCode())) { return false; } else { this.listener.getLogger().format("Got error from describeStacks: %s %n", e.getErrorMessage()); throw e; } } }
From source file:jp.classmethod.aws.gradle.cloudformation.AmazonCloudFormationPluginExtension.java
License:Apache License
public Optional<Stack> getStack(String stackName) { if (getProject().getGradle().getStartParameter().isOffline() == false) { try {/*from ww w.ja va 2 s .co m*/ DescribeStacksResult describeStacksResult = getClient() .describeStacks(new DescribeStacksRequest().withStackName(stackName)); List<Stack> stacks = describeStacksResult.getStacks(); if (stacks.isEmpty() == false) { return stacks.stream().findAny(); } } catch (AmazonCloudFormationException e) { if ("ValidationError".equals(e.getErrorCode())) { return Optional.empty(); } else { throw new GradleException(e.getMessage(), e); } } } return Optional.empty(); }
From source file:jp.classmethod.aws.gradle.cloudformation.AmazonCloudFormationPluginExtension.java
License:Apache License
public List<StackResource> getStackResources(String stackName) { if (getProject().getGradle().getStartParameter().isOffline() == false) { try {//from ww w . j a v a2 s . c om DescribeStackResourcesResult describeStackResourcesResult = getClient() .describeStackResources(new DescribeStackResourcesRequest().withStackName(stackName)); return describeStackResourcesResult.getStackResources(); } catch (AmazonCloudFormationException e) { if ("ValidationError".equals(e.getErrorCode())) { return Collections.emptyList(); } else { throw new GradleException(e.getMessage(), e); } } } logger.info("offline mode: return empty resources"); return Collections.emptyList(); }