admin管理员组

文章数量:1289879

Im trying to write the JAVA code to get the cloud front distribution details using AWS JAVA SDK 1.x

below is the code snippet

public static void main(String[] args) {
        // TODO Auto-generated method stub
  final AmazonCloudFront cf = AmazonCloudFrontClientBuilder.standard().withRegion("us-east-1").build();
          GetDistributionRequest rq = new GetDistributionRequest();
           System.out.println( cf.getDistribution(rq).getDistribution());
  }

getting below exception

20:48:07.002 [main] DEBUG com.amazonaws.AmazonWebServiceClient - Internal logging successfully configured to commons logger: true
20:48:07.347 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.EnvironmentVariableCsmConfigurationProvider@5a85c92: Unable to load Client Side Monitoring configurations from environment variables!
20:48:07.347 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.SystemPropertyCsmConfigurationProvider@32811494: Unable to load Client Side Monitoring configurations from system properties variables!
20:48:07.347 [java-sdk-http-connection-reaper] DEBUG .apache.http.impl.conn.PoolingHttpClientConnectionManager - Closing connections idle longer than 60000 MILLISECONDS
20:48:07.349 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.ProfileCsmConfigurationProvider@4795ded0: The 'default' profile does not define all the required properties!
20:48:07.528 [main] DEBUG com.amazonaws.metrics.AwsSdkMetrics - Admin mbean registered under com.amazonaws.management:type=AwsSdkMetrics
Exception in thread "main" java.lang.IllegalArgumentException: Id cannot be null
    at com.amazonaws.util.ValidationUtils.assertNotNull(ValidationUtils.java:37)
    at com.amazonaws.util.ValidationUtils.assertStringNotEmpty(ValidationUtils.java:87)
    at com.amazonaws.transform.PathMarshallers$NonGreedyPathMarshaller.marshall(PathMarshallers.java:75)
    at com.amazonaws.services.cloudfront.model.transform.GetDistributionRequestMarshaller.marshall(GetDistributionRequestMarshaller.java:43)
    at com.amazonaws.services.cloudfront.AmazonCloudFrontClient.executeGetDistribution(AmazonCloudFrontClient.java:4944)
    at com.amazonaws.services.cloudfront.AmazonCloudFrontClient.getDistribution(AmazonCloudFrontClient.java:4929)
    at oe.kubeapi.cloudcontroller.swagger.swaggerui.TestName1.main(TestName1.java:23)

what Im not able to understand is which Id code is looking for?

My findings:

  1. There is no any AWS authentication issue. I confirmed this because S3 AWS SDK works fine.

  2. I referred many blogs and AWS docs, havent found any sample code for 1.x

below is the pom.xml snippet

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-cloudfront</artifactId>
    <version>1.12.781</version>
</dependency>

Environment details:

JAVA: 17

not sure what is missing.

本文标签: amazon web servicesHow to get the cloud front distribution using AWS JAVA SDKStack Overflow