List of usage examples for com.amazonaws.services.cloudformation.model StackEvent getResourceStatusReason
public String getResourceStatusReason()
Success/failure message associated with the resource.
From source file:com.carrotgarden.maven.aws.cfn.CarrotCloudForm.java
License:BSD License
private void printStackEvents() { final DescribeStackEventsRequest request = new DescribeStackEventsRequest(); request.withStackName(name);//from w ww . j av a 2s . c o m final DescribeStackEventsResult describeStackEvents = amazonClient.describeStackEvents(request); final List<StackEvent> stackEvents = describeStackEvents.getStackEvents(); Collections.reverse(stackEvents); logger.info("stack events:"); for (final StackEvent event : stackEvents) { final StringBuilder text = new StringBuilder(128); text.append("\n\t"); text.append("time="); text.append(event.getTimestamp()); text.append("\n\t"); text.append("id="); text.append(event.getEventId()); text.append("\n\t"); text.append("type="); text.append(event.getResourceType()); text.append("\n\t"); text.append("status="); text.append(event.getResourceStatus()); text.append("\n\t"); text.append("reason="); text.append(event.getResourceStatusReason()); logger.info("event {}", text); } }
From source file:com.nike.cerberus.service.CloudFormationService.java
License:Apache License
/** * Blocking call that waits for a stack change to complete. Times out if waiting more than 30 minutes. * * @param endStatuses Status to end on/*from ww w.ja v a2s . c om*/ * @return The final status */ public StackStatus waitForStatus(final String stackId, final HashSet<StackStatus> endStatuses) { DateTime now = DateTime.now(DateTimeZone.UTC).minusSeconds(10); DateTime timeoutDateTime = now.plusMinutes(90); Set<String> recordedStackEvents = Sets.newHashSet(); boolean isRunning = true; StackStatus stackStatus = null; while (isRunning) { try { TimeUnit.SECONDS.sleep(5); } catch (InterruptedException e) { logger.warn("Thread sleep interrupted. Continuing...", e); } stackStatus = getStackStatus(stackId); if (endStatuses.contains(stackStatus) || stackStatus == null) { isRunning = false; } if (stackStatus != null) { List<StackEvent> stackEvents = getStackEvents(stackId); stackEvents.sort((o1, o2) -> o1.getTimestamp().compareTo(o2.getTimestamp())); for (StackEvent stackEvent : stackEvents) { DateTime eventTime = new DateTime(stackEvent.getTimestamp()); if (!recordedStackEvents.contains(stackEvent.getEventId()) && now.isBefore(eventTime)) { logger.info(String.format("TS: %s, Status: %s, Type: %s, Reason: %s", Chalk.on(stackEvent.getTimestamp().toString()).yellow(), getStatusColor(stackEvent.getResourceStatus()), Chalk.on(stackEvent.getResourceType()).yellow(), Chalk.on(stackEvent.getResourceStatusReason()).yellow())); recordedStackEvents.add(stackEvent.getEventId()); } } } if (timeoutDateTime.isBeforeNow()) { logger.error("Timed out waiting for CloudFormation completion status."); isRunning = false; } } return stackStatus; }
From source file:de.taimos.pipeline.aws.cloudformation.EventPrinter.java
License:Apache License
private void printEvent(SimpleDateFormat sdf, StackEvent event) { String time = this.padRight(sdf.format(event.getTimestamp()), 25); String logicalResourceId = this.padRight(event.getLogicalResourceId(), 20); String resourceStatus = this.padRight(event.getResourceStatus(), 36); String resourceStatusReason = this.padRight(event.getResourceStatusReason(), 140); this.listener.getLogger().format("| %s | %s | %s | %s |%n", time, logicalResourceId, resourceStatus, resourceStatusReason);//from w ww. j ava 2 s.c o m }