Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
783 views
in Technique[技术] by (71.8m points)

amazon web services - Add Target Group to application listener (AWS CDK PYTHON)

I have been trying to run this code unsuccessfully, i am using python and the 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)

The error I get is the following:

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

I dont understand what I am doing wrong as the documentation states is ok:

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

AWS DOCS

thanks

question from:https://stackoverflow.com/questions/65947533/add-target-group-to-application-listener-aws-cdk-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The docs for add_target_groups it tell that applicationTargetGroup is passed a key word argument and a list:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...