This topic describes how to verify that TriggerMesh Sources for Amazon Web Services (SAWS) was installed successfully.

TriggerMesh SAWS allows you to consume events from your AWS services and send them to workloads running in your cluster.

Cloud Native Runtimes for Tanzu includes an installation of the Triggermesh SAWS controller and CRDs. You can find the controller in the triggermesh namespace.

For general information about TriggerMesh SAWS, see aws-event-sources in GitHub.

The procedure below shows you how to test TriggerMesh SAWS using the example of an event source for Amazon CodeCommit. If you want to test using a different AWS service, see samples in GitHub. The basic steps are the same, regardless of the AWS service you choose: create a broker, trigger, and consumer and then test.

Prerequisites

Before you verify TriggerMesh SAWS with AWS CodeCommit, you must have:

  • An AWS service account

  • An AWS CodeCommit repository with push and pull access

Verify TriggerMesh SAWS

To verify TriggerMesh SAWS with AWS CodeCommit:

  1. Create a broker:

    kubectl apply -f - << EOF
    apiVersion: eventing.knative.dev/v1
    kind: Broker
    metadata:
      name: broker
      namespace: ${WORKLOAD_NAMESPACE}
    EOF
    
  2. Create a trigger:

    kubectl apply -f - << EOF
    ---
    apiVersion: eventing.knative.dev/v1
    kind: Trigger
    metadata:
      name: trigger
      namespace: ${WORKLOAD_NAMESPACE}
    spec:
      broker: broker
      subscriber:
        ref:
         apiVersion: serving.knative.dev/v1
         kind: Service
         name: consumer
         namespace: ${WORKLOAD_NAMESPACE}
    EOF
    
  3. Create a consumer:

    kubectl apply -f - << EOF
    ---
    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      name: consumer
      namespace: ${WORKLOAD_NAMESPACE}
    spec:
      template:
        spec:
          containers:
            - image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display
    EOF
    
  4. Add an AWS service account secret:

    Note: Kubernetes uses base64 encoding to store secrets. Convert your AWS keys to base64 before proceeding. For more information about base64 encoding, see Distribute Credentials Securely Using Secrets in the Kubernetes documentation.

    kubectl apply -f - << EOF
    apiVersion: v1
    data:
      aws_access_key_id: ID-BASE64
      aws_secret_access_key: KEY-BASE64
    kind: Secret
    metadata:
      name: awscreds
      namespace: ${WORKLOAD_NAMESPACE}
    type: Opaque
    EOF
    

    Where:

    • ID-BASE64 is the AWS access key for your AWS service account encoded in base64.
    • KEY-BASE64 is your AWS access key for your AWS service account encoded in base64.
  5. Create the AWSCodeCommitSource:

    kubectl apply -f - << EOF
    apiVersion: sources.triggermesh.io/v1alpha1
    kind: AWSCodeCommitSource
    metadata:
      name: source
      namespace: ${WORKLOAD_NAMESPACE}
    spec:
      arn: ARN
      branch: BRANCH    
    
      eventTypes:
        - push
        - pull_request    
    
      credentials:
        accessKeyID:
          valueFromSecret:
            name: awscreds
            key: aws_access_key_id
        secretAccessKey:
          valueFromSecret:
            name: awscreds
            key: aws_secret_access_key    
    
      sink:
        ref:
          apiVersion: eventing.knative.dev/v1
          kind: Broker
          name: broker
          namespace: ${WORKLOAD_NAMESPACE}
    EOF
    

    Where:

    • ARN is Amazon Resource Name (ARN) of your CodeCommit repository. For example, arn:aws:codecommit:eu-central-1:123456789012:triggermeshtest.
    • BRANCH is the branch of your CodeCommit repository that you want the trigger to watch. For example, main.
  6. Create an event by pushing a commit to your CodeCommit repository.

  7. Watch the consumer logs to see that the event appears after a minute:

    kubectl logs -l serving.knative.dev/service=consumer -c user-container -n ${WORKLOAD_NAMESPACE} --since=10m --tail=50
    
check-circle-line exclamation-circle-line close-line
Scroll to top icon