本文整理汇总了Java中com.amazonaws.services.cloudformation.model.DescribeStacksResult类的典型用法代码示例。如果您正苦于以下问题:Java DescribeStacksResult类的具体用法?Java DescribeStacksResult怎么用?Java DescribeStacksResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DescribeStacksResult类属于com.amazonaws.services.cloudformation.model包,在下文中一共展示了DescribeStacksResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStackStatus
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
/**
* Returns the current status of the named stack.
*
* @param stackId Stack ID.
* @return Stack status data.
*/
@Nullable
public StackStatus getStackStatus(final String stackId) {
final DescribeStacksRequest request = new DescribeStacksRequest().withStackName(stackId);
try {
final DescribeStacksResult result = cloudFormationClient.describeStacks(request);
if (result.getStacks().size() > 0) {
final String status = result.getStacks().get(0).getStackStatus();
if (StringUtils.isNotBlank(status)) {
return StackStatus.fromValue(status);
}
}
} catch (final AmazonServiceException ase) {
// Stack doesn't exist, just return with no status
if (ase.getStatusCode() != 400) {
throw ase;
}
}
return null;
}
示例2: searchStacksForOutput
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
/**
* Since there doesn't appear to be a first class way through the SDK at this time to get a CF export. We can
* iterate through the stacks for a given output key and return the value.
* @param outputKey The exported CF variable to search and retrieve the value of.
* @return The value for the export if found
*/
public Optional<String> searchStacksForOutput(String outputKey) {
DescribeStacksResult describeStacksResult = null;
do {
DescribeStacksRequest request = new DescribeStacksRequest();
if (describeStacksResult != null && describeStacksResult.getNextToken() != null) {
request.withNextToken(describeStacksResult.getNextToken());
}
describeStacksResult = cloudFormationClient.describeStacks();
for (Stack stack : describeStacksResult.getStacks()) {
for (Output output : stack.getOutputs()) {
if (StringUtils.equals(output.getOutputKey(), outputKey)) {
return Optional.of(output.getOutputValue());
}
}
}
} while (describeStacksResult.getNextToken() != null);
return Optional.empty();
}
示例3: getObject_stackWithTagsDefined_createTagsMap
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
@Test
public void getObject_stackWithTagsDefined_createTagsMap() throws Exception {
//Arrange
AmazonCloudFormation cloudFormation = mock(AmazonCloudFormation.class);
StackNameProvider stackNameProvider = mock(StackNameProvider.class);
when(stackNameProvider.getStackName()).thenReturn("testStack");
when(cloudFormation.describeStacks(new DescribeStacksRequest().withStackName("testStack"))).
thenReturn(new DescribeStacksResult().withStacks(new Stack().withTags(
new Tag().withKey("key1").withValue("value1"),
new Tag().withKey("key2").withValue("value2")
)));
StackResourceUserTagsFactoryBean factoryBean = new StackResourceUserTagsFactoryBean(cloudFormation, stackNameProvider);
//Act
factoryBean.afterPropertiesSet();
Map<String, String> factoryBeanObject = factoryBean.getObject();
//Assert
assertEquals("value1", factoryBeanObject.get("key1"));
assertEquals("value2", factoryBeanObject.get("key2"));
}
示例4: DefaultListableBeanFactory
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
@Test
public void parseInternal_stackConfigurationWithExternallyConfiguredCloudFormationClient_returnsConfiguredStackWithExternallyConfiguredClient() throws Exception {
//Arrange
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
reader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-withCustomCloudFormationClient.xml", getClass()));
AmazonCloudFormation amazonCloudFormationMock = beanFactory.getBean(AmazonCloudFormation.class);
when(amazonCloudFormationMock.listStackResources(new ListStackResourcesRequest().withStackName("test"))).
thenReturn(new ListStackResourcesResult().withStackResourceSummaries(new StackResourceSummary()));
when(amazonCloudFormationMock.describeStacks(new DescribeStacksRequest().withStackName("test"))).
thenReturn(new DescribeStacksResult().withStacks(new Stack()));
//Act
StackResourceRegistry stackResourceRegistry = beanFactory.getBean(StackResourceRegistry.class);
//Assert
assertNotNull(stackResourceRegistry);
assertFalse(beanFactory.containsBeanDefinition(getBeanName(AmazonCloudFormationClient.class.getName())));
verify(amazonCloudFormationMock, times(1)).listStackResources(new ListStackResourcesRequest().withStackName("test"));
beanFactory.getBean("customStackTags");
verify(amazonCloudFormationMock, times(1)).describeStacks(new DescribeStacksRequest().withStackName("test"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:26,代码来源:StackConfigurationBeanDefinitionParserTest.java
示例5: getStackParameters
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
/**
* Returns the current status of the named stack.
*
* @param stackId Stack name.
* @return Stack outputs data.
*/
public Map<String, String> getStackParameters(final String stackId) {
final DescribeStacksRequest request = new DescribeStacksRequest().withStackName(stackId);
final DescribeStacksResult result = cloudFormationClient.describeStacks(request);
final Map<String, String> parameters = Maps.newHashMap();
if (result.getStacks().size() > 0) {
parameters.putAll(result.getStacks().get(0).getParameters().stream().collect(
Collectors.toMap(Parameter::getParameterKey, Parameter::getParameterValue)));
}
return parameters;
}
示例6: getStackOutputs
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
/**
* Returns the current status of the named stack.
*
* @param stackId Stack name.
* @return Stack outputs data.
*/
public Map<String, String> getStackOutputs(final String stackId) {
final DescribeStacksRequest request = new DescribeStacksRequest().withStackName(stackId);
final DescribeStacksResult result = cloudFormationClient.describeStacks(request);
final Map<String, String> outputs = Maps.newHashMap();
if (result.getStacks().size() > 0) {
outputs.putAll(result.getStacks().get(0).getOutputs().stream().collect(
Collectors.toMap(Output::getOutputKey, Output::getOutputValue)));
}
return outputs;
}
示例7: listExistingApplications
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
private void listExistingApplications(CommandLine cmd, String region) {
logger.debug("list environments for region: {}", region);
DescribeStacksResult dst = null;
if (cmd.hasOption("e")) {
dst = provider.describeStacks(cmd.getOptionValue("e"));
} else {
dst = provider.describeStacks(null);
}
logger.debug("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
logger.info("active applications: {}", dst);
logger.debug("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
}
示例8: createInstance
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
@Override
protected Map<String, String> createInstance() throws Exception {
LinkedHashMap<String, String> userTags = new LinkedHashMap<>();
DescribeStacksResult stacksResult = this.amazonCloudFormation.describeStacks(new DescribeStacksRequest().withStackName(this.stackNameProvider.getStackName()));
for (Stack stack : stacksResult.getStacks()) {
for (Tag tag : stack.getTags()) {
userTags.put(tag.getKey(), tag.getValue());
}
}
return userTags;
}
示例9: getStackResources
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
private DescribeStackResourcesResult getStackResources(String stackName) throws InterruptedException, IOException {
try {
DescribeStacksResult describeStacksResult = this.amazonCloudFormationClient.describeStacks(new DescribeStacksRequest().withStackName(stackName));
for (Stack stack : describeStacksResult.getStacks()) {
if (isAvailable(stack)) {
return this.amazonCloudFormationClient.describeStackResources(new DescribeStackResourcesRequest().withStackName(stack.getStackName()));
}
if (isError(stack)) {
if (this.stackCreatedByThisInstance) {
throw new IllegalArgumentException("Could not create stack");
}
this.amazonCloudFormationClient.deleteStack(new DeleteStackRequest().withStackName(stack.getStackName()));
return getStackResources(stackName);
}
if (isInProgress(stack)) {
//noinspection BusyWait
Thread.sleep(5000L);
return getStackResources(stackName);
}
}
} catch (AmazonClientException e) {
String templateBody = FileCopyUtils.copyToString(new InputStreamReader(new ClassPathResource(TEMPLATE_PATH).getInputStream()));
this.amazonCloudFormationClient.createStack(new CreateStackRequest().withTemplateBody(templateBody).withOnFailure(OnFailure.DELETE).
withStackName(stackName).withTags(new Tag().withKey("tag1").withValue("value1")).
withParameters(new Parameter().withParameterKey("RdsPassword").withParameterValue(this.rdsPassword)));
this.stackCreatedByThisInstance = true;
}
return getStackResources(stackName);
}
示例10: getStack
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
private static Stack getStack(DescribeStacksResult describeStacksResult, String stackName) {
for (Stack stack : describeStacksResult.getStacks()) {
if (stack.getStackName().equals(stackName)) {
return stack;
}
}
throw new IllegalStateException("No stack found with name '" + stackName + "' (available stacks: " + allStackNames(describeStacksResult) + ")");
}
示例11: getInstanceId
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
@Override
public String getInstanceId() {
DescribeStacksResult describeStacksResult = this.amazonCloudFormationClient.describeStacks(new DescribeStacksRequest());
Stack stack = getStack(describeStacksResult, this.stackName);
return getOutputValue(stack, this.outputKey);
}
示例12: fetchCurrentStacks
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
private List<String> fetchCurrentStacks() {
List<String> current = new LinkedList<>();
DescribeStacksResult result = cfnClient.describeStacks();
for(Stack stack : result.getStacks()) {
current.add(stack.getStackName());
}
return current;
}
示例13: describeStack
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
private List<Stack> describeStack(String stackName) {
final DescribeStacksResult result = cloudFormation
.describeStacks(new DescribeStacksRequest().withStackName(stackName));
return result.getStacks();
}
示例14: findStack
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
public Stack findStack() throws Exception {
final DescribeStacksRequest request = new DescribeStacksRequest();
final DescribeStacksResult result = amazonClient
.describeStacks(request);
for (final Stack stack : result.getStacks()) {
if (name.equals(stack.getStackName())) {
return stack;
}
}
return null;
}
示例15: describeStacks
import com.amazonaws.services.cloudformation.model.DescribeStacksResult; //导入依赖的package包/类
DescribeStacksResult describeStacks(String environment);