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


Java AmazonCloudFormationClient类代码示例

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


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

示例1: CloudFrontLogEventHandler

import com.amazonaws.services.cloudformation.AmazonCloudFormationClient; //导入依赖的package包/类
public CloudFrontLogEventHandler(AmazonCloudFormationClient cloudFormationClient,
                                 AmazonS3Client amazonS3Client,
                                 AWSWAF awsWaf) {

    cloudFormationClient.setRegion(Region.getRegion(Regions.US_WEST_2));
    this.amazonS3Client = amazonS3Client;
    objectMapper = new ObjectMapper();
    objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);

    // New processors would need there own ip sets as there is a hard limit of 1000 ips and the
    // RateLimitingProcessor truncates the set and removes any ips from the set that it doesn't know about
    // see CloudFormationDefinedParams
    logEventProcessors.add(new RateLimitingProcessor(objectMapper, awsWaf, amazonS3Client));
    logEventProcessors.add(new GoogleAnalyticsKPIProcessor());
    logEventProcessors.add(new TlsVerificationProcessor());
}
 
开发者ID:Nike-Inc,项目名称:cerberus-serverless-components,代码行数:17,代码来源:CloudFrontLogEventHandler.java

示例2: CreateCloudFrontSecurityGroupUpdaterLambdaOperation

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

示例3: CfSignalResourceBundle

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

示例4: DefaultListableBeanFactory

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

