首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AWS Mysfits -无效的HTTP端点API网关推送

AWS Mysfits -无效的HTTP端点API网关推送
EN

Stack Overflow用户
提问于 2019-12-15 22:35:03
回答 2查看 858关注 0票数 2

在AWS神秘的Mysfits教程的模块4上,在用所有的替换mes更新swagger文档之后,我无法推动API更改。我已经按照本节的说明做了三次。

参考文献:https://aws.amazon.com/getting-started/projects/build-modern-app-fargate-lambda-dynamodb-python/module-four/

我正在通过Cloud9运行以下命令:

代码语言:javascript
复制
aws apigateway import-rest-api --parameters endpointConfigurationTypes=REGIONAL --body file://~/environment/aws-modern-application-workshop/module-4/aws-cli/api-swagger.json --fail-on-warnings

使用api-swagger-json:

代码语言:javascript
复制
{
    "swagger": 2.0,
    "info": {
        "title": "MysfitsApi"
    },
    "securityDefinitions": {
        "MysfitsUserPoolAuthorizer": {
            "type": "apiKey",
            "name": "Authorization",
            "in": "header",
            "x-amazon-apigateway-authtype": "cognito_user_pools",
            "x-amazon-apigateway-authorizer": {
                "type": "COGNITO_USER_POOLS",
                "providerARNs": [
                    "arn:aws:cognito-idp:us-east-2:730082756200:userpool/us-east-2_jFYjOTZRU"
                ]
            }
        }
    },
    "paths": {
        "/": {
            "get": {
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                },
                "x-amazon-apigateway-integration": {
                    "connectionType": "VPC_LINK",
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    },
                    "connectionId": "wg0305",
                    "httpMethod": "GET",
                    "type": "HTTP_PROXY",
                    "uri": "mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com"
                }
            },
            "options": {
                "summary": "CORS support",
                "description": "Enable CORS by returning correct headers\n",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "CORS"
                ],
                "x-amazon-apigateway-integration": {
                    "type": "mock",
                    "requestTemplates": {
                        "application/json": "{\n  \"statusCode\" : 200\n}\n"
                    },
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            },
                            "responseTemplates": {
                                "application/json": "{}\n"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/mysfits": {
            "get": {
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                },
                "x-amazon-apigateway-integration": {
                    "connectionType": "VPC_LINK",
                    "connectionId": "wg0305",
                    "httpMethod": "GET",
                    "type": "HTTP_PROXY",
                    "uri": "http://mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com/mysfits",
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    }
                }
            },
            "options": {
                "summary": "CORS support",
                "description": "Enable CORS by returning correct headers\n",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "CORS"
                ],
                "x-amazon-apigateway-integration": {
                    "type": "mock",
                    "requestTemplates": {
                        "application/json": "{\n  \"statusCode\" : 200\n}\n"
                    },
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            },
                            "responseTemplates": {
                                "application/json": "{}\n"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/mysfits/{mysfitId}": {
            "get": {
                "parameters": [{
                    "name": "mysfitId",
                    "in": "path",
                    "required": true,
                    "type": "string"
                }],
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                },
                "x-amazon-apigateway-integration": {
                    "requestParameters": {
                        "integration.request.path.mysfitId": "method.request.path.mysfitId"
                    },
                    "connectionType": "VPC_LINK",
                    "connectionId": "wg0305",
                    "httpMethod": "GET",
                    "type": "HTTP_PROXY",
                    "uri": "http://mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com/mysfits/{mysfitId}",
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    }
                }
            },
            "options": {
                "summary": "CORS support",
                "description": "Enable CORS by returning correct headers\n",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "CORS"
                ],
                "x-amazon-apigateway-integration": {
                    "type": "mock",
                    "requestTemplates": {
                        "application/json": "{\n  \"statusCode\" : 200\n}\n"
                    },
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            },
                            "responseTemplates": {
                                "application/json": "{}\n"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/mysfits/{mysfitId}/adopt": {
            "post": {
                "parameters": [{
                    "name": "mysfitId",
                    "in": "path",
                    "required": true,
                    "type": "string"
                }],
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                },
                "security": [{
                    "MysfitsUserPoolAuthorizer": [

                    ]
                }],
                "x-amazon-apigateway-integration": {
                    "requestParameters": {
                        "integration.request.path.mysfitId": "method.request.path.mysfitId"
                    },
                    "connectionType": "VPC_LINK",
                    "connectionId": "wg0305",
                    "httpMethod": "POST",
                    "type": "HTTP_PROXY",
                    "uri": "http://mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com/mysfits/{mysfitId}/adopt",
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    }
                }
            },
            "options": {
                "summary": "CORS support",
                "description": "Enable CORS by returning correct headers\n",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "CORS"
                ],
                "x-amazon-apigateway-integration": {
                    "type": "mock",
                    "requestTemplates": {
                        "application/json": "{\n  \"statusCode\" : 200\n}\n"
                    },
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            },
                            "responseTemplates": {
                                "application/json": "{}\n"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/mysfits/{mysfitId}/like": {
            "post": {
                "parameters": [{
                    "name": "mysfitId",
                    "in": "path",
                    "required": true,
                    "type": "string"
                }],
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                },
                "security": [{
                    "MysfitsUserPoolAuthorizer": [

                    ]
                }],
                "x-amazon-apigateway-integration": {
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    },
                    "requestParameters": {
                        "integration.request.path.mysfitId": "method.request.path.mysfitId"
                    },
                    "connectionType": "VPC_LINK",
                    "connectionId": "wg0305",
                    "httpMethod": "POST",
                    "security": [{
                        "MysfitsUserPoolAuthorizer": [

                        ]
                    }],
                    "type": "HTTP_PROXY",
                    "uri": "http://mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com/mysfits/{mysfitId}/like",
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    }
                }
            },
            "options": {
                "summary": "CORS support",
                "description": "Enable CORS by returning correct headers\n",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "CORS"
                ],
                "x-amazon-apigateway-integration": {
                    "type": "mock",
                    "requestTemplates": {
                        "application/json": "{\n  \"statusCode\" : 200\n}\n"
                    },
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            },
                            "responseTemplates": {
                                "application/json": "{}\n"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
    }
}

我收到错误:

代码语言:javascript
复制
An error occurred (BadRequestException) when calling the ImportRestApi operation: Errors found during import:
        Unable to put integration on 'GET' for resource at path '/': Invalid HTTP endpoint specified for URI

我哪里出问题了?哪个URI无效?如何添加更多的错误捕获以查看它遇到此异常的行和异常消息?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-12-16 00:20:29

因为你的文件格式不正确。它在验证时给出了一个错误“复制映射键”。我想你已经给“回应”下了两次定义。

票数 1
EN

Stack Overflow用户

发布于 2020-02-07 16:48:24

我也有过同样的问题。很简单,'/‘中的URI应该是http://mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59348657

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档