将目标组添加到应用程序侦听器(AWS CDK PYTHON)

2024-10-06 08:39:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直试图运行此代码,但未成功,我正在使用python和AWS CDK:

        applicationTargetGroup = elbv2.ApplicationTargetGroup(self, 'ApplicationTargetGroup', 
                            target_type=elbv2.TargetType.IP,
                            target_group_name='stg-test',
                            protocol=elbv2.ApplicationProtocol.HTTP,
                            port=8080,
                            vpc=vpc,
                            health_check=elbv2.HealthCheck(path='/images/favicon.ico')
                            )

    httpsListener.add_target_groups('TargetGroups', 
                            applicationTargetGroup, 
                            host_header='host.domain.com', 
                            priority=107)

我得到的错误如下:

File "/home/user/workspace/test/cdk/pytest/pytest/pytest_stack.py", line 33, in init httpsListener.add_target_groups('TargetGroups', applicationTargetGroup) TypeError: add_target_groups() takes 2 positional arguments but 3 were given

我不明白我做错了什么,因为文档中的说明是可以的:

add_target_groups(id, *, target_groups, conditions=None, host_header=None, path_pattern=None, path_patterns=None, priority=None)

AWS DOCS

谢谢


Tags: pathtestnoneawsaddhosttargetpytest
1条回答
网友
1楼 · 发布于 2024-10-06 08:39:25

add_target_groups的文档告诉我们applicationTargetGroup被传递了一个key word argument和一个list

    httpsListener.add_target_groups(
                  'TargetGroups', 
                  target_groups=[applicationTargetGroup],  
                  host_header='host.domain.com', 
                  priority=107)

相关问题 更多 >