PHP 5.6 way to send AWS SNS topic message
This is an example PHP 5.6 script to send AWS SNS topic message.
The architecture and assumption are as follow:
Architecture:
SNS (FIFO) -> SQS(FIFO) -> Lambda
Only FIFO SNS can connect to FIFO SQS. Standard SNS cannot publish to FIFO SQS.
Assumption:
This script is executed in an EC2 instance.
Assigned an AWS role to send SNS message.
Because of above, supposed that there is no need to use
Credentialwhen creatingSnsClientobject.As the OS and PHP in this EC2 is old, the
curlis already outdated. So it sethttptofalseto bypass SSL verification. Reference here.The
$messagepart is designed for sending email for different vendor. In other words, it would vary in different case.Since SNS and SQS are FIFO,
MessageGroupIdmust be set. It can be any random string, which is used to group message together for sending purpose.
Comments