awssnssource

command
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

README

AWS SNS event source for Knative Eventing

This event source subscribes to messages from a AWS SNS topic and sends them as CloudEvents to an arbitrary event sink.

Each instance of the SNS source is backed by a Knative Service that exposes a unique public HTTP(S) endpoint. This endpoint is used to subscribe to the desired SNS topic on behalf of the user.

Contents

  1. Prerequisites
  2. Deployment to Kubernetes
  3. Running locally

Prerequisites

  • Register an AWS account
  • Create an Access Key in your AWS IAM dashboard.
  • Create a Standard SNS topic.

Deployment to Kubernetes

The AWS SNS event source can be deployed to Kubernetes in different manners:

  • As an AWSSNSSource object, to a cluster where the TriggerMesh AWS Sources Controller is running.
  • As a Knative ContainerSource, to any cluster running Knative Eventing.

ℹ The sample manifests below reference AWS credentials (Access Key) from a Kubernetes Secret object called awscreds. This Secret can be generated with the following command:

$ kubectl -n <my_namespace> create secret generic awscreds \
  --from-literal=aws_access_key_id=<my_key_id> \
  --from-literal=aws_secret_access_key=<my_secret_key>

Alternatively, credentials can be used as literal strings instead of references to Kubernetes Secrets by replacing valueFrom attributes with value inside API objects' manifests.

As a AWSSNSSource object

Copy the sample manifest from config/samples/awssnssource.yaml and replace the pre-filled spec attributes with the values corresponding to your AWS SNS topic. Then, create that AWSSNSSource object in your Kubernetes cluster:

$ kubectl -n <my_namespace> create -f my-awssnssource.yaml
As a ContainerSource object

Copy the sample manifest from config/samples/awssns-containersource.yaml and replace the pre-filled environment variables under env with the values corresponding to your AWS SNS topic. Then, create that ContainerSource object in your Kubernetes cluster:

$ kubectl -n <my_namespace> create -f my-awssns-containersource.yaml
As a Deployment object bound by a SinkBinding

Copy the sample manifest from config/samples/awssns-sinkbinding.yaml and replace the pre-filled environment variables under env with the values corresponding to your AWS SNS topic. Then, create the Deployment and SinkBinding objects in your Kubernetes cluster:

$ kubectl -n <my_namespace> create -f my-awssns-sinkbinding.yaml

Running locally

Running the event source on your local machine can be convenient for development purposes.

In the shell

Ensure the following environment variables are exported to your current shell's environment:

export ARN=<arn_of_my_sns_topic>
export PUBLIC_URL=<public_source_url>
export AWS_ACCESS_KEY_ID=<my_key_id>
export AWS_SECRET_ACCESS_KEY=<my_secret_key>
export NAME=my-awssnssource
export NAMESPACE=default
export K_SINK=http://<url_of_event_sink>
export K_LOGGING_CONFIG=''
export K_METRICS_CONFIG='{"domain":"triggermesh.io/sources", "component":"awssnssource", "configMap":{}}'

Then, run the event source with:

$ go run ./cmd/awssnssource
In a Docker container

Using one of TriggerMesh's release images:

$ docker run --rm \
  -e ARN=<arn_of_my_sns_topic> \
  -e PUBLIC_URL=<public_source_url> \
  -e AWS_ACCESS_KEY_ID=<my_key_id> \
  -e AWS_SECRET_ACCESS_KEY=<my_secret_key> \
  -e NAME=my-awssnssource \
  -e NAMESPACE=default \
  -e K_SINK=http://<url_of_event_sink> \
  -e K_LOGGING_CONFIG='' \
  -e K_METRICS_CONFIG='{"domain":"triggermesh.io/sources", "component":"awssnssource", "configMap":{}}' \
  gcr.io/triggermesh/awssnssource:latest

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL