dbt-platform-helper 10.10.0__py3-none-any.whl → 10.11.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -250,7 +250,7 @@ def get_cert_arn(session, application, env_name):
250
250
  return arn
251
251
 
252
252
 
253
- def get_env_ips(vpc: str, application_environment: Environment):
253
+ def get_env_ips(vpc: str, application_environment: Environment) -> List[str]:
254
254
  account_name = f"{application_environment.session.profile_name}-vpc"
255
255
  vpc_name = vpc if vpc else account_name
256
256
  ssm_client = application_environment.session.client("ssm")
@@ -275,8 +275,6 @@ def generate(name, vpc_name):
275
275
  )
276
276
  raise click.Abort
277
277
 
278
- session = get_aws_session_or_abort()
279
-
280
278
  try:
281
279
  conf = load_and_validate_platform_config()
282
280
  except SchemaError as ex:
@@ -284,6 +282,9 @@ def generate(name, vpc_name):
284
282
  raise click.Abort
285
283
 
286
284
  env_config = apply_environment_defaults(conf)["environments"][name]
285
+ profile_for_environment = env_config.get("accounts", {}).get("deploy", {}).get("name")
286
+ click.secho(f"Using {profile_for_environment} for this AWS session")
287
+ session = get_aws_session_or_abort(profile_for_environment)
287
288
 
288
289
  _generate_copilot_environment_manifests(name, conf["application"], env_config, session)
289
290
 
@@ -482,11 +483,8 @@ def delete_listener_rule(tag_descriptions: list, tag_name: str, lb_client: boto3
482
483
  tags = {t["Key"]: t["Value"] for t in description["Tags"]}
483
484
  if tags.get("name") == tag_name:
484
485
  current_rule_arn = description["ResourceArn"]
485
-
486
- if not current_rule_arn:
487
- return current_rule_arn
488
-
489
- lb_client.delete_rule(RuleArn=current_rule_arn)
486
+ if current_rule_arn:
487
+ lb_client.delete_rule(RuleArn=current_rule_arn)
490
488
 
491
489
  return current_rule_arn
492
490
 
@@ -500,7 +498,7 @@ def remove_maintenance_page(session: boto3.Session, listener_arn: str):
500
498
  "TagDescriptions"
501
499
  ]
502
500
 
503
- for name in ["MaintenancePage", "AllowedIps", "BypassIpFilter"]:
501
+ for name in ["MaintenancePage", "AllowedIps", "BypassIpFilter", "AllowedSourceIps"]:
504
502
  deleted = delete_listener_rule(tag_descriptions, name, lb_client)
505
503
 
506
504
  if name == "MaintenancePage" and not deleted:
@@ -520,15 +518,7 @@ def get_rules_tag_descriptions(rules: list, lb_client):
520
518
  return tag_descriptions
521
519
 
522
520
 
523
- def create_header_rule(
524
- lb_client: boto3.client,
525
- listener_arn: str,
526
- target_group_arn: str,
527
- header_name: str,
528
- values: list,
529
- rule_name: str,
530
- priority: int,
531
- ):
521
+ def get_host_conditions(lb_client: boto3.client, listener_arn: str, target_group_arn: str):
532
522
  rules = lb_client.describe_rules(ListenerArn=listener_arn)["Rules"]
533
523
 
534
524
  # Get current set of forwarding conditions for the target group
@@ -549,6 +539,20 @@ def create_header_rule(
549
539
  v for v in conditions[0]["HostHeaderConfig"]["Values"]
550
540
  ]
551
541
 
542
+ return conditions
543
+
544
+
545
+ def create_header_rule(
546
+ lb_client: boto3.client,
547
+ listener_arn: str,
548
+ target_group_arn: str,
549
+ header_name: str,
550
+ values: list,
551
+ rule_name: str,
552
+ priority: int,
553
+ ):
554
+ conditions = get_host_conditions(lb_client, listener_arn, target_group_arn)
555
+
552
556
  # add new condition to existing conditions
