aws-api-gateway - 使用 CDK 为 AWS ApiGW 重用自定义授权方
问题描述
我想重用在一个存储库中使用 CDK 创建的自定义授权方,用于在另一个存储库中创建的新 AWS ApiGW 方法。目前,没有用于导入现有授权人的 CDK 内置方法。
解决方案
我找到了解决问题的方法:
# Import rest api from the environment using ids
rest_api = RestApi.from_rest_api_attributes(self, "fromrestapiid",
rest_api_id=rest_api_id,
root_resource_id=resource_id)
# Retrieve or create an API method
method_resource = rest_api.root.resource_for_path(endpoint_path)
# Change the property of the resource using the existing authorizer id
method_resource = method.node.find_child('Resource')
method_resource.add_property_override('AuthorizationType', 'CUSTOM')
method_resource.add_property_override('AuthorizerId', authorizer_id)
推荐阅读
- sql-server - 是否可以根据 SQL 数据库中的数据在 SSRS Report 中创建重复表?
- javascript - Vue.js 使用外部对象计算函数
- reactjs - 嵌套 React 组件中的路由
- c# - 命令栏 Myreport excel 不可见
- ios - Google Maps Flutter 自定义标记未显示
- python - 提取列表中与字符串匹配的所有元素
- highcharts - highcharts 多标记悬停颜色不继承自标记颜色
- python - RobotFramework 中的长寿对象
- html - 如何使“文本框”响应不同长度的文本
- excel - VBA WordDoc 表的第二次运行添加未设置变量