if (getCapabilities() != null) sb.append("Capabilities: ").append(getCapabilities()).append(","); if (getOutputs() != null) sb.append("Outputs: ").append(getOutputs()).append(","); if (getRoleARN() != null) sb.append("RoleARN: ").append(getRoleARN()).append(",");
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStackId() == null) ? 0 : getStackId().hashCode()); hashCode = prime * hashCode + ((getStackName() == null) ? 0 : getStackName().hashCode()); hashCode = prime * hashCode + ((getChangeSetId() == null) ? 0 : getChangeSetId().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getParameters() == null) ? 0 : getParameters().hashCode()); hashCode = prime * hashCode + ((getCreationTime() == null) ? 0 : getCreationTime().hashCode()); hashCode = prime * hashCode + ((getDeletionTime() == null) ? 0 : getDeletionTime().hashCode()); hashCode = prime * hashCode + ((getLastUpdatedTime() == null) ? 0 : getLastUpdatedTime().hashCode()); hashCode = prime * hashCode + ((getRollbackConfiguration() == null) ? 0 : getRollbackConfiguration().hashCode()); hashCode = prime * hashCode + ((getStackStatus() == null) ? 0 : getStackStatus().hashCode()); hashCode = prime * hashCode + ((getStackStatusReason() == null) ? 0 : getStackStatusReason().hashCode()); hashCode = prime * hashCode + ((getDisableRollback() == null) ? 0 : getDisableRollback().hashCode()); hashCode = prime * hashCode + ((getNotificationARNs() == null) ? 0 : getNotificationARNs().hashCode()); hashCode = prime * hashCode + ((getTimeoutInMinutes() == null) ? 0 : getTimeoutInMinutes().hashCode()); hashCode = prime * hashCode + ((getCapabilities() == null) ? 0 : getCapabilities().hashCode()); hashCode = prime * hashCode + ((getOutputs() == null) ? 0 : getOutputs().hashCode()); hashCode = prime * hashCode + ((getRoleARN() == null) ? 0 : getRoleARN().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getEnableTerminationProtection() == null) ? 0 : getEnableTerminationProtection().hashCode()); hashCode = prime * hashCode + ((getParentId() == null) ? 0 : getParentId().hashCode()); hashCode = prime * hashCode + ((getRootId() == null) ? 0 : getRootId().hashCode()); hashCode = prime * hashCode + ((getDriftInformation() == null) ? 0 : getDriftInformation().hashCode()); return hashCode; }
if (other.getCapabilities() != null && other.getCapabilities().equals(this.getCapabilities()) == false) return false; if (other.getOutputs() == null ^ this.getOutputs() == null) return false; if (other.getOutputs() != null && other.getOutputs().equals(this.getOutputs()) == false) return false; if (other.getRoleARN() == null ^ this.getRoleARN() == null)
public static String getStackOutputsToJson(Stack stack) throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(out, stack.getOutputs()); final byte[] stackOutputs = out.toByteArray(); return new String(stackOutputs); } }
public List<Output> getOutputParameters(String stackName) { final Stack stack = describeStack(stackName).stream().findFirst() .orElseThrow(() -> new DeploymentException("Stack not found")); return stack.getOutputs(); }
public static String getStackOutput(String stackName, String key){ DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest(); describeStacksRequest.withStackName(stackName); DescribeStacksResult describeStacksResult = client.describeStacks(describeStacksRequest); List<Output> outputs = describeStacksResult.getStacks().get(0).getOutputs(); Optional<Output> output = outputs.stream() .filter(index -> index.getOutputKey().equals(key)) .findFirst(); return output.map(Output::getOutputValue) .orElseThrow(() -> new RuntimeException("Did not find stack output.")); } }
private Collection<Output> listOutputs() { if (isEmpty(stackId)) { return Collections.emptyList(); } String nextToken = null; final DescribeStacksRequest request = new DescribeStacksRequest().withStackName(stackId); List<Output> result = new ArrayList<>(); do { request.setNextToken(nextToken); final DescribeStacksResult response = getService().describeStacks(request); result.addAll(response.getStacks().stream().flatMap(stack -> stack.getOutputs().stream()).collect(Collectors.toList())); nextToken = response.getNextToken(); } while (null != nextToken); return result; } }
public Map<String, String> describeOutputs() { DescribeStacksResult result = this.client.describeStacks(new DescribeStacksRequest().withStackName(this.stack)); Stack cfnStack = result.getStacks().get(0); Map<String, String> map = new HashMap<>(); for (Output output : cfnStack.getOutputs()) { map.put(output.getOutputKey(), output.getOutputValue()); } return map; }
private Properties getCloudformationOutputs(AmazonCloudFormation cloudFormation, CreateStackResult stack) { DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest(); describeStacksRequest.setStackName(stack.getStackId()); final DescribeStacksResult describeStacksResult = cloudFormation .describeStacks(describeStacksRequest); Properties outputProps = new Properties(); for (Stack st : describeStacksResult.getStacks()) { StringBuilder outputsStr = new StringBuilder("Infrastructure/Deployment outputs {\n"); for (Output output : st.getOutputs()) { outputProps.setProperty(output.getOutputKey(), output.getOutputValue()); outputsStr.append(output.getOutputKey()).append("=").append(output.getOutputValue()).append("\n"); } //Log cfn outputs logger.info(outputsStr.toString() + "\n}"); } return outputProps; }
public CompletableFuture<Stack> getStackWhen(String stackName, String... statuses) { DescribeStacksRequest request = new DescribeStacksRequest().withStackName(stackName); return describeStacks(request).thenApply(firstStack()).thenComposeAsync(stack -> { if (ImmutableSet.copyOf(statuses).contains(stack.getStackStatus()) && !stack.getOutputs().isEmpty()) { return CompletableFuture.completedFuture(stack); } else { Threads.sleep(1000); return getStackWhen(stackName, statuses); } }, executor); }
private void printOutputs(Stack stack) { getLogger().info("==== Outputs ===="); stack.getOutputs().stream() .forEach(o -> getLogger().info("{} ({}) = {}", o.getOutputKey(), o.getDescription(), o.getOutputValue())); } }
stack.getTags().stream().collect(Collectors.toMap(Tag::getKey, Tag::getValue))); stackAttributes.put("outputs", stack.getOutputs().stream().collect(Collectors.toMap(Output::getOutputKey, Output::getOutputValue))); stackAttributes.put("stackName", stack.getStackName()); stackAttributes.put("region", region);
if (getCapabilities() != null) sb.append("Capabilities: ").append(getCapabilities()).append(","); if (getOutputs() != null) sb.append("Outputs: ").append(getOutputs()).append(","); if (getRoleARN() != null) sb.append("RoleARN: ").append(getRoleARN()).append(",");
public CloudFormationOutput getStackOutputs(AmazonCloudFormation stackbuilder, String stackName) { DescribeStacksRequest wait = new DescribeStacksRequest(); wait.setStackName(stackName); List<Stack> stacks = getCloudFormationClient().describeStacks(wait).getStacks(); CloudFormationOutput cloudFormationOutput = new CloudFormationOutput(); for (Stack stack : stacks) { if (stack.getStackName().equals(stackName)) { stack.getOutputs().forEach(output -> { if (output.getOutputKey().equals(LAMBDA_EXECUTION_IAM_RESOURCE_NAME)) { cloudFormationOutput.setLambdaExecutionRole(output.getOutputValue()); } if (output.getOutputKey().equals(LAMBDA_EXECUTION_NAME)) { cloudFormationOutput.setLambdaFunctionArn(output.getOutputValue()); } }); return cloudFormationOutput; } } throw new RuntimeException("Unknown Cloudformation error. Try deploying."); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStackId() == null) ? 0 : getStackId().hashCode()); hashCode = prime * hashCode + ((getStackName() == null) ? 0 : getStackName().hashCode()); hashCode = prime * hashCode + ((getChangeSetId() == null) ? 0 : getChangeSetId().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getParameters() == null) ? 0 : getParameters().hashCode()); hashCode = prime * hashCode + ((getCreationTime() == null) ? 0 : getCreationTime().hashCode()); hashCode = prime * hashCode + ((getDeletionTime() == null) ? 0 : getDeletionTime().hashCode()); hashCode = prime * hashCode + ((getLastUpdatedTime() == null) ? 0 : getLastUpdatedTime().hashCode()); hashCode = prime * hashCode + ((getRollbackConfiguration() == null) ? 0 : getRollbackConfiguration().hashCode()); hashCode = prime * hashCode + ((getStackStatus() == null) ? 0 : getStackStatus().hashCode()); hashCode = prime * hashCode + ((getStackStatusReason() == null) ? 0 : getStackStatusReason().hashCode()); hashCode = prime * hashCode + ((getDisableRollback() == null) ? 0 : getDisableRollback().hashCode()); hashCode = prime * hashCode + ((getNotificationARNs() == null) ? 0 : getNotificationARNs().hashCode()); hashCode = prime * hashCode + ((getTimeoutInMinutes() == null) ? 0 : getTimeoutInMinutes().hashCode()); hashCode = prime * hashCode + ((getCapabilities() == null) ? 0 : getCapabilities().hashCode()); hashCode = prime * hashCode + ((getOutputs() == null) ? 0 : getOutputs().hashCode()); hashCode = prime * hashCode + ((getRoleARN() == null) ? 0 : getRoleARN().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getEnableTerminationProtection() == null) ? 0 : getEnableTerminationProtection().hashCode()); hashCode = prime * hashCode + ((getParentId() == null) ? 0 : getParentId().hashCode()); hashCode = prime * hashCode + ((getRootId() == null) ? 0 : getRootId().hashCode()); hashCode = prime * hashCode + ((getDriftInformation() == null) ? 0 : getDriftInformation().hashCode()); return hashCode; }
List<Output> outputs = stack.getOutputs(); for (Output output : outputs) { stackOutput.put(output.getOutputKey(), output.getOutputValue());
results.put(Outputs.STACK_CREATION_TIME_RESULT,stack.getCreationTime().toString()); results.put(Outputs.STACK_DESCRIPTION_RESULT,stack.getDescription()); results.put(Outputs.STACK_OUTPUTS_RESULT,stack.getOutputs().toString());
if (other.getCapabilities() != null && other.getCapabilities().equals(this.getCapabilities()) == false) return false; if (other.getOutputs() == null ^ this.getOutputs() == null) return false; if (other.getOutputs() != null && other.getOutputs().equals(this.getOutputs()) == false) return false; if (other.getRoleARN() == null ^ this.getRoleARN() == null)