作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 CfnConnector(如下面的文档引用链接所述)创建 MSK 连接器,它需要一个 customPluginArn。我如何使用 CDK 创建自定义插件,以便能够获取 CustomPluginArn 和修订号?没有任何关于它的文档。谢谢
引用类 CfnConnector 文档: enter link description here
最佳答案
我结束了创建自定义资源,如果对某人有用,请在此处编码:
def _create_custom_plugin(self):
create_params = {
"contentType": 'ZIP',
"location": {
's3Location': {
'bucketArn': self._msk_connector_bucket_arn,
'fileKey': self._plugin_file_name,
'objectVersion': 'null'
}
},
"name": self._plugin_name,
"description": self._plugin_name
}
create_custom_plugin = custom_resources.AwsSdkCall(
service='KafkaConnect',
action='createCustomPlugin',
region='ap-southeast-2',
physical_resource_id=custom_resources.PhysicalResourceId.of(f'connector-{self._environment_name}'),
parameters = create_params
)
cr_policy = iam.Policy(self, 'cr_policy',
statements = [iam.PolicyStatement(
actions=[
's3:*'
],
effect=iam.Effect.ALLOW,
resources=['*']
)]
)
lambda_role = self._get_provisioning_lambda_role(construct_id=id)
lambda_role.attach_inline_policy(cr_policy)
create_update_custom_plugin = custom_resources.AwsCustomResource(self,
'CreateUpdateCustomPlugin',
on_create=create_custom_plugin,
on_update=create_custom_plugin,
policy=custom_resources.AwsCustomResourcePolicy.from_sdk_calls(resources=custom_resources.AwsCustomResourcePolicy.ANY_RESOURCE)
,role=lambda_role)
self._custom_plugin_arn = create_update_custom_plugin.get_response_field('customPluginArn')
self._revision = create_update_custom_plugin.get_response_field('revision')
def _get_provisioning_lambda_role(self, construct_id: str):
return iam.Role(
scope=self,
id=f'{construct_id}-LambdaRole',
assumed_by=iam.ServicePrincipal('lambda.amazonaws.com'),
managed_policies=[iam.ManagedPolicy.from_aws_managed_policy_name(
"service-role/AWSLambdaBasicExecutionRole")],
)
关于amazon-web-services - 如何使用 AWS_MSK CDK 创建连接器 CustomPlugin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73348883/
我正在使用 CfnConnector(如下面的文档引用链接所述)创建 MSK 连接器,它需要一个 customPluginArn。我如何使用 CDK 创建自定义插件,以便能够获取 CustomPlug
我是一名优秀的程序员,十分优秀!