System.out.println("Streaming distribution " + (i + 1) + ": " + streamingDistributions[i]);
}
// Create a new streaming distribution
String streamingBucket = "jets3t-streaming.s3.amazonaws.com";
StreamingDistribution newStreamingDistribution = cloudFrontService.createStreamingDistribution(
new S3Origin(streamingBucket),
"" + System.currentTimeMillis(), // Caller reference - a unique string value
null, // CNAME aliases for distribution
"Test streaming distribution", // Comment
true, // Distribution is enabled?
null // Logging status
);
System.out.println("New Streaming Distribution: " + newStreamingDistribution);
// Streaming distributions can be made private just like standard non-streaming
// distributions. Create a new private streaming distribution for which signed
// URLs are *not* required
StreamingDistribution newPrivateStreamingDistribution =
cloudFrontService.createStreamingDistribution(
new S3Origin(streamingBucket, originAccessIdentityId),
"" + System.currentTimeMillis(), // Caller reference - a unique string value
new String[] {}, // CNAME aliases for distribution
"New private streaming distribution -- URL signing not required", // Comment
true, // Distribution is enabled?
null, // Logging status
true, // URLs self-signing enabled
null // No other AWS users can sign URLs
);
System.out.println("New Private Streaming Distribution: " + newPrivateStreamingDistribution);
// The ID of the streaming distribution we will use for testing
String testStreamingDistributionId = newStreamingDistribution.getId();
// List information about a streaming distribution
StreamingDistribution streamingDistribution =
cloudFrontService.getStreamingDistributionInfo(testStreamingDistributionId);
System.out.println("Streaming Distribution: " + streamingDistribution);
// List configuration information about a streaming distribution
StreamingDistributionConfig streamingDistributionConfig =
cloudFrontService.getStreamingDistributionConfig(testStreamingDistributionId);
System.out.println("Streaming Distribution Config: " + streamingDistributionConfig);
// Update a streaming distribution's configuration to add an extra CNAME alias
// and to enable access logging -- logs will be written to '
StreamingDistributionConfig updatedStreamingDistributionConfig =
cloudFrontService.updateStreamingDistributionConfig(
testStreamingDistributionId,
null, // origin -- null for no changes
new String[] {"cname.jets3t-streaming.com"}, // CNAME aliases for distribution
"Updated this streaming distribution", // Comment
true, // Distribution enabled?
new LoggingStatus("jets3t-streaming-logs.s3.amazonaws.com", "sdlog-") // Logging
);
System.out.println("Updated Streaming Distribution Config: "
+ updatedStreamingDistributionConfig);
// Disable a streaming distribution, e.g. so that it may be deleted.
// The CloudFront service may take some time to disable and deploy the distribution.
StreamingDistributionConfig disabledStreamingDistributionConfig =
cloudFrontService.updateStreamingDistributionConfig(
testStreamingDistributionId,
null, // origin -- null for no changes
new String[] {}, "Deleting distribution",
false, // Distribution enabled?
null // Logging status
);
System.out.println("Disabled Streaming Distribution Config: "
+ disabledStreamingDistributionConfig);
// Check whether a streaming distribution is deployed
StreamingDistribution streamingDistributionCheck =
cloudFrontService.getStreamingDistributionInfo(testStreamingDistributionId);
System.out.println("Streaming Distribution is deployed? "
+ streamingDistributionCheck.isDeployed());
// Convenience method to disable a streaming distribution prior to deletion
cloudFrontService.disableStreamingDistributionForDeletion(testStreamingDistributionId);
// Delete a streaming distribution (the distribution must be disabled and deployed first)