Verifying TriggerMesh SAWS

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 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

  • Have a namespace where you want to deploy Knative services. This namespace will be referred as ${WORKLOAD_NAMESPACE} in this tutorial. See step 1 of Verifying Your Installation for more information.

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:

    kubectl -n ${WORKLOAD_NAMESPACE} create secret generic awscreds \
    --from-literal=aws_access_key_id=${AWS_ACCESS_KEY_ID} \
    --from-literal=aws_secret_access_key=${AWS_SECRET_ACCESS_KEY}
    

    Where:

    • AWS_ACCESS_KEY_ID is the AWS access key ID for your AWS service account.
    • AWS_SECRET_ACCESS_KEY is your AWS access key for your AWS service account.
  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. Patch the awscodecommitsource-adapter service account to pull images from the private registry using the tap-registry secret, created during the TAP installation. Note that the awscodecommitsource-adapter service account was created on the previous step during the creation of AWSCodeCommitSource.

    kubectl patch serviceaccount -n ${WORKLOAD_NAMESPACE} awscodecommitsource-adapter -p '{"imagePullSecrets": [{"name": "tap-registry"}]}'
    

    Note: It may be necessary to delete the current awscodecommitsource-source Pod so a new pod is created with the new imagePullSecrets.

  7. Create an event by pushing a commit to your CodeCommit repository.

  8. 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