553
557
  combined_conditions = [
554
558
  {
@@ -573,6 +577,40 @@ def create_header_rule(
573
577
  )
574
578
 
575
579
 
580
+ def create_source_ip_rule(
581
+ lb_client: boto3.client,
582
+ listener_arn: str,
583
+ target_group_arn: str,
584
+ values: list,
585
+ rule_name: str,
586
+ priority: int,
587
+ ):
588
+ conditions = get_host_conditions(lb_client, listener_arn, target_group_arn)
589
+
590
+ # add new condition to existing conditions
591
+ combined_conditions = [
592
+ {
593
+ "Field": "source-ip",
594
+ "SourceIpConfig": {"Values": [value + "/32" for value in values]},
595
+ }
596
+ ] + conditions
597
+
598
+ lb_client.create_rule(
599
+ ListenerArn=listener_arn,
600
+ Priority=priority,
601
+ Conditions=combined_conditions,
602
+ Actions=[{"Type": "forward", "TargetGroupArn": target_group_arn}],
603
+ Tags=[
604
+ {"Key": "name", "Value": rule_name},
605
+ ],
606
+ )
607
+
608
+ click.secho(
609
+ f"Creating listener rule {rule_name} for HTTPS Listener with arn {listener_arn}.\n\nIf request source ip matches one of the values {values}, the request will be forwarded to target group with arn {target_group_arn}.",
610
+ fg="green",
611
+ )
612
+
613
+
576
614
  def add_maintenance_page(
577
615
  session: boto3.Session,
578
616
  listener_arn: str,
@@ -608,6 +646,14 @@ def add_maintenance_page(
608
646
  "AllowedIps",
609
647
  forwarded_rule_priority,
610
648
  )
649
+ create_source_ip_rule(
650
+ lb_client,
651
+ listener_arn,
652
+ target_group_arn,
653
+ [ip],
654
+ "AllowedSourceIps",
655
+ forwarded_rule_priority + 1,
656
+ )
611
657
 
612
658
  bypass_rule_priority = service_number
613
659
  create_header_rule(
@@ -35,20 +35,6 @@ Mappings:
35
35
  CacheParameterGroupFamily: 'redis7.x'
36
36
  '6.2':
37
37
  CacheParameterGroupFamily: 'redis6.x'
38
- '6.0':
39
- CacheParameterGroupFamily: 'redis6.x'
40
- '5.0.6':
41
- CacheParameterGroupFamily: 'redis5.0'
42
- '5.0.4':
43
- CacheParameterGroupFamily: 'redis5.0'
44
- '5.0.3':
45
- CacheParameterGroupFamily: 'redis5.0'
46
- '5.0.0':
47
- CacheParameterGroupFamily: 'redis5.0'
48
- '4.0.10':
49
- CacheParameterGroupFamily: 'redis4.0'
50
- '3.2.6':
51
- CacheParameterGroupFamily: 'redis3.2'
52
38
 
53
39
  Conditions:
54
40
  {{ addon_config.prefix }}HasAutomaticFailoverEnabled: !Not [!Equals [!FindInMap [{{ addon_config.prefix }}EnvironmentConfigMap, !Ref Env, NumReplicas], 0]]
@@ -180,7 +180,7 @@ REDIS_PLANS = Or(
180
180
  "x-large-ha",
181
181
  )
182
182
 
183
- REDIS_ENGINE_VERSIONS = Or("4.0.10", "5.0.6", "6.0", "6.2", "7.0", "7.1")
183
+ REDIS_ENGINE_VERSIONS = Or("6.2", "7.0", "7.1")
184
184
 
185
185
  REDIS_DEFINITION = {
186
186
  "type": "redis",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbt-platform-helper
3
- Version: 10.10.0
3
+ Version: 10.11.0
4
4
  Summary: Set of tools to help transfer applications/services from GOV.UK PaaS to DBT PaaS augmenting AWS Copilot.
5
5
  License: MIT
6
6
  Author: Department for Business and Trade Platform Team
@@ -12,7 +12,7 @@ dbt_platform_helper/commands/config.py,sha256=NOHea7OAjrl6XHlW6HMLn0m0T5lFPyNH3H
12
12
  dbt_platform_helper/commands/copilot.py,sha256=euid0FTlVtwKmBQ6vxt_HxtBdRYiVQvb-9CyrK1-MWc,16724
13
13
  dbt_platform_helper/commands/database.py,sha256=-DacXZ2LhwV3CRukG35urEU2TuNVZHppUA3EhbBNjUs,4840
14
14
  dbt_platform_helper/commands/dns.py,sha256=o7PkvHktZo0jmqbx0krJTL0R4GtWSf1rF2KDEWor8Ts,35211
15
- dbt_platform_helper/commands/environment.py,sha256=MJcqYBGxMl3oZIJqnbUNNBbwi5WCShLujMUFgGlmzy8,23147
15
+ dbt_platform_helper/commands/environment.py,sha256=VNr7G1QstM8INGs8jOxL1jQRqDcWx2Q0jaaBXtbHhys,24819
16
16
  dbt_platform_helper/commands/generate.py,sha256=YLCPb-xcPapGcsLn-7d1Am7BpGp5l0iecIDTOdNGjHk,722
17
17
  dbt_platform_helper/commands/notify.py,sha256=kVJ0s78QMiaEWPVKu_bbMko4DW2uJy2fu8-HNJsglyk,3748
18
18
  dbt_platform_helper/commands/pipeline.py,sha256=jQGwCRpJ_hXK988XmLHzRBHDWmhFzZb37wa75KuSd0M,5945
@@ -38,7 +38,7 @@ dbt_platform_helper/templates/addons/env/aurora-postgres.yml,sha256=El0jTaWqWy5C
38
38
  dbt_platform_helper/templates/addons/env/monitoring.yml,sha256=ZjvKhrhg6hIoQ51n0jl94z5I8ue_XQp-sypsDVQLiwY,6085
39
39
  dbt_platform_helper/templates/addons/env/opensearch.yml,sha256=Ay0IAE8AWMEUjBRpMWyI4qLFmdwNkQwAN1ciTnuKb5c,10874
40
40
  dbt_platform_helper/templates/addons/env/rds-postgres.yml,sha256=uz7I9u8c-25ergwzNe1EQTT9TadlekeRyhgdpyNbCOo,25645
41
- dbt_platform_helper/templates/addons/env/redis-cluster.yml,sha256=dx6dYniLdhcX-hnSF6RKaO5ZWewAOYqHgX_MMhPkcjs,7634
41
+ dbt_platform_helper/templates/addons/env/redis-cluster.yml,sha256=lUqoNgomx5FzoAplRcqT1BDMeXHTXZ16Or5Xd0Sz2eg,7236
42
42
  dbt_platform_helper/templates/addons/env/s3.yml,sha256=E0ikzN7ztk61rPjUXoKbAujgWcm6MRiDfHzShflBQPA,7758
43
43
  dbt_platform_helper/templates/addons/env/vpc.yml,sha256=Bi-RDr58u-X5J6VHRUxSKDCJ0ddbY79gec6kB69sz8w,3679
44
44
  dbt_platform_helper/templates/addons/svc/appconfig-ipfilter.yml,sha256=nBIXV4um4jIvXs3Q5QycHqVpJODK5yg_M-xJT6AOBKE,977
@@ -93,11 +93,11 @@ dbt_platform_helper/utils/manifests.py,sha256=ji3UYHCxq9tTpkm4MlRa2y0-JOYYqq1pWZ
93
93
  dbt_platform_helper/utils/messages.py,sha256=aLx6s9utt__IqlDdeIYq4n82ERwludu2Zfqy0Q2t-x8,115
94
94
  dbt_platform_helper/utils/platform_config.py,sha256=dEGB6peHB1ywYSdS71JGxbWIuTFRaeQfWelksX9v6bQ,608
95
95
  dbt_platform_helper/utils/template.py,sha256=raRx4QUCVJtKfvJK08Egg6gwWcs3r3V4nPWcJW4xNhA,574
96
- dbt_platform_helper/utils/validation.py,sha256=_1bAnM4GG1MM2xXSGs0IQE2Vwaa-GkueROltIK6Wce8,23725
96
+ dbt_platform_helper/utils/validation.py,sha256=2XMizmCGk4oTVU67q72cdc8eyOzL0wxhe7DframhQ8Q,23699
97
97
  dbt_platform_helper/utils/versioning.py,sha256=h3veQpFoiOjYY9dRVppcBDzVfgZerT0lXuE9QCTo5-c,10710
98
98
  platform_helper.py,sha256=zjsZKcbyrEQbKfERi0JG8JEL-MgG6EjxIMiWT66kCVg,2299
99
- dbt_platform_helper-10.10.0.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
100
- dbt_platform_helper-10.10.0.dist-info/METADATA,sha256=EmVJYENHMaKlcdGSzBcWke2zNzTgtV_O_L3DFrqSAIU,3127
101
- dbt_platform_helper-10.10.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
102
- dbt_platform_helper-10.10.0.dist-info/entry_points.txt,sha256=QhbY8F434A-onsg0-FsdMd2U6HKh6Q7yCFFZrGUh5-M,67
103
- dbt_platform_helper-10.10.0.dist-info/RECORD,,
99
+ dbt_platform_helper-10.11.0.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
100
+ dbt_platform_helper-10.11.0.dist-info/METADATA,sha256=R2rfcAwazxqT20_XZoW-CZeaGjBLSuHIJSchxQJ4Kh4,3127
101
+ dbt_platform_helper-10.11.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
102
+ dbt_platform_helper-10.11.0.dist-info/entry_points.txt,sha256=QhbY8F434A-onsg0-FsdMd2U6HKh6Q7yCFFZrGUh5-M,67
103
+ dbt_platform_helper-10.11.0.dist-info/RECORD,,