In my last post, I described how an API Gateway can interact with Kinesis Firehose. This time I used the same approach to connect the API Gateway to SNS.
With this, I could simplify the access pattern for my application by exposing an internal HTTP Endpoint which then routes all requests to a corresponding SNS Topic.
So here an overview picture of what I am about to build.
The first part of the CloudFormation template is the definition of the API Gateway.
As a prerequisite, I needed a role which would allow the API Gateway to actually write into the SNS Topic.
Now the difficult part is getting the method definition right. I’m using a GET method since it is simpler to call this from any browser/CLI/script environment.
The parameter mapping for SNS is derived from the AWS API documentation.
To also deploy this API within the same CloudFormation operation, I added a deployment instruction.
Now I can send notifications to any registered topic through the following curl command.
Here is the overall CloudFormation template: