You can use various Amazon web services in FileMaker using our CURL functions in MBS FileMaker Plugin. You need to build the URL and her payload and either pass data in the URL or as POST data, depending on the service. You may easily translate an existing sample call on the AWS documentation for the call you like to make and translate that to setting the various options.
The special thing for the AWS requests is the signature to properly encode and hash the credentials. For years we have CURL.SetupAWS function to help signing the requests. But since CURL got the AWSSigV4 Option, we can use our CURL.SetOptionAWSSigV4 function to sign the request on the fly. There we pass the names of the provider, region and service, so CURL can include this in the signature.
To try this, let us use the Amazon Simple Notification Service to send a text message to a mobile phone. For this we need a phone number and since people like to use brackets and spaces, we filter the text to only have the digits and the plus symbol for the country.
Here is the sample script:
# 1. Set AWS and SNS Configuration
Set Variable [ $PhoneNumber ; Value: Filter ( CURL Test::phoneNumber ; "+0123456789" ) ]
Set Variable [ $Message ; Value: CURL Test::message ]
Set Variable [ $AWSRegion ; Value: CURL Test::region ]
#
# 2. Set AWS SNS Endpoint and Host
Set Variable [ $Host ; Value: "sns." & $AWSRegion & ".amazonaws.com" ]
Set Variable [ $URL ; Value: "https://" & $Host ]
#
# 3. Create the Payload
Set Variable [ $Payload ; Value: "Action=Publish&PhoneNumber=" & URLEncode ( $PhoneNumber) & "&Message=" & URLEncode ( $Message ) ]
Set Field [ CURL Test::Input ; $Payload ]
#
# send via MBS Plugin using CURL functions
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionURL"; $curl; $URL) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionPostFields"; $curl; $Payload) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionAWSSigV4"; $curl; "aws:amz:us-east-2:sns") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUserName"; $curl; CURL Test::AWS_access_key) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionPassword"; $curl; CURL Test::AWS_secret_key) ]
Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ]
Set Field [ CURL Test::Result ; MBS("CURL.GetResultAsText"; $curl; "utf-8") ]
Set Field [ CURL Test::debug ; MBS("CURL.GetDebugMessages"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]
Exit Script [ Text Result: ]
We'll include the sample database for the next pre-release. Sending the SMS works just fine and you could create an AWS account and integrate this into a solution if you see a need for this.