import com.amazonaws.services.cloudformation.AmazonCloudFormationClient; //导入依赖的package包/类
private List<CloudResource> getCloudResources(AuthenticatedContext ac, CloudStack stack, String cFStackName, AmazonCloudFormationClient client,
        AmazonEC2Client amazonEC2Client, AmazonAutoScalingClient amazonASClient, boolean mapPublicIpOnLaunch) {
    List<CloudResource> cloudResources = new ArrayList<>();
    AmazonCloudFormationClient cloudFormationClient = awsClient.createCloudFormationClient(new AwsCredentialView(ac.getCloudCredential()),
            ac.getCloudContext().getLocation().getRegion().value());
    scheduleStatusChecks(stack, ac, cloudFormationClient);
    suspendAutoScaling(ac, stack);
    if (mapPublicIpOnLaunch) {
        Map<String, String> eipAllocationIds = getElasticIpAllocationIds(cFStackName, client);
        List<Group> gateways = getGatewayGroups(stack.getGroups());
        for (Group gateway : gateways) {
            List<String> eips = getEipsForGatewayGroup(eipAllocationIds, gateway);
            List<String> instanceIds = getInstancesForGroup(ac, amazonASClient, client, gateway);
            associateElasticIpsToInstances(amazonEC2Client, eips, instanceIds);
        }
    }
    return cloudResources;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:19,代码来源:AwsResourceConnector.java

示例6: scheduleStatusChecks

import com.amazonaws.services.cloudformation.AmazonCloudFormationClient; //导入依赖的package包/类
private void scheduleStatusChecks(CloudStack stack, AuthenticatedContext ac, AmazonCloudFormationClient cloudFormationClient) {
    for (Group group : stack.getGroups()) {
        String asGroupName = cfStackUtil.getAutoscalingGroupName(ac, cloudFormationClient, group.getName());
        LOGGER.info("Polling Auto Scaling group until new instances are ready. [stack: {}, asGroup: {}]", ac.getCloudContext().getId(),
                asGroupName);
        PollTask<Boolean> task = awsPollTaskFactory.newASGroupStatusCheckerTask(ac, asGroupName, group.getInstancesSize(), awsClient, cfStackUtil);
        try {
            Boolean statePollerResult = task.call();
            if (!task.completed(statePollerResult)) {
                syncPollingScheduler.schedule(task);
            }
        } catch (Exception e) {
            throw new CloudConnectorException(e.getMessage(), e);
        }
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:17,代码来源:AwsResourceConnector.java

示例7: collect

import com.amazonaws.services.cloudformation.AmazonCloudFormationClient; //导入依赖的package包/类
@Override
public List<CloudVmMetaDataStatus> collect(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms) {
    List<CloudVmMetaDataStatus> cloudVmMetaDataStatuses = new ArrayList<>();
    try {
        String region = ac.getCloudContext().getLocation().getRegion().value();
        AmazonCloudFormationClient amazonCFClient =
                awsClient.createCloudFormationClient(new AwsCredentialView(ac.getCloudCredential()), region);
        AmazonAutoScalingClient amazonASClient =
                awsClient.createAutoScalingClient(new AwsCredentialView(ac.getCloudCredential()), region);
        AmazonEC2Client amazonEC2Client =
                awsClient.createAccess(new AwsCredentialView(ac.getCloudCredential()), region);

        //contains all instances
        ListMultimap<String, CloudInstance> groupByInstanceGroup = groupByInstanceGroup(vms);

        for (String key : groupByInstanceGroup.keySet()) {
            List<CloudInstance> cloudInstances = groupByInstanceGroup.get(key);
            cloudVmMetaDataStatuses.addAll(collectGroupMetaData(ac, amazonASClient, amazonEC2Client, amazonCFClient, key, cloudInstances));
        }

        return cloudVmMetaDataStatuses;
    } catch (RuntimeException e) {
        throw new CloudConnectorException(e.getMessage(), e);
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:26,代码来源:AwsMetadataCollector.java

示例8: getOutputForRequest

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

示例9: configure

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

示例10: getCloudFormationClient

import com.amazonaws.services.cloudformation.AmazonCloudFormationClient; //导入依赖的package包/类
protected AmazonCloudFormationClient getCloudFormationClient() {
    if (null != cloudformationClient) {
        return cloudformationClient;
    }

    return cloudformationClient = new AmazonCloudFormationClient(getAWSCredentialsProvideChain()).withRegion(Region.getRegion(Regions.fromName(deployment.getRegion())));
}
 
开发者ID:lambadaframework,项目名称:lambadaframework,代码行数:8,代码来源:Cloudformation.java

示例11: parseInternal_withCustomRegion_shouldConfigureDefaultClientWithCustomRegion

import com.amazonaws.services.cloudformation.AmazonCloudFormationClient; //导入依赖的package包/类
@Test
public void parseInternal_withCustomRegion_shouldConfigureDefaultClientWithCustomRegion() throws Exception {
    //Arrange
    DefaultListableBeanFactory registry = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);

    //Act
    reader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-custom-region.xml", getClass()));

    // Assert
    AmazonCloudFormationClient amazonCloudFormation = registry.getBean(AmazonCloudFormationClient.class);
    assertEquals("https://" + Region.getRegion(Regions.SA_EAST_1).getServiceEndpoint("cloudformation"), ReflectionTestUtils.getField(amazonCloudFormation, "endpoint").toString());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:14,代码来源:StackConfigurationBeanDefinitionParserTest.java

示例12: parseInternal_withCustomRegionProvider_shouldConfigureDefaultClientWithCustomRegionReturnedByProvider

import com.amazonaws.services.cloudformation.AmazonCloudFormationClient; //导入依赖的package包/类
@Test
public void parseInternal_withCustomRegionProvider_shouldConfigureDefaultClientWithCustomRegionReturnedByProvider() throws Exception {
    //Arrange
    DefaultListableBeanFactory registry = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);

    //Act
    reader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-custom-region-provider.xml", getClass()));

    // Assert
    AmazonCloudFormationClient amazonCloudFormation = registry.getBean(AmazonCloudFormationClient.class);
    assertEquals("https://" + Region.getRegion(Regions.AP_SOUTHEAST_2).getServiceEndpoint("cloudformation"), ReflectionTestUtils.getField(amazonCloudFormation, "endpoint").toString());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:14,代码来源:StackConfigurationBeanDefinitionParserTest.java

示例13: execute

import com.amazonaws.services.cloudformation.AmazonCloudFormationClient; //导入依赖的package包/类
public void execute() {
    checkParams();
    AmazonCloudFormationClient client = getOrCreateClient(AmazonCloudFormationClient.class);
    UpdateStackRequest request = new UpdateStackRequest()
            .withStackName(stackName).withStackPolicyBody(stackPolicyBody)
            .withStackPolicyURL(stackPolicyURL)
            .withTemplateBody(templateBody).withTemplateURL(templateURL)
            .withStackPolicyDuringUpdateBody(stackPolicyDuringUpdateBody)
            .withStackPolicyDuringUpdateURL(stackPolicyDuringUpdateURL)
            .withUsePreviousTemplate(usePreviousTemplate);

    if (capabilities.size() > 0) {
        request.setCapabilities(capabilities);
    }
    if (parameters.size() > 0) {
        request.setParameters(parameters);
    }
    if (notificationArns.size() > 0) {
        request.setNotificationARNs(notificationArns);
    }

    try {
        client.updateStack(request);
        System.out.println("Update stack " + stackName
                + " request submitted.");
    } catch (Exception e) {
        throw new BuildException("Could not update stack: "
                + e.getMessage(), e);
    }
}
 
开发者ID:awslabs,项目名称:aws-ant-tasks,代码行数:31,代码来源:UpdateStackTask.java

示例14: execute

import com.amazonaws.services.cloudformation.AmazonCloudFormationClient; //导入依赖的package包/类
public void execute() {
    checkParams();
    AmazonCloudFormationClient client = getOrCreateClient(AmazonCloudFormationClient.class);
    CreateStackRequest createStackRequest = new CreateStackRequest()
            .withDisableRollback(disableRollback).withOnFailure(onFailure)
            .withStackName(stackName).withStackPolicyBody(stackPolicyBody)
            .withStackPolicyURL(stackPolicyURL)
            .withTemplateBody(templateBody).withTemplateURL(templateURL)
            .withTimeoutInMinutes(timeoutInMinutes);

    if (capabilities.size() > 0) {
        createStackRequest.setCapabilities(capabilities);
    }
    if (parameters.size() > 0) {
        createStackRequest.setParameters(parameters);
    }
    if (tags.size() > 0) {
        createStackRequest.setTags(tags);
    }
    try {
        client.createStack(createStackRequest);
        System.out.println("Create stack " + stackName
                + " request submitted.");
        if(waitForCreation) {
            WaitForStackToReachStateTask.waitForCloudFormationStackToReachStatus(client, stackName, CREATE_COMPLETE);
        }
    } catch (Exception e) {
        throw new BuildException(
                "Could not create stack " + e.getMessage(), e);
    }
}
 
开发者ID:awslabs,项目名称:aws-ant-tasks,代码行数:32,代码来源:CreateStackTask.java

示例15: execute

import com.amazonaws.services.cloudformation.AmazonCloudFormationClient; //导入依赖的package包/类
public void execute() {
    checkParams();
    AmazonCloudFormationClient client = getOrCreateClient(AmazonCloudFormationClient.class);
    SetStackPolicyRequest setStackPolicyRequest = new SetStackPolicyRequest()
            .withStackName(stackName).withStackPolicyBody(stackPolicyBody)
            .withStackPolicyURL(stackPolicyURL);
    try {
        client.setStackPolicy(setStackPolicyRequest);
        System.out.println("Successfully set stack policy");
    } catch (Exception e) {
        throw new BuildException("Could not set the stack policy "
                + e.getMessage(), e);
    }
}
 
开发者ID:awslabs,项目名称:aws-ant-tasks,代码行数:15,代码来源:SetStackPolicyTask.java


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