AWS Blog

AWS Support API Update – Attachment Creation and Lightweight Monitoring

The AWS Support API provides you with a programmatic access to your support cases and to the AWS Trusted Advisor. Today we are extending the API in order to give you more control over the cases that you create and a new, lightweight way to access information about your cases. The examples in this post make use of the AWS SDK for Java.

Creating Attachments for Support Cases
When you create a support case, you may want to include additional information along with the case. Perhaps you want to attach some sample code, a protocol trace, or some screen shots. With today’s release you can now create, manage, and use attachments programmatically.

My colleague Kapil Sharma provided me with some sample Java code to show you how to do this. Let’s walk through it. The first step is to create an Attachment from a file (File1 in this case):

Attachment attachment = new Attachment;
Attachment.setData(ByteBuffer.wrap(File.readAllBytes(FileSystems.getDefault().getPath("", "File1"))));

Then you create a List of the attachments for the case:

             attachmentSet = New ArrayList 
              (); attachmentSet.add(attachment); 

And upload the attachments:

AddAttachmentsToSetRequest addAttachmentsToSetRequest = new AddAttachmentsToSetRequest();
AddAttachmentsToSetResult addAttachmentsToSetResult = client.addAttachmentsToSet(addAttachmentsToSetRequest);

With the attachment or attachments uploaded, you next need to get an Id for the set:

String attachmentSetId = addAttachmentsToSetResult.getAttachmentSetId();

And then you are ready to create the actual support case:

CreateCaseRequest request = new CreateCaseRequest()

CreateCaseResult result = client.createCase(request);

Once you have created a support case or two, you probably want to check on their status. The describeCases function lets you do just that. In the past, this function returned a detailed response that included up to 15 MB of attachments. With today’s enhancement, you can now ask for a lightweight response that does not include any attachments. If you are calling describeCases to check for changes in status, you can now do this in a more efficient fashion.

DescribeCaseRequest request = new DescribeCaseRequest();


To learn more about creating and managing cases programmatically, take a look at Programming the Life of an AWS Support Case.

Available Now
The new functionality described in this post is available now and you can start using them today! The SDK for PHP, SDK for .NET, SDK for Ruby, SDK for Java, SDK for JavaScript in the Browser, and the AWS Command Line Interface (CLI) have been updated.