use of com.amazonaws.services.cloudformation.model.DescribeStacksRequest in project pipeline-aws-plugin by jenkinsci.
the class CloudFormationStack method describeOutputs.
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;
}
use of com.amazonaws.services.cloudformation.model.DescribeStacksRequest in project pipeline-aws-plugin by jenkinsci.
the class EventPrinter method waitAndPrintStackEvents.
public void waitAndPrintStackEvents(String stack, Waiter<DescribeStacksRequest> waiter, long pollIntervalMillis) throws ExecutionException {
final BasicFuture<AmazonWebServiceRequest> waitResult = new BasicFuture<>(null);
waiter.runAsync(new WaiterParameters<>(new DescribeStacksRequest().withStackName(stack)), new WaiterHandler() {
@Override
public void onWaitSuccess(AmazonWebServiceRequest request) {
waitResult.completed(request);
}
@Override
public void onWaitFailure(Exception e) {
waitResult.failed(e);
}
});
this.waitAndPrintEvents(stack, pollIntervalMillis, waitResult);
}
use of com.amazonaws.services.cloudformation.model.DescribeStacksRequest in project cloudbreak by hortonworks.
the class AwsResourceConnector method getOutputs.
private Map<String, String> getOutputs(String cFStackName, AmazonCloudFormation client) {
DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest().withStackName(cFStackName);
String outputNotFound = String.format("Couldn't get Cloudformation stack's('%s') output", cFStackName);
List<Output> cfStackOutputs = client.describeStacks(describeStacksRequest).getStacks().stream().findFirst().orElseThrow(getCloudConnectorExceptionSupplier(outputNotFound)).getOutputs();
return cfStackOutputs.stream().collect(Collectors.toMap(Output::getOutputKey, Output::getOutputValue));
}
use of com.amazonaws.services.cloudformation.model.DescribeStacksRequest in project cloudbreak by hortonworks.
the class AwsStackValidator method validate.
@Override
public void validate(AuthenticatedContext ac, CloudStack cloudStack) {
AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential());
String regionName = ac.getCloudContext().getLocation().getRegion().value();
AmazonCloudFormationClient cfClient = awsClient.createCloudFormationClient(credentialView, regionName);
String cFStackName = cfStackUtil.getCfStackName(ac);
try {
cfClient.describeStacks(new DescribeStacksRequest().withStackName(cFStackName));
throw new CloudConnectorException(String.format("Stack is already exists with the given name: %s", cFStackName));
} catch (AmazonServiceException ignored) {
}
}
use of com.amazonaws.services.cloudformation.model.DescribeStacksRequest in project cloudbreak by hortonworks.
the class AwsCreateVpcNetworkTest method getOutputForRequest.
private List<Output> getOutputForRequest(String vpcStackName, AmazonCloudFormation client) {
int tried = 0;
while (tried < MAX_TRY) {
LOGGER.info("checking vpc stack creation result, tried: " + tried + '/' + MAX_TRY);
DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest();
describeStacksRequest.withStackName(vpcStackName);
Stack resultStack = client.describeStacks(describeStacksRequest).getStacks().get(0);
StackStatus stackStatus = StackStatus.valueOf(resultStack.getStackStatus());
if (FAILED_STATUSES.contains(stackStatus)) {
LOGGER.error("stack creation failed: {}", stackStatus);
throw new RuntimeException();
} else if (CREATE_COMPLETE.equals(stackStatus)) {
return resultStack.getOutputs();
}
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
LOGGER.error("thread sleep interrupted", e);
}
tried++;
}
throw new RuntimeException("vpc creation timed out");
}
Aggregations