我想用无服务器创建一个安全的APIG,在我目前的" s-fuction.json "我已经拥有:
"apiKeyRequired": true,
Run Code Online (Sandbox Code Playgroud)
在我的" s-resources-cf.json "中我已经拥有:
"AWSApiKey": {
"Type": "AWS::ApiGateway::ApiKey",
"Properties" : {
"Description" : "ApiKey for secure the connections to the xxx API",
"Enabled" : true
}
}
Run Code Online (Sandbox Code Playgroud)
它正确地为lambda(包括CORS)和API Key创建了一个Lambda,一个APIG,但是我需要手动"分配"生成的APIG-Stage的密钥,你对我怎么能这样做有什么想法自动使用无服务器?
我从这里阅读了有关我想要的功能的AWS文档(似乎有可能):AWS CloudFormation API密钥
文档显示它可以通过以下方式完成:
"ApiKey": {
"Type": "AWS::ApiGateway::ApiKey",
"DependsOn": ["TestAPIDeployment", "Test"],
"Properties": {
"Name": "TestApiKey",
"Description": "CloudFormation API Key V1",
"Enabled": "true",
"StageKeys": [{
"RestApiId": { "Ref": "RestApi" },
"StageName": "Test"
}]
}
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何添加对无服务器自动创建的APIG的引用以及如何等待创建APIG.