Giter VIP home page Giter VIP logo

Comments (5)

jamesls avatar jamesls commented on May 12, 2024

I think this is now fixable. I believe API gateway has an option to not forward things that don't explicitly map to a resource.

from chalice.

jamesls avatar jamesls commented on May 12, 2024

Actually, it doesn't look like this is possible based on this forums post.

Going to have to close this as "cant-fix" for now. I will keep an eye out on this though. If API gateway ever adds an option to configure this, I'd like to expose this in chalice.

from chalice.

grutty avatar grutty commented on May 12, 2024

Hi, I used Chalice to deploy a Lambda function and I'm struggling to resolve the error message referenced by @garnaat .

HTTP/1.1 403 Forbidden
Connection: keep-alive
Content-Length: 42
Content-Type: application/json
Date: Wed, 17 Jun 2020 00:17:48 GMT
Via: 1.1 61bc723adb3b1884ed759711e84e13a9.cloudfront.net (CloudFront)
X-Amz-Cf-Id: 7VGHBcaOaG6FtY7zG-hBzJZ-IOgtbAakt95iF9CpD7ElUAWnvenXQA==
X-Amz-Cf-Pop: SEA19-C2
X-Cache: Error from cloudfront
x-amz-apigw-id: OPwe_ErKvHcF5ZA=
x-amzn-ErrorType: MissingAuthenticationTokenException
x-amzn-RequestId: c68ec83f-e660-4737-b57f-3e633546abc4

{
    "message": "Missing Authentication Token"
}

When I test via AWS CLI I get the above error. When I make the request using Insomnia I get a 500.


< HTTP/2 500 
< content-type: application/json
< content-length: 77
< date: Wed, 17 Jun 2020 03:14:34 GMT
< x-amzn-requestid: 8294d263-ff41-4936-bc6a-f50351b8ec63
< x-amz-apigw-id: OQKX9ETRPHcFmNg=
< x-amzn-trace-id: Root=1-5ee98a99-a7101a206bc0983cea761640;Sampled=0
< x-cache: Error from cloudfront
< via: 1.1 4f3feb5c4393987d42d1971d404d7cea.cloudfront.net (CloudFront)
< x-amz-cf-pop: SEA19-C2
< x-amz-cf-id: xRFOhkm-s2nwSjjJhLjQM83dayeD62BjQIA1RH11OjROPjjunZY6DA==

I can confirm I'm not requesting an unknown resource and that the IAM profile configured using the CLI has sufficient privileges. Is there any documentaiton you can point me to for troubleshooting this? All the docs and responses I've come across deal with using the aws console rather than Chalice.

from chalice.

jamesls avatar jamesls commented on May 12, 2024

Can you give me more info or sample code? You mention you're deploying a lambda function and testing via the AWS CLI but the output you show is output you'd get from making an HTTP request to an API gateway rest API (note the x-amz-apigw-id header) which the AWS CLI doesn't support. Can you show the exact commands you're running to test this lambda function?

from chalice.

grutty avatar grutty commented on May 12, 2024

Thank you for your reply. Yes, to clarify, I misspoke when I said I was testing from AWS CLI. I meant I'm setting my credentials using aws configure then making a request http https://zf4f4g4ssh.execute-api.us-west-2.amazonaws.com/api/ . I can get a response from the Chalice hello world root path but when I request the path for my Lambda function I get the "missing token" error.

This is the function:


import requests, json
from chalice import Chalice

app = Chalice(app_name='alpalca_bot')

API_KEY = ''
SECRET_KEY = ''
BASE_URL = "https://paper-api.alpaca.markets"
ORDERS_URL = "{}/v2/orders".format(BASE_URL)
HEADERS = {'APCA-API-KEY-ID': API_KEY, 'APCA-API-SECRET-KEY': SECRET_KEY}

@app.route('/')
def index():
    return {'hello': 'world'}

@app.route('/buy_stonk', methods=['POST'])
def buy_stonk():
    request = app.current_request
    webhook_message = request.json_body

    data = {
    "symbol": webhook_message['ticker'],
    "qty": 1,
    "side": "buy",
    "type": "market",
    "time_in_force": "gtc",
    "order_class": "bracket",
    "take_profit": {
        "limit_price": webhook_message['close'] * 1.035
        },
    "stop_loss": {
        "stop_price": webhook_message['close'] * 0.985,
        }
    }

    r = requests.post(ORDERS_URL, json=data, headers=HEADERS)

    response = json.loads(r.content)

    return {
       'message':'You bought some stonks. Stonks only go up!',
       'webhook_message': webhook_message,
       'id': response['id'],
       'client_order_id': response['client_order_id']
     }

I redeployed the function with chalice deploy tonight for the nth time, still getting the 403 but this time with some more detail from Cloudfront (below). Based on the "missing token" error I've been troubleshooting authentication with my IAM roles and policies but the new message seems to be saying the POST method isn't allowed?

I'm still unsure on how to resolve in the context of using Chalice and the quickstart guide. Thank you again for your help.

New error messaging after redeploying.


HTTP/1.1 403 Forbidden
Connection: keep-alive
Content-Length: 1053
Content-Type: text/html
Date: Thu, 18 Jun 2020 05:51:08 GMT
Server: CloudFront
Via: 1.1 d6b180eb367f7de26d67a9f3901b96a6.cloudfront.net (CloudFront)
X-Amz-Cf-Id: gydDtVjuL1juvAIRYxzw6aNOLmOw9QvK9yOonnanNNjAPjg2XCKc7A==
X-Amz-Cf-Pop: SEA19-C2
X-Cache: Error from cloudfront



<TITLE>ERROR: The request could not be satisfied</TITLE>

403 ERROR

The request could not be satisfied.


This distribution is not configured to allow the HTTP request method that was used for this request. The distribution supports only cachable requests. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.

Generated by cloudfront (CloudFront)
Request ID: gydDtVjuL1juvAIRYxzw6aNOLmOw9QvK9yOonnanNNjAPjg2XCKc7A==

from chalice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.