本文整理汇总了Java中com.amazonaws.services.cloudformation.model.Stack类的典型用法代码示例。如果您正苦于以下问题:Java Stack类的具体用法?Java Stack怎么用?Java Stack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Stack类属于com.amazonaws.services.cloudformation.model包,在下文中一共展示了Stack类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getStack
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
protected Optional<Stack> getStack() {
final List<Stack> stacks;
try {
stacks = cloudFormation.describeStacks(new DescribeStacksRequest().withStackName(stackName)).getStacks();
} catch (final AmazonCloudFormationException e) {
if (e.getStatusCode() == 400) {
return Optional.empty();
}
throw e;
}
if (stacks.isEmpty()) {
return Optional.empty();
}
if (stacks.size() > 1) {
throw new DeploymentException("Found more than one stack for name '" + stackName + "'");
}
final Stack stack = stacks.get(0);
return Optional.of(stack);
}
开发者ID:kaklakariada,项目名称:aws-sam-gradle,代码行数:20,代码来源:StackStatusWaitCondition.java
示例2: searchStacksForOutput
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的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();
}
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:27,代码来源:CloudFormationService.java
示例3: getObject_stackWithTagsDefined_createTagsMap
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的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"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:25,代码来源:StackResourceUserTagsFactoryBeanTest.java
示例4: DefaultListableBeanFactory
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的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: getOutputForRequest
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
private List<Output> getOutputForRequest(String vpcStackName, AmazonCloudFormationClient 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");
}
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:24,代码来源:AwsCreateVpcNetworkTest.java
示例6: updateStack
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
private StackNameAndId updateStack(ProjectAndEnv projAndEnv, Collection<Parameter> userParameters,
List<TemplateParameter> declaredParameters, String contents,
ParameterFactory parameterFactory) throws CfnAssistException, IOException, InterruptedException {
Collection<Parameter> parameters = parameterFactory.createRequiredParameters(projAndEnv, userParameters,
declaredParameters, this);
String stackName = findStackToUpdate(declaredParameters, projAndEnv);
StackNameAndId id = cfnRepository.updateStack(contents, parameters, monitor, stackName);
try {
monitor.waitForUpdateFinished(id);
} catch (WrongStackStatus stackFailedToUpdate) {
logger.error("Failed to update stack",stackFailedToUpdate);
cfnRepository.updateFail(id);
throw stackFailedToUpdate;
}
Stack createdStack = cfnRepository.updateSuccess(id);
createOutputTags(createdStack, projAndEnv);
return id;
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:22,代码来源:AwsFacade.java
示例7: setUpdateExpectations
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
protected StackNameAndId setUpdateExpectations(String stackName, String filename,
List<TemplateParameter> templateParameters,
Collection<Parameter> parameters)
throws CfnAssistException, InterruptedException, IOException {
String stackId = "stackId";
Stack stack = new Stack().withStackId(stackId);
StackNameAndId stackNameAndId = new StackNameAndId(stackName, stackId);
String contents = EnvironmentSetupForTests.loadFile(filename);
EasyMock.expect(vpcRepository.getCopyOfVpc(projectAndEnv)).andReturn(new Vpc().withVpcId(VPC_ID));
EasyMock.expect(cfnRepository.validateStackTemplate(contents)).andReturn(templateParameters);
EasyMock.expect(cfnRepository.updateStack(contents, parameters, monitor, stackName)).andReturn(stackNameAndId);
EasyMock.expect(monitor.waitForUpdateFinished(stackNameAndId)).andReturn(StackStatus.UPDATE_COMPLETE.toString());
EasyMock.expect(cfnRepository.updateSuccess(stackNameAndId)).andReturn(stack);
EasyMock.expect(cloudRepository.getZones()).andReturn(zones);
return stackNameAndId;
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:19,代码来源:UpdateStackExpectations.java
示例8: SetCreateExpectations
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
private StackNameAndId SetCreateExpectations(String stackName, String contents,
List<TemplateParameter> templateParameters,
Collection<Parameter> creationParameters, String comment, Collection<Output> outputs,
Map<String, AvailabilityZone> zones)
throws CfnAssistException, InterruptedException {
StackNameAndId stackNameAndId = new StackNameAndId(stackName, "stackId");
Stack stack = new Stack().withStackId("stackId");
if (outputs.size()>0) {
stack.setOutputs(outputs);
}
EasyMock.expect(vpcRepository.getCopyOfVpc(projectAndEnv)).andReturn(new Vpc().withVpcId(VPC_ID));
EasyMock.expect(cfnRepository.validateStackTemplate(contents)).andReturn(templateParameters);
EasyMock.expect(cfnRepository.getStackStatus(stackName)).andReturn("");
Tagging tagging = new Tagging();
tagging.setCommentTag(comment);
EasyMock.expect(cfnRepository.createStack(projectAndEnv, contents, stackName, creationParameters, monitor, tagging)).
andReturn(stackNameAndId);
EasyMock.expect(cloudRepository.getZones()).andReturn(zones);
EasyMock.expect(monitor.waitForCreateFinished(stackNameAndId)).andReturn(CREATE_COMP_STATUS);
EasyMock.expect(identityProvider.getUserId()).andReturn(user);
CFNAssistNotification notification = new CFNAssistNotification(stackName, CREATE_COMP_STATUS, user);
EasyMock.expect(notificationSender.sendNotification(notification)).andReturn("sendMessageID");
EasyMock.expect(cfnRepository.createSuccess(stackNameAndId)).andReturn(stack);
return stackNameAndId;
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:27,代码来源:TestAwsFacadeCreatesStacks.java
示例9: shouldListStacks
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
@Test
public void shouldListStacks() throws MissingArgumentException, CfnAssistException, InterruptedException, IOException {
String stackName = "theStackName";
String project = "theProject";
String stackId = "theStackId";
String env = "theEnv";
setFactoryExpectations();
List<StackEntry> stackEntries = new LinkedList<>();
Stack stack = new Stack().withStackName(stackName).withStackId(stackId).withStackStatus(StackStatus.CREATE_COMPLETE);
stackEntries.add(new StackEntry(project, new EnvironmentTag(env), stack));
EasyMock.expect(facade.listStacks(projectAndEnv)).andReturn(stackEntries);
String output = validate(CLIArgBuilder.listStacks());
CLIArgBuilder.checkForExpectedLine(stackName, project, env, output);
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:19,代码来源:TestCommandLineActions.java
示例10: createInstance
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的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;
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:12,代码来源:StackResourceUserTagsFactoryBean.java
示例11: getStackResources
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的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);
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:31,代码来源:TestStackEnvironment.java
示例12: getStack
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的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) + ")");
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:10,代码来源:TestStackInstanceIdService.java
示例13: getInstanceId
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
@Override
public String getInstanceId() {
DescribeStacksResult describeStacksResult = this.amazonCloudFormationClient.describeStacks(new DescribeStacksRequest());
Stack stack = getStack(describeStacksResult, this.stackName);
return getOutputValue(stack, this.outputKey);
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:8,代码来源:TestStackInstanceIdService.java
示例14: getOutputValue
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
private static String getOutputValue(Stack stack, String outputKey) {
for (Output output : stack.getOutputs()) {
if (output.getOutputKey().equals(outputKey)) {
return output.getOutputValue();
}
}
throw new IllegalStateException("No output '" + outputKey + "' defined in stack '" + stack.getStackName() + "'");
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:10,代码来源:TestStackInstanceIdService.java
示例15: doCall
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
@Override
protected Boolean doCall() {
LOGGER.info("Checking if AWS CloudFormation stack '{}' reached status '{}'", cloudFormationStackName, successStatus);
try {
com.amazonaws.services.cloudformation.model.Stack cfStack = cfClient.describeStacks(describeStacksRequest).getStacks().get(0);
List<StackEvent> stackEvents = cfClient.describeStackEvents(stackEventsRequest).getStackEvents();
return doCheck(cfStack, stackEvents);
} catch (AmazonServiceException e) {
return handleError(e);
}
}
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:13,代码来源:AbstractAwsStackStatusCheckerTask.java
示例16: isSuccess
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
protected boolean isSuccess(Stack cfStack, List<StackEvent> stackEvents) {
if (!stackEvents.isEmpty() && cfStack != null) {
StackStatus cfStackStatus = StackStatus.valueOf(cfStack.getStackStatus());
if (stackErrorStatuses.contains(cfStackStatus)) {
throw new CloudConnectorException(getErrorMessage(errorStatus.toString(), getErrorCauseStatusReason(stackEvents, errorStatus)));
} else if (cfStackStatus.equals(successStatus)) {
return true;
}
}
return false;
}
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:12,代码来源:AbstractAwsStackStatusCheckerTask.java
示例17: createStack
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
private StackNameAndId createStack(File file, ProjectAndEnv projAndEnv,
Collection<Parameter> userParameters,
List<TemplateParameter> declaredParameters,
String contents,
ParameterFactory parameterFactory, Tagging tagging)
throws CfnAssistException, InterruptedException, IOException {
String stackName = createStackName(file, projAndEnv);
logger.info("Stackname is " + stackName);
handlePossibleRollback(stackName);
Collection<Parameter> parameters = parameterFactory.createRequiredParameters(projAndEnv, userParameters, declaredParameters, this);
StackNameAndId id = cfnRepository.createStack(projAndEnv, contents, stackName, parameters, monitor, tagging);
try {
monitor.waitForCreateFinished(id);
} catch (WrongStackStatus stackFailedToCreate) {
logger.error("Failed to create stack",stackFailedToCreate);
cfnRepository.createFail(id);
throw stackFailedToCreate;
}
Stack createdStack = cfnRepository.createSuccess(id);
createOutputTags(createdStack, projAndEnv);
sendNotification(stackName, StackStatus.CREATE_COMPLETE.toString());
return id;
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:28,代码来源:AwsFacade.java
示例18: createOutputTags
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
private void createOutputTags(Stack createdStack, ProjectAndEnv projAndEnv) {
List<Output> outputs = createdStack.getOutputs();
outputs.stream().filter(output -> shouldCreateTag(output.getDescription())).forEach(output -> {
logger.info("Should create output tag for " + output.toString());
vpcRepository.setVpcTag(projAndEnv, output.getOutputKey(), output.getOutputValue());
});
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:8,代码来源:AwsFacade.java
示例19: getAllStacksForProject
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
private void getAllStacksForProject() {
// TODO handle "next token"?
if (theEntries.size() == 0) {
logger.info("No cached stacks, loading all stacks");
List<Stack> stacks = formationClient.describeAllStacks();
populateEntriesIfProjectMatches(stacks);
logger.info(String.format("Loaded %s stacks", theEntries.size()));
} else {
logger.info("Cache hit on stacks");
}
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:13,代码来源:StackCache.java
示例20: populateEntriesIfProjectMatches
import com.amazonaws.services.cloudformation.model.Stack; //导入依赖的package包/类
private void populateEntriesIfProjectMatches(List<Stack> stacks) {
logger.info(String.format("Populating stack entries for %s stacks", stacks.size()));
for(Stack stack : stacks) {
logger.info(String.format("Checking stack %s for tag", stack.getStackName()));
List<Tag> tags = stack.getTags();
Map<String, String> keyValues = convertToMap(tags);
int count = 3;
String env = "";
String proj = "";
Integer build = null;
for(Tag tag : tags) {
String key = tag.getKey();
String value = tag.getValue();
if (key.equals(AwsFacade.ENVIRONMENT_TAG)) {
env = value;
count--;
} else if (key.equals(AwsFacade.PROJECT_TAG)) {
proj = value;
count--;
} else if (key.equals(AwsFacade.BUILD_TAG)) {
build = Integer.parseInt(value);
count--;
}
if (count==0) break; // small optimisation
}
//String index = keyValues.get(AwsFacade.INDEX_TAG);
addEntryIfProjectAndEnvMatches(stack, env, proj, build, keyValues);
}
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:32,代码来源:StackCache.java
注:本文中的com.amazonaws.services.cloudformation.model.Stack类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论