Java examples for AWS:Glacier
amazon glacier Vault Creator
import java.io.IOException; import com.amazonaws.ClientConfiguration; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.PropertiesCredentials; import com.amazonaws.services.glacier.AmazonGlacierClient; import com.amazonaws.services.glacier.model.CreateVaultRequest; import com.amazonaws.services.glacier.model.SetVaultNotificationsRequest; import com.amazonaws.services.glacier.model.VaultNotificationConfig; public class VaultCreator { public static String vaultName = "GLACIER_TEST"; public static String snsTopicArn = "ARN OF SNS TOPIC"; public static void main(String[] args) throws IOException { ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setProxyHost("xx.xx.xx.xx"); clientConfiguration.setProxyPort(0); AWSCredentials credentials = new PropertiesCredentials( VaultCreator.class .getResourceAsStream("AwsCredentials.properties")); AmazonGlacierClient client = new AmazonGlacierClient(credentials, clientConfiguration);/*from w w w. j a v a 2 s . c o m*/ client.setEndpoint("https://glacier.ap-northeast-1.amazonaws.com/"); try { CreateVaultRequest createVaultRequest = new CreateVaultRequest() .withVaultName(vaultName); client.createVault(createVaultRequest); VaultNotificationConfig vaultNotificationConfig = new VaultNotificationConfig() .withSNSTopic(snsTopicArn).withEvents( "ArchiveRetrievalCompleted", "InventoryRetrievalCompleted"); SetVaultNotificationsRequest setVaultNotificationsRequest = new SetVaultNotificationsRequest() .withVaultName(vaultName).withVaultNotificationConfig( vaultNotificationConfig); client.setVaultNotifications(setVaultNotificationsRequest); } catch (Exception e) { e.printStackTrace(); } } }