We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add support for Application Load Balancer to TargetGroup's valid types
Currently the valid TargetTypes include Instance, IP and Lambda.

ALB should also be added as a valid target group type - [ref](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html#cfn-elasticloadbalancingv2-targetgroup-targettype).

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `troposphere/elasticloadbalancingv2.py`
Content:
```
1 # Copyright (c) 2012-2013, Mark Peek <mark@peek.org>
2 # All rights reserved.
3 #
4 # See LICENSE file for full license.
5 
6 from . import AWSObject, AWSProperty, If, Tags
7 from .validators import (
8     boolean,
9     elb_name,
10     exactly_one,
11     integer,
12     network_port,
13     one_of,
14     tg_healthcheck_port,
15 )
16 
17 
18 class LoadBalancerAttributes(AWSProperty):
19     props = {"Key": (str, False), "Value": (str, False)}
20 
21 
22 class Certificate(AWSProperty):
23     props = {"CertificateArn": (str, False)}
24 
25 
26 class AuthenticateCognitoConfig(AWSProperty):
27     props = {
28         "AuthenticationRequestExtraParams": (dict, False),
29         "OnUnauthenticatedRequest": (str, False),
30         "Scope": (str, False),
31         "SessionCookieName": (str, False),
32         "SessionTimeout": (integer, False),
33         "UserPoolArn": (str, True),
34         "UserPoolClientId": (str, True),
35         "UserPoolDomain": (str, True),
36     }
37 
38 
39 class AuthenticateOidcConfig(AWSProperty):
40     props = {
41         "AuthenticationRequestExtraParams": (dict, False),
42         "AuthorizationEndpoint": (str, True),
43         "ClientId": (str, True),
44         "ClientSecret": (str, True),
45         "Issuer": (str, True),
46         "OnUnauthenticatedRequest": (str, False),
47         "Scope": (str, False),
48         "SessionCookieName": (str, False),
49         "SessionTimeout": (integer, False),
50         "TokenEndpoint": (str, True),
51         "UserInfoEndpoint": (str, True),
52     }
53 
54 
55 class RedirectConfig(AWSProperty):
56     # https://docs.aws.amazon.com/
57     # AWSCloudFormation/latest/UserGuide/
58     # aws-properties-elasticloadbalancingv2-listener-redirectconfig.html
59     props = {
60         "Host": (str, False),
61         "Path": (str, False),
62         "Port": (str, False),
63         "Protocol": (str, False),
64         "Query": (str, False),
65         "StatusCode": (str, True),
66     }
67 
68     def validate(self):
69         one_of(
70             self.__class__.__name__,
71             self.properties,
72             "StatusCode",
73             ["HTTP_301", "HTTP_302"],
74         )
75 
76 
77 class FixedResponseConfig(AWSProperty):
78     props = {
79         "ContentType": (str, False),
80         "MessageBody": (str, False),
81         "StatusCode": (str, True),
82     }
83 
84     def validate(self):
85         one_of(
86             self.__class__.__name__,
87             self.properties,
88             "ContentType",
89             [
90                 None,
91                 "text/plain",
92                 "text/css",
93                 "text/html",
94                 "application/javascript",
95                 "application/json",
96             ],
97         )
98 
99 
100 class TargetGroupTuple(AWSProperty):
101     props = {
102         "TargetGroupArn": (str, True),
103         "Weight": (integer, False),
104     }
105 
106 
107 class TargetGroupStickinessConfig(AWSProperty):
108     props = {
109         "DurationSeconds": (integer, False),
110         "Enabled": (boolean, False),
111     }
112 
113 
114 class ForwardConfig(AWSProperty):
115     props = {
116         "TargetGroups": ([TargetGroupTuple], False),
117         "TargetGroupStickinessConfig": (TargetGroupStickinessConfig, False),
118     }
119 
120 
121 class Action(AWSProperty):
122     props = {
123         "AuthenticateCognitoConfig": (AuthenticateCognitoConfig, False),
124         "AuthenticateOidcConfig": (AuthenticateOidcConfig, False),
125         "FixedResponseConfig": (FixedResponseConfig, False),
126         "Order": (integer, False),
127         "RedirectConfig": (RedirectConfig, False),
128         "TargetGroupArn": (str, False),
129         "ForwardConfig": (ForwardConfig, False),
130         "Type": (str, True),
131     }
132 
133     @staticmethod
134     def any_property(require_prop, properties):
135         return any(p in require_prop for p in properties)
136 
137     def validate(self):
138         one_of(
139             self.__class__.__name__,
140             self.properties,
141             "Type",
142             [
143                 "forward",
144                 "redirect",
145                 "fixed-response",
146                 "authenticate-cognito",
147                 "authenticate-oidc",
148             ],
149         )
150 
151         def requires(action_type, prop):
152             properties = [definition for definition in self.properties.keys()]
153             if self.properties.get("Type") == action_type and not self.any_property(
154                 prop, properties
155             ):
156                 raise ValueError(
157                     'Type "%s" requires definition of "%s"' % (action_type, prop)
158                 )
159             if (
160                 self.any_property(prop, properties)
161                 and self.properties.get("Type") != action_type
162             ):
163                 raise ValueError(
164                     'Definition of "%s" allowed only with '
165                     'type "%s", was: "%s"'
166                     % (prop, action_type, self.properties.get("Type"))
167                 )
168 
169         requires("forward", ["TargetGroupArn", "ForwardConfig"])
170         requires("redirect", ["RedirectConfig"])
171         requires("fixed-response", ["FixedResponseConfig"])
172 
173 
174 class HostHeaderConfig(AWSProperty):
175     props = {
176         "Values": ([str], False),
177     }
178 
179 
180 class HttpHeaderConfig(AWSProperty):
181     props = {
182         "HttpHeaderName": (str, False),
183         "Values": ([str], False),
184     }
185 
186 
187 class HttpRequestMethodConfig(AWSProperty):
188     props = {
189         "Values": ([str], False),
190     }
191 
192 
193 class PathPatternConfig(AWSProperty):
194     props = {
195         "Values": ([str], False),
196     }
197 
198 
199 class QueryStringKeyValue(AWSProperty):
200     props = {
201         "Key": (str, False),
202         "Value": (str, False),
203     }
204 
205 
206 class QueryStringConfig(AWSProperty):
207     props = {
208         "Values": ([QueryStringKeyValue], False),
209     }
210 
211 
212 class SourceIpConfig(AWSProperty):
213     props = {
214         "Values": ([str], False),
215     }
216 
217 
218 class Condition(AWSProperty):
219     props = {
220         "Field": (str, False),
221         "HostHeaderConfig": (HostHeaderConfig, False),
222         "HttpHeaderConfig": (HttpHeaderConfig, False),
223         "HttpRequestMethodConfig": (HttpRequestMethodConfig, False),
224         "PathPatternConfig": (PathPatternConfig, False),
225         "QueryStringConfig": (QueryStringConfig, False),
226         "SourceIpConfig": (SourceIpConfig, False),
227         "Values": ([str], False),
228     }
229 
230 
231 class Matcher(AWSProperty):
232     props = {"HttpCode": (str, True)}
233 
234 
235 class SubnetMapping(AWSProperty):
236     props = {
237         "AllocationId": (str, False),
238         "PrivateIPv4Address": (str, False),
239         "SubnetId": (str, True),
240     }
241 
242 
243 class TargetGroupAttribute(AWSProperty):
244     props = {"Key": (str, False), "Value": (str, False)}
245 
246 
247 class TargetDescription(AWSProperty):
248     props = {
249         "AvailabilityZone": (str, False),
250         "Id": (str, True),
251         "Port": (network_port, False),
252     }
253 
254 
255 class Listener(AWSObject):
256     resource_type = "AWS::ElasticLoadBalancingV2::Listener"
257 
258     props = {
259         "AlpnPolicy": ([str], False),
260         "Certificates": ([Certificate], False),
261         "DefaultActions": ([Action], True),
262         "LoadBalancerArn": (str, True),
263         "Port": (network_port, True),
264         "Protocol": (str, True),
265         "SslPolicy": (str, False),
266     }
267 
268 
269 class ListenerCertificate(AWSObject):
270     resource_type = "AWS::ElasticLoadBalancingV2::ListenerCertificate"
271 
272     props = {
273         "Certificates": ([Certificate], True),
274         "ListenerArn": (str, True),
275     }
276 
277 
278 class ListenerRule(AWSObject):
279     resource_type = "AWS::ElasticLoadBalancingV2::ListenerRule"
280 
281     props = {
282         "Actions": ([Action], True),
283         "Conditions": ([Condition], True),
284         "ListenerArn": (str, True),
285         "Priority": (integer, True),
286     }
287 
288 
289 TARGET_TYPE_INSTANCE = "instance"
290 TARGET_TYPE_IP = "ip"
291 TARGET_TYPE_LAMBDA = "lambda"
292 
293 
294 def validate_target_type(target_type):
295     valid_types = [TARGET_TYPE_INSTANCE, TARGET_TYPE_IP, TARGET_TYPE_LAMBDA]
296     if target_type not in valid_types:
297         raise ValueError(
298             'TargetGroup.TargetType must be one of: "%s"' % ", ".join(valid_types)
299         )
300     return target_type
301 
302 
303 class TargetGroup(AWSObject):
304     resource_type = "AWS::ElasticLoadBalancingV2::TargetGroup"
305 
306     props = {
307         "HealthCheckEnabled": (boolean, False),
308         "HealthCheckIntervalSeconds": (integer, False),
309         "HealthCheckPath": (str, False),
310         "HealthCheckPort": (tg_healthcheck_port, False),
311         "HealthCheckProtocol": (str, False),
312         "HealthCheckTimeoutSeconds": (integer, False),
313         "HealthyThresholdCount": (integer, False),
314         "Matcher": (Matcher, False),
315         "Name": (str, False),
316         "Port": (network_port, False),
317         "Protocol": (str, False),
318         "ProtocolVersion": (str, False),
319         "Tags": ((Tags, list), False),
320         "TargetGroupAttributes": ([TargetGroupAttribute], False),
321         "Targets": ([TargetDescription], False),
322         "TargetType": (validate_target_type, False),
323         "UnhealthyThresholdCount": (integer, False),
324         "VpcId": (str, False),
325     }
326 
327     def validate(self):
328         def check_properties(action_types, props_to_check, required):
329 
330             for this_type in action_types:
331 
332                 self_props = self.properties
333                 if self_props.get("TargetType") == this_type:
334 
335                     invalid_props = []
336                     for prop in props_to_check:
337 
338                         if (prop not in self_props and required is True) or (
339                             prop in self_props and required is False
340                         ):
341                             invalid_props.append(prop)
342 
343                     if len(invalid_props) > 0:
344                         # Make error message more readable in the default case
345                         type_msg = (
346                             "Omitting TargetType"
347                             if this_type is None
348                             else 'TargetType of "%s"' % this_type
349                         )
350 
351                         raise ValueError(
352                             '%s in "%s" %s definitions of %s'
353                             % (
354                                 type_msg,
355                                 self.__class__.__name__,
356                                 "requires" if required is True else "must not contain",
357                                 str(invalid_props).strip("[]"),
358                             )
359                         )
360 
361         # None defaults to instance as per the AWS docs
362         check_properties(
363             [None, TARGET_TYPE_INSTANCE, TARGET_TYPE_IP],
364             ["Port", "Protocol", "VpcId"],
365             True,
366         )
367         check_properties([TARGET_TYPE_LAMBDA], ["Port", "Protocol", "VpcId"], False)
368 
369 
370 class LoadBalancer(AWSObject):
371     resource_type = "AWS::ElasticLoadBalancingV2::LoadBalancer"
372 
373     props = {
374         "IpAddressType": (str, False),
375         "LoadBalancerAttributes": ([LoadBalancerAttributes], False),
376         "Name": (elb_name, False),
377         "Scheme": (str, False),
378         "SecurityGroups": ([str], False),
379         "SubnetMappings": ([SubnetMapping], False),
380         "Subnets": ([str], False),
381         "Tags": ((Tags, list), False),
382         "Type": (str, False),
383     }
384 
385     def validate(self):
386         conds = [
387             "SubnetMappings",
388             "Subnets",
389         ]
390 
391         def check_if(names, props):
392             validated = []
393             for name in names:
394                 validated.append(name in props and isinstance(props[name], If))
395             return all(validated)
396 
397         if check_if(conds, self.properties):
398             return
399 
400         exactly_one(self.__class__.__name__, self.properties, conds)
401
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/troposphere/elasticloadbalancingv2.py b/troposphere/elasticloadbalancingv2.py
--- a/troposphere/elasticloadbalancingv2.py
+++ b/troposphere/elasticloadbalancingv2.py
@@ -286,13 +286,19 @@
     }
 
 
+TARGET_TYPE_ALB = "alb"
 TARGET_TYPE_INSTANCE = "instance"
 TARGET_TYPE_IP = "ip"
 TARGET_TYPE_LAMBDA = "lambda"
 
 
 def validate_target_type(target_type):
-    valid_types = [TARGET_TYPE_INSTANCE, TARGET_TYPE_IP, TARGET_TYPE_LAMBDA]
+    valid_types = [
+        TARGET_TYPE_ALB,
+        TARGET_TYPE_INSTANCE,
+        TARGET_TYPE_IP,
+        TARGET_TYPE_LAMBDA,
+    ]
     if target_type not in valid_types:
         raise ValueError(
             'TargetGroup.TargetType must be one of: "%s"' % ", ".join(valid_types)

{"golden_diff": "diff --git a/troposphere/elasticloadbalancingv2.py b/troposphere/elasticloadbalancingv2.py\n--- a/troposphere/elasticloadbalancingv2.py\n+++ b/troposphere/elasticloadbalancingv2.py\n@@ -286,13 +286,19 @@\n     }\n \n \n+TARGET_TYPE_ALB = \"alb\"\n TARGET_TYPE_INSTANCE = \"instance\"\n TARGET_TYPE_IP = \"ip\"\n TARGET_TYPE_LAMBDA = \"lambda\"\n \n \n def validate_target_type(target_type):\n-    valid_types = [TARGET_TYPE_INSTANCE, TARGET_TYPE_IP, TARGET_TYPE_LAMBDA]\n+    valid_types = [\n+        TARGET_TYPE_ALB,\n+        TARGET_TYPE_INSTANCE,\n+        TARGET_TYPE_IP,\n+        TARGET_TYPE_LAMBDA,\n+    ]\n     if target_type not in valid_types:\n         raise ValueError(\n             'TargetGroup.TargetType must be one of: \"%s\"' % \", \".join(valid_types)\n", "issue": "Add support for Application Load Balancer to TargetGroup's valid types\nCurrently the valid TargetTypes include Instance, IP and Lambda.\r\n\r\nALB should also be added as a valid target group type - [ref](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html#cfn-elasticloadbalancingv2-targetgroup-targettype).\n", "before_files": [{"content": "# Copyright (c) 2012-2013, Mark Peek <mark@peek.org>\n# All rights reserved.\n#\n# See LICENSE file for full license.\n\nfrom . import AWSObject, AWSProperty, If, Tags\nfrom .validators import (\n    boolean,\n    elb_name,\n    exactly_one,\n    integer,\n    network_port,\n    one_of,\n    tg_healthcheck_port,\n)\n\n\nclass LoadBalancerAttributes(AWSProperty):\n    props = {\"Key\": (str, False), \"Value\": (str, False)}\n\n\nclass Certificate(AWSProperty):\n    props = {\"CertificateArn\": (str, False)}\n\n\nclass AuthenticateCognitoConfig(AWSProperty):\n    props = {\n        \"AuthenticationRequestExtraParams\": (dict, False),\n        \"OnUnauthenticatedRequest\": (str, False),\n        \"Scope\": (str, False),\n        \"SessionCookieName\": (str, False),\n        \"SessionTimeout\": (integer, False),\n        \"UserPoolArn\": (str, True),\n        \"UserPoolClientId\": (str, True),\n        \"UserPoolDomain\": (str, True),\n    }\n\n\nclass AuthenticateOidcConfig(AWSProperty):\n    props = {\n        \"AuthenticationRequestExtraParams\": (dict, False),\n        \"AuthorizationEndpoint\": (str, True),\n        \"ClientId\": (str, True),\n        \"ClientSecret\": (str, True),\n        \"Issuer\": (str, True),\n        \"OnUnauthenticatedRequest\": (str, False),\n        \"Scope\": (str, False),\n        \"SessionCookieName\": (str, False),\n        \"SessionTimeout\": (integer, False),\n        \"TokenEndpoint\": (str, True),\n        \"UserInfoEndpoint\": (str, True),\n    }\n\n\nclass RedirectConfig(AWSProperty):\n    # https://docs.aws.amazon.com/\n    # AWSCloudFormation/latest/UserGuide/\n    # aws-properties-elasticloadbalancingv2-listener-redirectconfig.html\n    props = {\n        \"Host\": (str, False),\n        \"Path\": (str, False),\n        \"Port\": (str, False),\n        \"Protocol\": (str, False),\n        \"Query\": (str, False),\n        \"StatusCode\": (str, True),\n    }\n\n    def validate(self):\n        one_of(\n            self.__class__.__name__,\n            self.properties,\n            \"StatusCode\",\n            [\"HTTP_301\", \"HTTP_302\"],\n        )\n\n\nclass FixedResponseConfig(AWSProperty):\n    props = {\n        \"ContentType\": (str, False),\n        \"MessageBody\": (str, False),\n        \"StatusCode\": (str, True),\n    }\n\n    def validate(self):\n        one_of(\n            self.__class__.__name__,\n            self.properties,\n            \"ContentType\",\n            [\n                None,\n                \"text/plain\",\n                \"text/css\",\n                \"text/html\",\n                \"application/javascript\",\n                \"application/json\",\n            ],\n        )\n\n\nclass TargetGroupTuple(AWSProperty):\n    props = {\n        \"TargetGroupArn\": (str, True),\n        \"Weight\": (integer, False),\n    }\n\n\nclass TargetGroupStickinessConfig(AWSProperty):\n    props = {\n        \"DurationSeconds\": (integer, False),\n        \"Enabled\": (boolean, False),\n    }\n\n\nclass ForwardConfig(AWSProperty):\n    props = {\n        \"TargetGroups\": ([TargetGroupTuple], False),\n        \"TargetGroupStickinessConfig\": (TargetGroupStickinessConfig, False),\n    }\n\n\nclass Action(AWSProperty):\n    props = {\n        \"AuthenticateCognitoConfig\": (AuthenticateCognitoConfig, False),\n        \"AuthenticateOidcConfig\": (AuthenticateOidcConfig, False),\n        \"FixedResponseConfig\": (FixedResponseConfig, False),\n        \"Order\": (integer, False),\n        \"RedirectConfig\": (RedirectConfig, False),\n        \"TargetGroupArn\": (str, False),\n        \"ForwardConfig\": (ForwardConfig, False),\n        \"Type\": (str, True),\n    }\n\n    @staticmethod\n    def any_property(require_prop, properties):\n        return any(p in require_prop for p in properties)\n\n    def validate(self):\n        one_of(\n            self.__class__.__name__,\n            self.properties,\n            \"Type\",\n            [\n                \"forward\",\n                \"redirect\",\n                \"fixed-response\",\n                \"authenticate-cognito\",\n                \"authenticate-oidc\",\n            ],\n        )\n\n        def requires(action_type, prop):\n            properties = [definition for definition in self.properties.keys()]\n            if self.properties.get(\"Type\") == action_type and not self.any_property(\n                prop, properties\n            ):\n                raise ValueError(\n                    'Type \"%s\" requires definition of \"%s\"' % (action_type, prop)\n                )\n            if (\n                self.any_property(prop, properties)\n                and self.properties.get(\"Type\") != action_type\n            ):\n                raise ValueError(\n                    'Definition of \"%s\" allowed only with '\n                    'type \"%s\", was: \"%s\"'\n                    % (prop, action_type, self.properties.get(\"Type\"))\n                )\n\n        requires(\"forward\", [\"TargetGroupArn\", \"ForwardConfig\"])\n        requires(\"redirect\", [\"RedirectConfig\"])\n        requires(\"fixed-response\", [\"FixedResponseConfig\"])\n\n\nclass HostHeaderConfig(AWSProperty):\n    props = {\n        \"Values\": ([str], False),\n    }\n\n\nclass HttpHeaderConfig(AWSProperty):\n    props = {\n        \"HttpHeaderName\": (str, False),\n        \"Values\": ([str], False),\n    }\n\n\nclass HttpRequestMethodConfig(AWSProperty):\n    props = {\n        \"Values\": ([str], False),\n    }\n\n\nclass PathPatternConfig(AWSProperty):\n    props = {\n        \"Values\": ([str], False),\n    }\n\n\nclass QueryStringKeyValue(AWSProperty):\n    props = {\n        \"Key\": (str, False),\n        \"Value\": (str, False),\n    }\n\n\nclass QueryStringConfig(AWSProperty):\n    props = {\n        \"Values\": ([QueryStringKeyValue], False),\n    }\n\n\nclass SourceIpConfig(AWSProperty):\n    props = {\n        \"Values\": ([str], False),\n    }\n\n\nclass Condition(AWSProperty):\n    props = {\n        \"Field\": (str, False),\n        \"HostHeaderConfig\": (HostHeaderConfig, False),\n        \"HttpHeaderConfig\": (HttpHeaderConfig, False),\n        \"HttpRequestMethodConfig\": (HttpRequestMethodConfig, False),\n        \"PathPatternConfig\": (PathPatternConfig, False),\n        \"QueryStringConfig\": (QueryStringConfig, False),\n        \"SourceIpConfig\": (SourceIpConfig, False),\n        \"Values\": ([str], False),\n    }\n\n\nclass Matcher(AWSProperty):\n    props = {\"HttpCode\": (str, True)}\n\n\nclass SubnetMapping(AWSProperty):\n    props = {\n        \"AllocationId\": (str, False),\n        \"PrivateIPv4Address\": (str, False),\n        \"SubnetId\": (str, True),\n    }\n\n\nclass TargetGroupAttribute(AWSProperty):\n    props = {\"Key\": (str, False), \"Value\": (str, False)}\n\n\nclass TargetDescription(AWSProperty):\n    props = {\n        \"AvailabilityZone\": (str, False),\n        \"Id\": (str, True),\n        \"Port\": (network_port, False),\n    }\n\n\nclass Listener(AWSObject):\n    resource_type = \"AWS::ElasticLoadBalancingV2::Listener\"\n\n    props = {\n        \"AlpnPolicy\": ([str], False),\n        \"Certificates\": ([Certificate], False),\n        \"DefaultActions\": ([Action], True),\n        \"LoadBalancerArn\": (str, True),\n        \"Port\": (network_port, True),\n        \"Protocol\": (str, True),\n        \"SslPolicy\": (str, False),\n    }\n\n\nclass ListenerCertificate(AWSObject):\n    resource_type = \"AWS::ElasticLoadBalancingV2::ListenerCertificate\"\n\n    props = {\n        \"Certificates\": ([Certificate], True),\n        \"ListenerArn\": (str, True),\n    }\n\n\nclass ListenerRule(AWSObject):\n    resource_type = \"AWS::ElasticLoadBalancingV2::ListenerRule\"\n\n    props = {\n        \"Actions\": ([Action], True),\n        \"Conditions\": ([Condition], True),\n        \"ListenerArn\": (str, True),\n        \"Priority\": (integer, True),\n    }\n\n\nTARGET_TYPE_INSTANCE = \"instance\"\nTARGET_TYPE_IP = \"ip\"\nTARGET_TYPE_LAMBDA = \"lambda\"\n\n\ndef validate_target_type(target_type):\n    valid_types = [TARGET_TYPE_INSTANCE, TARGET_TYPE_IP, TARGET_TYPE_LAMBDA]\n    if target_type not in valid_types:\n        raise ValueError(\n            'TargetGroup.TargetType must be one of: \"%s\"' % \", \".join(valid_types)\n        )\n    return target_type\n\n\nclass TargetGroup(AWSObject):\n    resource_type = \"AWS::ElasticLoadBalancingV2::TargetGroup\"\n\n    props = {\n        \"HealthCheckEnabled\": (boolean, False),\n        \"HealthCheckIntervalSeconds\": (integer, False),\n        \"HealthCheckPath\": (str, False),\n        \"HealthCheckPort\": (tg_healthcheck_port, False),\n        \"HealthCheckProtocol\": (str, False),\n        \"HealthCheckTimeoutSeconds\": (integer, False),\n        \"HealthyThresholdCount\": (integer, False),\n        \"Matcher\": (Matcher, False),\n        \"Name\": (str, False),\n        \"Port\": (network_port, False),\n        \"Protocol\": (str, False),\n        \"ProtocolVersion\": (str, False),\n        \"Tags\": ((Tags, list), False),\n        \"TargetGroupAttributes\": ([TargetGroupAttribute], False),\n        \"Targets\": ([TargetDescription], False),\n        \"TargetType\": (validate_target_type, False),\n        \"UnhealthyThresholdCount\": (integer, False),\n        \"VpcId\": (str, False),\n    }\n\n    def validate(self):\n        def check_properties(action_types, props_to_check, required):\n\n            for this_type in action_types:\n\n                self_props = self.properties\n                if self_props.get(\"TargetType\") == this_type:\n\n                    invalid_props = []\n                    for prop in props_to_check:\n\n                        if (prop not in self_props and required is True) or (\n                            prop in self_props and required is False\n                        ):\n                            invalid_props.append(prop)\n\n                    if len(invalid_props) > 0:\n                        # Make error message more readable in the default case\n                        type_msg = (\n                            \"Omitting TargetType\"\n                            if this_type is None\n                            else 'TargetType of \"%s\"' % this_type\n                        )\n\n                        raise ValueError(\n                            '%s in \"%s\" %s definitions of %s'\n                            % (\n                                type_msg,\n                                self.__class__.__name__,\n                                \"requires\" if required is True else \"must not contain\",\n                                str(invalid_props).strip(\"[]\"),\n                            )\n                        )\n\n        # None defaults to instance as per the AWS docs\n        check_properties(\n            [None, TARGET_TYPE_INSTANCE, TARGET_TYPE_IP],\n            [\"Port\", \"Protocol\", \"VpcId\"],\n            True,\n        )\n        check_properties([TARGET_TYPE_LAMBDA], [\"Port\", \"Protocol\", \"VpcId\"], False)\n\n\nclass LoadBalancer(AWSObject):\n    resource_type = \"AWS::ElasticLoadBalancingV2::LoadBalancer\"\n\n    props = {\n        \"IpAddressType\": (str, False),\n        \"LoadBalancerAttributes\": ([LoadBalancerAttributes], False),\n        \"Name\": (elb_name, False),\n        \"Scheme\": (str, False),\n        \"SecurityGroups\": ([str], False),\n        \"SubnetMappings\": ([SubnetMapping], False),\n        \"Subnets\": ([str], False),\n        \"Tags\": ((Tags, list), False),\n        \"Type\": (str, False),\n    }\n\n    def validate(self):\n        conds = [\n            \"SubnetMappings\",\n            \"Subnets\",\n        ]\n\n        def check_if(names, props):\n            validated = []\n            for name in names:\n                validated.append(name in props and isinstance(props[name], If))\n            return all(validated)\n\n        if check_if(conds, self.properties):\n            return\n\n        exactly_one(self.__class__.__name__, self.properties, conds)\n", "path": "troposphere/elasticloadbalancingv2.py"}], "after_files": [{"content": "# Copyright (c) 2012-2013, Mark Peek <mark@peek.org>\n# All rights reserved.\n#\n# See LICENSE file for full license.\n\nfrom . import AWSObject, AWSProperty, If, Tags\nfrom .validators import (\n    boolean,\n    elb_name,\n    exactly_one,\n    integer,\n    network_port,\n    one_of,\n    tg_healthcheck_port,\n)\n\n\nclass LoadBalancerAttributes(AWSProperty):\n    props = {\"Key\": (str, False), \"Value\": (str, False)}\n\n\nclass Certificate(AWSProperty):\n    props = {\"CertificateArn\": (str, False)}\n\n\nclass AuthenticateCognitoConfig(AWSProperty):\n    props = {\n        \"AuthenticationRequestExtraParams\": (dict, False),\n        \"OnUnauthenticatedRequest\": (str, False),\n        \"Scope\": (str, False),\n        \"SessionCookieName\": (str, False),\n        \"SessionTimeout\": (integer, False),\n        \"UserPoolArn\": (str, True),\n        \"UserPoolClientId\": (str, True),\n        \"UserPoolDomain\": (str, True),\n    }\n\n\nclass AuthenticateOidcConfig(AWSProperty):\n    props = {\n        \"AuthenticationRequestExtraParams\": (dict, False),\n        \"AuthorizationEndpoint\": (str, True),\n        \"ClientId\": (str, True),\n        \"ClientSecret\": (str, True),\n        \"Issuer\": (str, True),\n        \"OnUnauthenticatedRequest\": (str, False),\n        \"Scope\": (str, False),\n        \"SessionCookieName\": (str, False),\n        \"SessionTimeout\": (integer, False),\n        \"TokenEndpoint\": (str, True),\n        \"UserInfoEndpoint\": (str, True),\n    }\n\n\nclass RedirectConfig(AWSProperty):\n    # https://docs.aws.amazon.com/\n    # AWSCloudFormation/latest/UserGuide/\n    # aws-properties-elasticloadbalancingv2-listener-redirectconfig.html\n    props = {\n        \"Host\": (str, False),\n        \"Path\": (str, False),\n        \"Port\": (str, False),\n        \"Protocol\": (str, False),\n        \"Query\": (str, False),\n        \"StatusCode\": (str, True),\n    }\n\n    def validate(self):\n        one_of(\n            self.__class__.__name__,\n            self.properties,\n            \"StatusCode\",\n            [\"HTTP_301\", \"HTTP_302\"],\n        )\n\n\nclass FixedResponseConfig(AWSProperty):\n    props = {\n        \"ContentType\": (str, False),\n        \"MessageBody\": (str, False),\n        \"StatusCode\": (str, True),\n    }\n\n    def validate(self):\n        one_of(\n            self.__class__.__name__,\n            self.properties,\n            \"ContentType\",\n            [\n                None,\n                \"text/plain\",\n                \"text/css\",\n                \"text/html\",\n                \"application/javascript\",\n                \"application/json\",\n            ],\n        )\n\n\nclass TargetGroupTuple(AWSProperty):\n    props = {\n        \"TargetGroupArn\": (str, True),\n        \"Weight\": (integer, False),\n    }\n\n\nclass TargetGroupStickinessConfig(AWSProperty):\n    props = {\n        \"DurationSeconds\": (integer, False),\n        \"Enabled\": (boolean, False),\n    }\n\n\nclass ForwardConfig(AWSProperty):\n    props = {\n        \"TargetGroups\": ([TargetGroupTuple], False),\n        \"TargetGroupStickinessConfig\": (TargetGroupStickinessConfig, False),\n    }\n\n\nclass Action(AWSProperty):\n    props = {\n        \"AuthenticateCognitoConfig\": (AuthenticateCognitoConfig, False),\n        \"AuthenticateOidcConfig\": (AuthenticateOidcConfig, False),\n        \"FixedResponseConfig\": (FixedResponseConfig, False),\n        \"Order\": (integer, False),\n        \"RedirectConfig\": (RedirectConfig, False),\n        \"TargetGroupArn\": (str, False),\n        \"ForwardConfig\": (ForwardConfig, False),\n        \"Type\": (str, True),\n    }\n\n    @staticmethod\n    def any_property(require_prop, properties):\n        return any(p in require_prop for p in properties)\n\n    def validate(self):\n        one_of(\n            self.__class__.__name__,\n            self.properties,\n            \"Type\",\n            [\n                \"forward\",\n                \"redirect\",\n                \"fixed-response\",\n                \"authenticate-cognito\",\n                \"authenticate-oidc\",\n            ],\n        )\n\n        def requires(action_type, prop):\n            properties = [definition for definition in self.properties.keys()]\n            if self.properties.get(\"Type\") == action_type and not self.any_property(\n                prop, properties\n            ):\n                raise ValueError(\n                    'Type \"%s\" requires definition of \"%s\"' % (action_type, prop)\n                )\n            if (\n                self.any_property(prop, properties)\n                and self.properties.get(\"Type\") != action_type\n            ):\n                raise ValueError(\n                    'Definition of \"%s\" allowed only with '\n                    'type \"%s\", was: \"%s\"'\n                    % (prop, action_type, self.properties.get(\"Type\"))\n                )\n\n        requires(\"forward\", [\"TargetGroupArn\", \"ForwardConfig\"])\n        requires(\"redirect\", [\"RedirectConfig\"])\n        requires(\"fixed-response\", [\"FixedResponseConfig\"])\n\n\nclass HostHeaderConfig(AWSProperty):\n    props = {\n        \"Values\": ([str], False),\n    }\n\n\nclass HttpHeaderConfig(AWSProperty):\n    props = {\n        \"HttpHeaderName\": (str, False),\n        \"Values\": ([str], False),\n    }\n\n\nclass HttpRequestMethodConfig(AWSProperty):\n    props = {\n        \"Values\": ([str], False),\n    }\n\n\nclass PathPatternConfig(AWSProperty):\n    props = {\n        \"Values\": ([str], False),\n    }\n\n\nclass QueryStringKeyValue(AWSProperty):\n    props = {\n        \"Key\": (str, False),\n        \"Value\": (str, False),\n    }\n\n\nclass QueryStringConfig(AWSProperty):\n    props = {\n        \"Values\": ([QueryStringKeyValue], False),\n    }\n\n\nclass SourceIpConfig(AWSProperty):\n    props = {\n        \"Values\": ([str], False),\n    }\n\n\nclass Condition(AWSProperty):\n    props = {\n        \"Field\": (str, False),\n        \"HostHeaderConfig\": (HostHeaderConfig, False),\n        \"HttpHeaderConfig\": (HttpHeaderConfig, False),\n        \"HttpRequestMethodConfig\": (HttpRequestMethodConfig, False),\n        \"PathPatternConfig\": (PathPatternConfig, False),\n        \"QueryStringConfig\": (QueryStringConfig, False),\n        \"SourceIpConfig\": (SourceIpConfig, False),\n        \"Values\": ([str], False),\n    }\n\n\nclass Matcher(AWSProperty):\n    props = {\"HttpCode\": (str, True)}\n\n\nclass SubnetMapping(AWSProperty):\n    props = {\n        \"AllocationId\": (str, False),\n        \"PrivateIPv4Address\": (str, False),\n        \"SubnetId\": (str, True),\n    }\n\n\nclass TargetGroupAttribute(AWSProperty):\n    props = {\"Key\": (str, False), \"Value\": (str, False)}\n\n\nclass TargetDescription(AWSProperty):\n    props = {\n        \"AvailabilityZone\": (str, False),\n        \"Id\": (str, True),\n        \"Port\": (network_port, False),\n    }\n\n\nclass Listener(AWSObject):\n    resource_type = \"AWS::ElasticLoadBalancingV2::Listener\"\n\n    props = {\n        \"AlpnPolicy\": ([str], False),\n        \"Certificates\": ([Certificate], False),\n        \"DefaultActions\": ([Action], True),\n        \"LoadBalancerArn\": (str, True),\n        \"Port\": (network_port, True),\n        \"Protocol\": (str, True),\n        \"SslPolicy\": (str, False),\n    }\n\n\nclass ListenerCertificate(AWSObject):\n    resource_type = \"AWS::ElasticLoadBalancingV2::ListenerCertificate\"\n\n    props = {\n        \"Certificates\": ([Certificate], True),\n        \"ListenerArn\": (str, True),\n    }\n\n\nclass ListenerRule(AWSObject):\n    resource_type = \"AWS::ElasticLoadBalancingV2::ListenerRule\"\n\n    props = {\n        \"Actions\": ([Action], True),\n        \"Conditions\": ([Condition], True),\n        \"ListenerArn\": (str, True),\n        \"Priority\": (integer, True),\n    }\n\n\nTARGET_TYPE_ALB = \"alb\"\nTARGET_TYPE_INSTANCE = \"instance\"\nTARGET_TYPE_IP = \"ip\"\nTARGET_TYPE_LAMBDA = \"lambda\"\n\n\ndef validate_target_type(target_type):\n    valid_types = [\n        TARGET_TYPE_ALB,\n        TARGET_TYPE_INSTANCE,\n        TARGET_TYPE_IP,\n        TARGET_TYPE_LAMBDA,\n    ]\n    if target_type not in valid_types:\n        raise ValueError(\n            'TargetGroup.TargetType must be one of: \"%s\"' % \", \".join(valid_types)\n        )\n    return target_type\n\n\nclass TargetGroup(AWSObject):\n    resource_type = \"AWS::ElasticLoadBalancingV2::TargetGroup\"\n\n    props = {\n        \"HealthCheckEnabled\": (boolean, False),\n        \"HealthCheckIntervalSeconds\": (integer, False),\n        \"HealthCheckPath\": (str, False),\n        \"HealthCheckPort\": (tg_healthcheck_port, False),\n        \"HealthCheckProtocol\": (str, False),\n        \"HealthCheckTimeoutSeconds\": (integer, False),\n        \"HealthyThresholdCount\": (integer, False),\n        \"Matcher\": (Matcher, False),\n        \"Name\": (str, False),\n        \"Port\": (network_port, False),\n        \"Protocol\": (str, False),\n        \"ProtocolVersion\": (str, False),\n        \"Tags\": ((Tags, list), False),\n        \"TargetGroupAttributes\": ([TargetGroupAttribute], False),\n        \"Targets\": ([TargetDescription], False),\n        \"TargetType\": (validate_target_type, False),\n        \"UnhealthyThresholdCount\": (integer, False),\n        \"VpcId\": (str, False),\n    }\n\n    def validate(self):\n        def check_properties(action_types, props_to_check, required):\n\n            for this_type in action_types:\n\n                self_props = self.properties\n                if self_props.get(\"TargetType\") == this_type:\n\n                    invalid_props = []\n                    for prop in props_to_check:\n\n                        if (prop not in self_props and required is True) or (\n                            prop in self_props and required is False\n                        ):\n                            invalid_props.append(prop)\n\n                    if len(invalid_props) > 0:\n                        # Make error message more readable in the default case\n                        type_msg = (\n                            \"Omitting TargetType\"\n                            if this_type is None\n                            else 'TargetType of \"%s\"' % this_type\n                        )\n\n                        raise ValueError(\n                            '%s in \"%s\" %s definitions of %s'\n                            % (\n                                type_msg,\n                                self.__class__.__name__,\n                                \"requires\" if required is True else \"must not contain\",\n                                str(invalid_props).strip(\"[]\"),\n                            )\n                        )\n\n        # None defaults to instance as per the AWS docs\n        check_properties(\n            [None, TARGET_TYPE_INSTANCE, TARGET_TYPE_IP],\n            [\"Port\", \"Protocol\", \"VpcId\"],\n            True,\n        )\n        check_properties([TARGET_TYPE_LAMBDA], [\"Port\", \"Protocol\", \"VpcId\"], False)\n\n\nclass LoadBalancer(AWSObject):\n    resource_type = \"AWS::ElasticLoadBalancingV2::LoadBalancer\"\n\n    props = {\n        \"IpAddressType\": (str, False),\n        \"LoadBalancerAttributes\": ([LoadBalancerAttributes], False),\n        \"Name\": (elb_name, False),\n        \"Scheme\": (str, False),\n        \"SecurityGroups\": ([str], False),\n        \"SubnetMappings\": ([SubnetMapping], False),\n        \"Subnets\": ([str], False),\n        \"Tags\": ((Tags, list), False),\n        \"Type\": (str, False),\n    }\n\n    def validate(self):\n        conds = [\n            \"SubnetMappings\",\n            \"Subnets\",\n        ]\n\n        def check_if(names, props):\n            validated = []\n            for name in names:\n                validated.append(name in props and isinstance(props[name], If))\n            return all(validated)\n\n        if check_if(conds, self.properties):\n            return\n\n        exactly_one(self.__class__.__name__, self.properties, conds)\n", "path": "troposphere/elasticloadbalancingv2.py"}]}