AWS (Amazon Web Services) SDK for Delphi

AWS (Amazon Web Services) SDK for Delphi

AWS (Amazon Web Services) SDK for Delphi

A new relevant open source project is now available for Delphi community on GitHub: AWS SDK for Delphi.

The AWS SDK for Delphi enables Delphi developers to easily work with Amazon Web Services and build scalable solutions with Amazon SES, Amazon SQS, and more. It is a non-official SDK based on the official AWS SDK for .NET. A few selected popular services are added, and more will be added very soon.

About Amazon Web Services
From Amazon Web Services (AWS) web site itself: “AWS is the world’s most comprehensive and broadly adopted cloud platform, offering over 200 fully featured services from data centers globally. Millions of customers—including the fastest-growing startups, largest enterprises, and leading government agencies—are using AWS to lower costs, become more agile, and innovate faster.

AWS includes useful services for developers to send notifications (Amazon SNS), send and receive e-mails (Amazon SES), use queue systems (Amazon SQS), several database systems (Amazon RDS, Amazon DynamoDB), memory cache (Amazon ElastiCache), content delivery network (Amazon CloudFront), storage (Amazon S3 and Amazon Glacier), and many more!.

Using the SDK
Each Amazon web service has its own package and unit name scheme, which is AWS.dproj and AWS..*.pas, respectively. For example, for Amazon SQS (Simple Queue Service), the package name is AWSSQS.dproj and unit name is AWS.SQS.pas (and all other units in the package follow same pattern, like AWS.SQS.Client.pas or AWS.SQS.ClientIntf.pas.

Most types you need will be in the main unit, which for example is AWS.SQS. So that’s the only unit you will need to use most of the functions. From there you can access all the available API operations. Each operation method receives a request interface and returns a response interface.

The following examples receive a message from an SQS queue and output the id and body of each message received:

// 1. Use main unit
uses AWS.SQS;

procedure WriteMessageIds(const QueueUrl: string);
Client: IAmazonSQS;
Response: IReceiveMessageResponse;
Request: IReceiveMessageRequest;
Msg: AWS.SQS.TMessage;
// 2. Instantiate client interface
Client := TAmazonSQSClient.Create;

// 3. Create and fill the request
Request := TReceiveMessageRequest.Create;
Request.QueueUrl := QueueUrl;

// 4. Call operation method passing the request to receive the response;
Response := Client.ReceiveMessage(Request);

// 5. Process the response
for Msg in Response.Messages do

The following example sends an e-mail to the specified address using the specified subject and message:

// 1. Use main unit
uses AWS.SES;

procedure SendEmail(const Recipient, Subject, Content: string);
Client: IAmazonSimpleEmailService;
Request: ISendEmailRequest;
Response: ISendEmailResponse;
// 2. Instantiate client interface
Client := TAmazonSimpleEmailServiceClient.Create;

// 3. Create and fill the request
Request := TSendEmailRequest.Create;
Request.Source := SenderEmail;
Request.Destination := TDestination.Create;
Request.Message := TMessage.Create(

// 4. Call operation method passing the request to receive the response;
Response := Client.SendEmail(Request);

// 5. Process the response

The AWS SDK for Delphi searches for credentials in a certain order and uses the first available set for the current application.

Credential search order
Credentials that are explicitly set on the AWS service client, as described in below.
A credentials profile with the name specified by a value in TAWSConfigs.AWSProfileName.
A credentials profile with the name specified by the AWS_PROFILE environment variable.
The [default] credentials profile.
Passing access and secret keys directly to client
You can simply pass the Access key ID and Secret key directly in the client constructor:

Client := TAmazonSQSClient.Create(myAccessKey, mySecretKey);

Although using credentials profile is recommended as it’s easier to manage and also compatible with AWS Command Line Interface.

Go here:
  • 202