use of com.amazonaws.services.cloudformation.model.DescribeStackResourcesRequest in project cloudbreak by hortonworks.
the class AwsMigrationUtil method allInstancesDeletedFromCloudFormation.
public boolean allInstancesDeletedFromCloudFormation(AuthenticatedContext ac, CloudResource cloudResource) {
String regionName = ac.getCloudContext().getLocation().getRegion().value();
AwsCredentialView awsCredential = new AwsCredentialView(ac.getCloudCredential());
DescribeStackResourcesResult describeStackResourcesResult = awsClient.createCloudFormationClient(awsCredential, regionName).describeStackResources(new DescribeStackResourcesRequest().withStackName(cloudResource.getName()));
List<StackResource> asGroups = describeStackResourcesResult.getStackResources().stream().filter(it -> "AWS::AutoScaling::AutoScalingGroup".equals(it.getResourceType())).collect(Collectors.toList());
LOGGER.debug("AutoScalingGroup fetched: {}", asGroups);
boolean empty = true;
int i = 0;
while (empty && i < asGroups.size()) {
StackResource asGroup = asGroups.get(i);
List<String> result = cfStackUtil.getInstanceIds(awsClient.createAutoScalingClient(awsCredential, regionName), asGroup.getPhysicalResourceId());
LOGGER.debug("{} autoScalingGroup has {} instance(s): {}", asGroup.getPhysicalResourceId(), result.size(), result);
empty = result.isEmpty();
i++;
}
return empty;
}
use of com.amazonaws.services.cloudformation.model.DescribeStackResourcesRequest in project spring-cloud-aws by awspring.
the class StackConfigurationBeanDefinitionParserTest method resourceIdResolverResolveToPhysicalResourceId_stackConfigurationWithoutStaticNameAndLogicalResourceIdOfExistingResourceProvided_returnsPhysicalResourceId.
// @checkstyle:off
@Test
void resourceIdResolverResolveToPhysicalResourceId_stackConfigurationWithoutStaticNameAndLogicalResourceIdOfExistingResourceProvided_returnsPhysicalResourceId() throws Exception {
// @checkstyle:on
// Arrange
HttpServer server = MetaDataServer.setupHttpServer();
HttpContext httpContext = server.createContext("/latest/meta-data/instance-id", new MetaDataServer.HttpResponseWriterHandler("foo"));
GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
AmazonCloudFormation amazonCloudFormation = Mockito.mock(AmazonCloudFormation.class);
when(amazonCloudFormation.describeStackResources(new DescribeStackResourcesRequest().withPhysicalResourceId("foo"))).thenReturn(new DescribeStackResourcesResult().withStackResources(new StackResource().withStackName("test")));
when(amazonCloudFormation.listStackResources(new ListStackResourcesRequest().withStackName("test"))).thenReturn(new ListStackResourcesResult().withStackResourceSummaries(new StackResourceSummary().withLogicalResourceId("EmptyBucket").withPhysicalResourceId("integrationteststack-emptybucket-foo")));
applicationContext.load(new ClassPathResource(getClass().getSimpleName() + "-autoDetectStackName.xml", getClass()));
applicationContext.getBeanFactory().registerSingleton(getBeanName(AmazonCloudFormation.class.getName()), amazonCloudFormation);
applicationContext.refresh();
ResourceIdResolver resourceIdResolver = applicationContext.getBean(ResourceIdResolver.class);
// Act
String physicalResourceId = resourceIdResolver.resolveToPhysicalResourceId("EmptyBucket");
// Assert
assertThat(physicalResourceId).startsWith("integrationteststack-emptybucket-");
server.removeContext(httpContext);
}
use of com.amazonaws.services.cloudformation.model.DescribeStackResourcesRequest in project cs-actions by CloudSlang.
the class GetStackDetailsAction method getStackResources.
private String getStackResources(String stackName, AmazonCloudFormation stackBuilder) throws IOException {
final DescribeStackResourcesRequest stackResourceRequest = new DescribeStackResourcesRequest().withStackName(stackName);
DescribeStackResourcesResult describeStackResourcesResult = stackBuilder.describeStackResources(stackResourceRequest);
String stackResources = OutputsUtil.getStackResourcesToJson(describeStackResourcesResult);
return stackResources;
}
Aggregations