当前位置: 首页>>代码示例>>Java>>正文


Java AmazonCloudFormation类代码示例

本文整理汇总了Java中com.amazonaws.services.cloudformation.AmazonCloudFormation的典型用法代码示例。如果您正苦于以下问题:Java AmazonCloudFormation类的具体用法?Java AmazonCloudFormation怎么用?Java AmazonCloudFormation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AmazonCloudFormation类属于com.amazonaws.services.cloudformation包,在下文中一共展示了AmazonCloudFormation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CreateCloudFrontSecurityGroupUpdaterLambdaOperation

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
@Inject
public CreateCloudFrontSecurityGroupUpdaterLambdaOperation(final CloudFormationService cloudFormationService,
                                                           final EnvironmentMetadata environmentMetadata,
                                                           @Named(CF_OBJECT_MAPPER) final ObjectMapper cloudformationObjectMapper,
                                                           AWSLambda awsLambda,
                                                           AmazonS3 amazonS3) {

    this.cloudFormationService = cloudFormationService;
    this.cloudformationObjectMapper = cloudformationObjectMapper;
    this.environmentMetadata = environmentMetadata;
    this.awsLambda = awsLambda;
    this.amazonS3 = amazonS3;

    final Region region = Region.getRegion(Regions.US_EAST_1);
    AmazonCloudFormation amazonCloudFormation = new AmazonCloudFormationClient();
    amazonCloudFormation.setRegion(region);
    amazonSNS = new AmazonSNSClient();
    amazonSNS.setRegion(region);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:20,代码来源:CreateCloudFrontSecurityGroupUpdaterLambdaOperation.java

示例2: deleteFailedCreate

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
private void deleteFailedCreate(final String stackName, AmazonCloudFormation cf, int statusPollingIntervalMs) {
    {
        // delete an application in ROLLBACK_COMPLETE status

        ListStacksResult r = cf.listStacks();
        r.getStackSummaries() //
                .stream() //
                .filter(x -> x.getStackName().equals(stackName)) //
                .limit(1) //
                .filter(x -> StackStatus.ROLLBACK_COMPLETE.toString().equals(x.getStackStatus())) //
                .forEach(x -> {
                    log.info("Deleting stack with status " + x.getStackStatus()); //
                    cf.deleteStack(new DeleteStackRequest().withStackName(stackName));
                    waitForCompletion(cf, stackName, statusPollingIntervalMs, log);
                });

    }
}
 
开发者ID:davidmoten,项目名称:aws-maven-plugin,代码行数:19,代码来源:CloudFormationDeployer.java

示例3: displayStatusHistory

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
private void displayStatusHistory(final String stackName, AmazonCloudFormation cf) {
    {
        // list history of application
        log.info("------------------------------");
        log.info("Stack history - " + stackName);
        log.info("------------------------------");
        ListStacksResult r = cf.listStacks();
        r.getStackSummaries() //
                .stream() //
                .filter(x -> x.getStackName().equals(stackName)) //
                .forEach(x -> {
                    log.info("id=" + x.getStackId());
                    log.info("  status=" + x.getStackStatus());
                    log.info("  created=" + x.getCreationTime());
                    log.info("  update=" + x.getLastUpdatedTime());
                    log.info("  deleted=" + x.getDeletionTime());
                });
        log.info("");
    }
}
 
开发者ID:davidmoten,项目名称:aws-maven-plugin,代码行数:21,代码来源:CloudFormationDeployer.java

示例4: displayEvents

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
private void displayEvents(final String stackName, AmazonCloudFormation cf, long sinceTime) {
    // list history of application
    log.info("------------------------------");
    log.info("Event history - " + stackName);
    log.info("------------------------------");
    DescribeStackEventsResult r = cf.describeStackEvents(new DescribeStackEventsRequest().withStackName(stackName));
    r.getStackEvents() //
            .stream() //
            .sorted((a, b) -> a.getTimestamp().compareTo(b.getTimestamp())) //
            .filter(x -> x.getTimestamp().getTime() >= sinceTime - TimeUnit.MINUTES.toMillis(1)) //
            .forEach(x -> {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-ddd HH:mm:ss");
                log.info(sdf.format(x.getTimestamp()) + " " + x.getResourceStatus() + " " + x.getResourceType());
                if (x.getResourceStatusReason() != null) {
                    log.info("  reason=" + x.getResourceStatusReason());
                    if (x.getResourceProperties() != null) {
                        log.info("  properties=\n");
                        log.info(Util.formatJson(x.getResourceProperties()));
                    }
                }
            });
}
 
开发者ID:davidmoten,项目名称:aws-maven-plugin,代码行数:23,代码来源:CloudFormationDeployer.java

示例5: getStackOutputs

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
public CloudFormationOutput getStackOutputs(AmazonCloudFormation stackbuilder,
                                            String stackName) {
    DescribeStacksRequest wait = new DescribeStacksRequest();
    wait.setStackName(stackName);
    List<Stack> stacks = getCloudFormationClient().describeStacks(wait).getStacks();

    CloudFormationOutput cloudFormationOutput = new CloudFormationOutput();

    for (Stack stack : stacks) {
        if (stack.getStackName().equals(stackName)) {
            stack.getOutputs().forEach(output -> {
                if (output.getOutputKey().equals(LAMBDA_EXECUTION_IAM_RESOURCE_NAME)) {
                    cloudFormationOutput.setLambdaExecutionRole(output.getOutputValue());
                }

                if (output.getOutputKey().equals(LAMBDA_EXECUTION_NAME)) {
                    cloudFormationOutput.setLambdaFunctionArn(output.getOutputValue());
                }
            });
            return cloudFormationOutput;
        }
    }
    throw new RuntimeException("Unknown Cloudformation error. Try deploying.");

}
 
开发者ID:lambadaframework,项目名称:lambadaframework,代码行数:26,代码来源:Cloudformation.java

示例6: CfSignalResourceBundle

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
public CfSignalResourceBundle() {
  cloudFormationSupplier = (cfSignalResourceConfig) -> {
    AmazonCloudFormation amazonCloudFormation = internalCloudFormation.get();

    if (amazonCloudFormation != null) {
      return amazonCloudFormation;
    }

    return internalCloudFormation.updateAndGet((unused) -> {

      AmazonCloudFormationClient amazonCloudFormationClient = new AmazonCloudFormationClient();

      String awsRegion = cfSignalResourceConfig.getAwsRegion();
      Region region;
      if (Strings.isNullOrEmpty(awsRegion)) {
        region = Regions.getCurrentRegion();
      }
      else {
        region = Region.getRegion(Regions.fromName(awsRegion));
      }
      amazonCloudFormationClient.setRegion(region);

      return amazonCloudFormationClient;
    });
  };
}
 
开发者ID:heldeen,项目名称:cf-signal-resource-bundle,代码行数:27,代码来源:CfSignalResourceBundle.java

示例7: getObject_stackWithTagsDefined_createTagsMap

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的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

示例8: DefaultListableBeanFactory

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的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

示例9: resourceIdResolver_stackConfiguration_resourceIdResolverBeanExposed

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
@Test
public void resourceIdResolver_stackConfiguration_resourceIdResolverBeanExposed() {
    // Arrange
    GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
    AmazonCloudFormation amazonCloudFormation = Mockito.mock(AmazonCloudFormation.class);

    when(amazonCloudFormation.listStackResources(new ListStackResourcesRequest().withStackName("IntegrationTestStack"))).
            thenReturn(new ListStackResourcesResult().withStackResourceSummaries(new StackResourceSummary()));

    applicationContext.load(new ClassPathResource(getClass().getSimpleName() + "-staticStackName.xml", getClass()));
    applicationContext.getBeanFactory().registerSingleton(getBeanName(AmazonCloudFormation.class.getName()), amazonCloudFormation);

    applicationContext.refresh();

    // Act
    ResourceIdResolver resourceIdResolver = applicationContext.getBean(ResourceIdResolver.class);

    // Assert
    assertThat(resourceIdResolver, is(not(nullValue())));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:21,代码来源:StackConfigurationBeanDefinitionParserTest.java

示例10: GenericXmlApplicationContext

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
@Test
public void stackResourceRegistry_stackConfigurationWithStaticName_stackResourceRegistryBeanExposedUnderStaticStackName() throws Exception {
    // Arrange
    GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
    AmazonCloudFormation amazonCloudFormation = Mockito.mock(AmazonCloudFormation.class);

    when(amazonCloudFormation.listStackResources(new ListStackResourcesRequest().withStackName("IntegrationTestStack"))).
            thenReturn(new ListStackResourcesResult().withStackResourceSummaries(new StackResourceSummary()));

    applicationContext.load(new ClassPathResource(getClass().getSimpleName() + "-staticStackName.xml", getClass()));
    applicationContext.getBeanFactory().registerSingleton(getBeanName(AmazonCloudFormation.class.getName()), amazonCloudFormation);

    applicationContext.refresh();

    // Act
    StackResourceRegistry staticStackNameProviderBasedStackResourceRegistry = applicationContext.getBean("IntegrationTestStack", StackResourceRegistry.class);

    // Assert
    assertThat(staticStackNameProviderBasedStackResourceRegistry, is(not(nullValue())));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:21,代码来源:StackConfigurationBeanDefinitionParserTest.java

示例11: beforeEachTestRuns

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
@Before
public void beforeEachTestRuns() {
	AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
	AmazonEC2 ec2Client = EnvironmentSetupForTests.createEC2Client();
	AmazonElasticLoadBalancing awsElbClient = EnvironmentSetupForTests.createELBClient();
	AmazonCloudFormation cfnClient = EnvironmentSetupForTests.createCFNClient();
	AmazonRDS awsRdsClient = EnvironmentSetupForTests.createRDSClient();

	CloudClient cloudClient = new CloudClient(ec2Client, new DefaultAwsRegionProviderChain());
	LoadBalancerClient elbClient = new LoadBalancerClient(awsElbClient);
	VpcRepository vpcRepository = new VpcRepository(cloudClient);

	CloudFormationClient cloudFormationClient = new CloudFormationClient(cfnClient);
	cloudRepository = new CloudRepository(cloudClient);
	ResourceRepository cfnRepository = new CfnRepository(cloudFormationClient, cloudRepository, "CfnAssist");
	
	elbRepository = new ELBRepository(elbClient, vpcRepository, cfnRepository);
	rdsClient = new RDSClient(awsRdsClient);
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:20,代码来源:TestPictureGeneration.java

示例12: createTemporarySimpleStack

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
public static StackNameAndId createTemporarySimpleStack(AmazonCloudFormation cfnClient, String vpcId, String arn) throws IOException {
	CreateStackRequest createStackRequest = new CreateStackRequest();
	createStackRequest.setStackName(TEMPORARY_STACK);
	File file = new File(FilesForTesting.SIMPLE_STACK);
	createStackRequest.setTemplateBody(FileUtils.readFileToString(file , Charset.defaultCharset()));
	Collection<Parameter> parameters = new LinkedList<>();
	parameters.add(createParam("env", EnvironmentSetupForTests.ENV));
	parameters.add(createParam("vpc", vpcId));
	if (!arn.isEmpty()) {
		Collection<String> notificationARNs = new LinkedList<>();
		notificationARNs.add(arn);
		logger.debug("Adding arn subscription "+ arn);
		createStackRequest.setNotificationARNs(notificationARNs);
	}
	createStackRequest.setParameters(parameters);
	CreateStackResult result = cfnClient.createStack(createStackRequest);
	return new StackNameAndId(TEMPORARY_STACK, result.getStackId());
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:19,代码来源:EnvironmentSetupForTests.java

示例13: amazonCloudFormationClient

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
@Bean
public AmazonCloudFormation amazonCloudFormationClient(final AWSCredentialsProvider awsCredentialsProvider,
    final ClientConfiguration awsClientConfig, final Region awsRegion) {
    return AmazonCloudFormationClientBuilder.standard()
        .withCredentials(awsCredentialsProvider)
        .withClientConfiguration(awsClientConfig)
        .withRegion(awsRegion.getName())
        .build();
}
 
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:10,代码来源:AwsConfig.java

示例14: configure

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
/**
 * Binds all the Amazon services used.
 */
@Override
protected void configure() {
    final Region region = Region.getRegion(Regions.fromName(regionName));
    bind(AmazonEC2.class).toInstance(createAmazonClientInstance(AmazonEC2Client.class, region));
    bind(AmazonCloudFormation.class).toInstance(createAmazonClientInstance(AmazonCloudFormationClient.class, region));
    bind(AmazonIdentityManagement.class).toInstance(createAmazonClientInstance(AmazonIdentityManagementClient.class, region));
    bind(AWSKMS.class).toInstance(createAmazonClientInstance(AWSKMSClient.class, region));
    bind(AmazonS3.class).toInstance(createAmazonClientInstance(AmazonS3Client.class, region));
    bind(AmazonAutoScaling.class).toInstance(createAmazonClientInstance(AmazonAutoScalingClient.class, region));
    bind(AWSSecurityTokenService.class).toInstance(createAmazonClientInstance(AWSSecurityTokenServiceClient.class, region));
    bind(AWSLambda.class).toInstance(createAmazonClientInstance(AWSLambdaClient.class, region));
    bind(AmazonSNS.class).toInstance(createAmazonClientInstance(AmazonSNSClient.class, region));
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:17,代码来源:CerberusModule.java

示例15: testSkip

import com.amazonaws.services.cloudformation.AmazonCloudFormation; //导入依赖的package包/类
@Test
  public void testSkip() {
    testConfig.cfSignalResourceConfig.setSkip(true);
//  purposefully null this to test for NPE
    testConfig.cfSignalResourceConfig.setStackName(null);

    AmazonCloudFormation amazonCloudFormation = mock(AmazonCloudFormation.class);

    new CfSignalResourceBundle(amazonCloudFormation).run(testConfig, environment);

    verifyZeroInteractions(amazonCloudFormation, lifecycleEnvironment);
    verify(testConfig).getCfSignalResourceConfig();
  }
 
开发者ID:heldeen,项目名称:cf-signal-resource-bundle,代码行数:14,代码来源:CfSignalResourceBundleTest.java


注:本文中的com.amazonaws.services.cloudformation.AmazonCloudFormation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。