Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request help: how to configure route without upstream (aws-lambda plugin) #2271

Open
kayx23 opened this issue Aug 1, 2024 · 5 comments
Open

Comments

@kayx23
Copy link
Member

kayx23 commented Aug 1, 2024

Issue description

An upstream is not required when using aws-lambda plugin. See:

With ingress controller, if you attempt to apply the following config:

apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: aws-lambda-route
spec:
  http:
    - name: aws-lambda-route
      match:
        paths:
          - /something
      plugins:
      - name: aws-lambda
        enable: true
        config:
          function_uri: https://xxx.com
          authorization:
            iam:
              accesskey: xxx
              secretkey: xxx
              aws_region: us-east-2
              service: lambda
          timeout: 30000
          ssl_verify: false

You get the a schema check error:

The ApisixRoute "aws-lambda-route" is invalid: 
* <nil>: Invalid value: "": "spec.http[0]" must validate at least one schema (anyOf)
* spec.http[0].backends: Required value

What I have also attempted is to set an upstreams:

apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: aws-lambda-route
spec:
  http:
    - name: aws-lambda-route
      match:
        paths:
          - /something
      upstreams:
      - name: https-upstream
      plugins:
      - name: aws-lambda
        enable: true
        config:
          function_uri: https://xxx.com
          authorization:
            iam:
              accesskey: xxx
              secretkey: xxx
              aws_region: us-east-2
              service: lambda
          timeout: 30000
          ssl_verify: false
---
apiVersion: apisix.apache.org/v2
kind: ApisixUpstream
metadata:
  name: https-upstream
spec:
  scheme: https
  loadbalancer:
    type: roundrobin

With this you do get around the schema check but you would see an empty ExternalNodes or Discovery configuration error in the ingress controller log:

2024-08-01T17:39:26+08:00	error	translation/apisix_route.go:243	failed to translate ApisixUpstream at Upstream[0]	{"error": "default/https-upstream has empty ExternalNodes or Discovery configuration", "apisix_upstream": "default/amazon-bedrock-upstream"}

So what should be the right way to configure aws-lambda on a route that does not require an upstream? Or is this scenario something ingress controller schema should accommodate for?

Note: aws-lambda plugin does not have test coverage in this repo as of now.

Environment

  • your apisix-ingress-controller version (output of apisix-ingress-controller version --long): 1.8.0
@Revolyssup
Copy link
Contributor

ginkgo.It("should be able to access third-party service", func() {
Refer to this test case

@Revolyssup
Copy link
Contributor

I see this plugin terminates the original request. So doesn't matter what the upstream is. Creating ApisixRoute creates an upstream automatically so it still requires backend field to be configured.
As a workaroud, you can configure an externalservice as the same URL and use that as backend. Though that upstream won't be used. But currently ingress controller doesn't support creating ApisixRoute with upstream.

@kayx23
Copy link
Member Author

kayx23 commented Aug 1, 2024

As a workaroud, you can configure an externalservice as the same URL and use that as backend.

Adopting this workaround for now and keeping this issue to track future actions (if any).

Copy link

This issue has been marked as stale due to 90 days of inactivity. It will be closed in 30 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Oct 31, 2024
Copy link

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

@kayx23 kayx23 reopened this Nov 30, 2024
@github-actions github-actions bot removed the stale label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants