There are more AWS SDK examples available in the AWS Doc SDK Examples
Use CreateKeyGroup
with an AWS SDK
The following code example shows how to use CreateKeyGroup
.
- Java
-
- SDK for Java 2.x
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. A key group requires at least one public key that is used to verify signed URLs or cookies.
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.services.cloudfront.CloudFrontClient; import java.util.UUID; public class CreateKeyGroup { private static final Logger logger = LoggerFactory.getLogger(CreateKeyGroup.class); public static String createKeyGroup(CloudFrontClient cloudFrontClient, String publicKeyId) { String keyGroupId = cloudFrontClient.createKeyGroup(b -> b.keyGroupConfig(c -> c .items(publicKeyId) .name("JavaKeyGroup" + UUID.randomUUID()))) .keyGroup().id(); logger.info("KeyGroup created with ID: [{}]", keyGroupId); return keyGroupId; } }
-
For API details, see CreateKeyGroup in AWS SDK for Java 2.x API Reference.
-
CreateInvalidation
CreatePublicKey