qontract-reconcile 0.10.2.dev64__py3-none-any.whl → 0.10.2.dev65__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qontract-reconcile
3
- Version: 0.10.2.dev64
3
+ Version: 0.10.2.dev65
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Project-URL: homepage, https://github.com/app-sre/qontract-reconcile
6
6
  Project-URL: repository, https://github.com/app-sre/qontract-reconcile
@@ -637,7 +637,7 @@ reconcile/utils/state.py,sha256=az4tBmZ0EdbFcAGiBVUxs3cr2-BVWsuDQiNTvjjQq8s,1637
637
637
  reconcile/utils/structs.py,sha256=LcbLEg8WxfRqM6nW7NhcWN0YeqF7SQzxOgntmLs1SgY,352
638
638
  reconcile/utils/template.py,sha256=wTvRU4AnAV_o042tD4Mwls2dwWMuk7MKnde3MaCjaYg,331
639
639
  reconcile/utils/terraform_client.py,sha256=H8frsS370y8xfivKLNBD1dwlBLHvfuR6JSN_syBL5Qc,36033
640
- reconcile/utils/terrascript_aws_client.py,sha256=HtBl6Agm8b1rsFbanaatMg1EASQy44KaU5gu_lM_zQQ,284878
640
+ reconcile/utils/terrascript_aws_client.py,sha256=hPfWduAsMpVUcYgw1cx7tiAyVmsJ1BdTCqPzyYPTThE,286260
641
641
  reconcile/utils/three_way_diff_strategy.py,sha256=oQcHXd9LVhirJfoaOBoHUYuZVGfyL2voKr6KVI34zZE,4833
642
642
  reconcile/utils/throughput.py,sha256=iP4UWAe2LVhDo69mPPmgo9nQ7RxHD6_GS8MZe-aSiuM,344
643
643
  reconcile/utils/vault.py,sha256=aSA8l9cJlPUHpChFGl27nSY-Mpq9FMjBo7Dcgb1BVfM,15036
@@ -777,7 +777,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
777
777
  tools/saas_promotion_state/saas_promotion_state.py,sha256=UfwwRLS5Ya4_Nh1w5n1dvoYtchQvYE9yj1VANt2IKqI,3925
778
778
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
779
779
  tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
780
- qontract_reconcile-0.10.2.dev64.dist-info/METADATA,sha256=w1DVvEyO9I2lEXPv9LlbxwxJxqO9tZkUhzrD_jC9KE0,24665
781
- qontract_reconcile-0.10.2.dev64.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
782
- qontract_reconcile-0.10.2.dev64.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
783
- qontract_reconcile-0.10.2.dev64.dist-info/RECORD,,
780
+ qontract_reconcile-0.10.2.dev65.dist-info/METADATA,sha256=Wv30Cf9UuON-ZNSyiNXTocpDNcpFrLTFSdglYgLe_Vg,24665
781
+ qontract_reconcile-0.10.2.dev65.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
782
+ qontract_reconcile-0.10.2.dev65.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
783
+ qontract_reconcile-0.10.2.dev65.dist-info/RECORD,,
@@ -270,6 +270,36 @@ DEFAULT_TAGS = {
270
270
  },
271
271
  }
272
272
 
273
+ AWS_ELB_ACCOUNT_IDS = {
274
+ "us-east-1": "127311923021",
275
+ "us-east-2": "033677994240",
276
+ "us-west-1": "027434742980",
277
+ "us-west-2": "797873946194",
278
+ "af-south-1": "098369216593",
279
+ "ap-east-1": "754344448648",
280
+ "ap-southeast-3": "589379963580",
281
+ "ap-south-1": "718504428378",
282
+ "ap-northeast-3": "383597477331",
283
+ "ap-northeast-2": "600734575887",
284
+ "ap-southeast-1": "114774131450",
285
+ "ap-southeast-2": "783225319266",
286
+ "ap-northeast-1": "582318560864",
287
+ "ca-central-1": "985666609251",
288
+ "eu-central-1": "054676820928",
289
+ "eu-west-1": "156460612806",
290
+ "eu-west-2": "652711504416",
291
+ "eu-south-1": "635631232127",
292
+ "eu-west-3": "009996457667",
293
+ "eu-north-1": "897822967062",
294
+ "me-south-1": "076674570225",
295
+ "sa-east-1": "507241528517",
296
+ }
297
+
298
+ AWS_US_GOV_ELB_ACCOUNT_IDS = {
299
+ "us-gov-west-1": "048591011584",
300
+ "us-gov-east-1": "190560391635",
301
+ }
302
+
273
303
 
274
304
  class OutputResourceNameNotUniqueException(Exception):
275
305
  def __init__(self, namespace, duplicates):
@@ -5148,6 +5178,16 @@ class TerrascriptClient: # pylint: disable=too-many-public-methods
5148
5178
  raise KeyError(f"unknown alb rule condition type {condition_type}")
5149
5179
  return {condition_type_key: {"values": condition[condition_type_key]}}
5150
5180
 
5181
+ @staticmethod
5182
+ def _get_principal_for_s3_bucket_policy(
5183
+ region: str, elb_account_id: str | None
5184
+ ) -> Mapping[str, str]:
5185
+ if region in AWS_ELB_ACCOUNT_IDS:
5186
+ return {"AWS": f"arn:aws:iam::{elb_account_id}:root"}
5187
+ if region in AWS_US_GOV_ELB_ACCOUNT_IDS:
5188
+ return {"AWS": f"arn:aws-us-gov:iam::{elb_account_id}:root"}
5189
+ return {"Service": "logdelivery.elasticloadbalancing.amazonaws.com"}
5190
+
5151
5191
  def populate_tf_resource_alb(self, spec, ocm_map=None):
5152
5192
  account = spec.provisioner_name
5153
5193
  identifier = spec.identifier
@@ -5262,15 +5302,18 @@ class TerrascriptClient: # pylint: disable=too-many-public-methods
5262
5302
  tf_resources.append(lb_access_logs_s3_bucket_tf_resource)
5263
5303
 
5264
5304
  policy_identifier = f"{identifier}-s3-bucket-policy"
5265
- # https://docs.aws.amazon.com/elasticloadbalancing/latest/application/enable-access-logging.html#access-log-create-bucket
5305
+ region = str(
5306
+ common_values.get("region") or self.default_regions.get(account)
5307
+ )
5308
+ elb_account_id = self._get_elb_account_id(region)
5309
+ principal = self._get_principal_for_s3_bucket_policy(region, elb_account_id)
5310
+
5266
5311
  policy = {
5267
5312
  "Version": "2012-10-17",
5268
5313
  "Statement": [
5269
5314
  {
5270
5315
  "Effect": "Allow",
5271
- "Principal": {
5272
- "AWS": f"arn:aws:iam::{self.accounts[account]['uid']}:root"
5273
- },
5316
+ "Principal": principal,
5274
5317
  "Action": "s3:PutObject",
5275
5318
  "Resource": f"${{{lb_access_logs_s3_bucket_tf_resource.arn}}}/*",
5276
5319
  }