qontract-reconcile 0.10.2.dev291__py3-none-any.whl → 0.10.2.dev292__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.
- {qontract_reconcile-0.10.2.dev291.dist-info → qontract_reconcile-0.10.2.dev292.dist-info}/METADATA +1 -1
- {qontract_reconcile-0.10.2.dev291.dist-info → qontract_reconcile-0.10.2.dev292.dist-info}/RECORD +5 -5
- reconcile/utils/terrascript_aws_client.py +107 -45
- {qontract_reconcile-0.10.2.dev291.dist-info → qontract_reconcile-0.10.2.dev292.dist-info}/WHEEL +0 -0
- {qontract_reconcile-0.10.2.dev291.dist-info → qontract_reconcile-0.10.2.dev292.dist-info}/entry_points.txt +0 -0
{qontract_reconcile-0.10.2.dev291.dist-info → qontract_reconcile-0.10.2.dev292.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: qontract-reconcile
|
3
|
-
Version: 0.10.2.
|
3
|
+
Version: 0.10.2.dev292
|
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
|
{qontract_reconcile-0.10.2.dev291.dist-info → qontract_reconcile-0.10.2.dev292.dist-info}/RECORD
RENAMED
@@ -658,7 +658,7 @@ reconcile/utils/sqs_gateway.py,sha256=XNIf3PY4UCPNufP2Ul0UJj3fKlt5larBba-VTT-41F
|
|
658
658
|
reconcile/utils/state.py,sha256=vCHYIfrWLfPyIWEHSaADWlc4OqhwcOiqM3Egqvw-lfo,16372
|
659
659
|
reconcile/utils/structs.py,sha256=LcbLEg8WxfRqM6nW7NhcWN0YeqF7SQzxOgntmLs1SgY,352
|
660
660
|
reconcile/utils/terraform_client.py,sha256=GoLbfs4d4YItNCeV3NZnrth4sD8ziNYgY2IszruRDpg,37303
|
661
|
-
reconcile/utils/terrascript_aws_client.py,sha256=
|
661
|
+
reconcile/utils/terrascript_aws_client.py,sha256=jVzh5PmphbCAN7Pog_PFYHoHj7lmQGb6Q4FwT_c8pF8,295634
|
662
662
|
reconcile/utils/three_way_diff_strategy.py,sha256=oQcHXd9LVhirJfoaOBoHUYuZVGfyL2voKr6KVI34zZE,4833
|
663
663
|
reconcile/utils/throughput.py,sha256=iP4UWAe2LVhDo69mPPmgo9nQ7RxHD6_GS8MZe-aSiuM,344
|
664
664
|
reconcile/utils/vault.py,sha256=6V15LByFghp-U3k0N4lum6V7qt2EAlRfcAxjy5e-FAU,15146
|
@@ -796,7 +796,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
|
|
796
796
|
tools/saas_promotion_state/saas_promotion_state.py,sha256=uQv2QJAmUXP1g2GPIH30WTlvL9soY6m9lefpZEVDM5w,3965
|
797
797
|
tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
|
798
798
|
tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
|
799
|
-
qontract_reconcile-0.10.2.
|
800
|
-
qontract_reconcile-0.10.2.
|
801
|
-
qontract_reconcile-0.10.2.
|
802
|
-
qontract_reconcile-0.10.2.
|
799
|
+
qontract_reconcile-0.10.2.dev292.dist-info/METADATA,sha256=ihGz58VKwtQQvhSNIkYsi1RwyscQpXOvPCSEIw9DpfM,24916
|
800
|
+
qontract_reconcile-0.10.2.dev292.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
801
|
+
qontract_reconcile-0.10.2.dev292.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
|
802
|
+
qontract_reconcile-0.10.2.dev292.dist-info/RECORD,,
|
@@ -190,13 +190,14 @@ from reconcile.utils.terraform import safe_resource_id
|
|
190
190
|
from reconcile.utils.vcs import VCS
|
191
191
|
|
192
192
|
GH_BASE_URL = os.environ.get("GITHUB_API", "https://api.github.com")
|
193
|
-
|
194
|
-
|
193
|
+
ROSA_AUTH_LOGTOES_RELEASE = "repos/app-sre/logs-to-elasticsearch-lambda/releases/latest"
|
194
|
+
ROSA_AUTH_KINESIS_TO_OS_RELEASE = (
|
195
195
|
"https://github.com/app-sre/kinesis-to-opensearch-lambda/releases/latest"
|
196
196
|
)
|
197
|
-
|
197
|
+
ROSA_AUTH_PRE_SIGNUP_RELEASE = (
|
198
198
|
"repos/app-sre/cognito-pre-signup-trigger/releases/latest"
|
199
199
|
)
|
200
|
+
ROSA_AUTH_PRE_TOKEN_RELEASE = "repos/app-sre/cognito-pre-token-trigger/releases/latest"
|
200
201
|
# VARIABLE_KEYS are passed to common_values on instantiation of a provider
|
201
202
|
VARIABLE_KEYS = [
|
202
203
|
"region",
|
@@ -546,12 +547,14 @@ class TerrascriptClient:
|
|
546
547
|
self.partitions = {
|
547
548
|
a["name"]: a.get("partition") or "aws" for a in filtered_accounts
|
548
549
|
}
|
549
|
-
self.
|
550
|
-
self.
|
551
|
-
self.
|
552
|
-
self.
|
553
|
-
self.
|
554
|
-
self.
|
550
|
+
self.rosa_auth_logtoes_zip = ""
|
551
|
+
self.rosa_auth_logtoes_zip_lock = Lock()
|
552
|
+
self.rosa_auth_pre_signup_zip = ""
|
553
|
+
self.rosa_auth_pre_signup_zip_lock = Lock()
|
554
|
+
self.rosa_auth_pre_token_zip = ""
|
555
|
+
self.rosa_auth_pre_token_zip_lock = Lock()
|
556
|
+
self.rosa_auth_kinesis_to_os_zip: dict[str, str] = {}
|
557
|
+
self.rosa_auth_kinesis_to_os_zip_lock = Lock()
|
555
558
|
self.github: Github | None = None
|
556
559
|
self.github_lock = Lock()
|
557
560
|
self.gitlab: GitLabApi | None = None
|
@@ -608,15 +611,17 @@ class TerrascriptClient:
|
|
608
611
|
)
|
609
612
|
raise ValueError(f"No bucket config found for account {account_name}")
|
610
613
|
|
611
|
-
def
|
612
|
-
if not self.
|
613
|
-
with self.
|
614
|
+
def get_rosa_auth_kinesis_to_os_zip(self, release_url: str) -> str:
|
615
|
+
if not self.rosa_auth_kinesis_to_os_zip.get(release_url):
|
616
|
+
with self.rosa_auth_kinesis_to_os_zip_lock:
|
614
617
|
# this may have already happened, so we check again
|
615
|
-
if not self.
|
616
|
-
self.
|
617
|
-
|
618
|
+
if not self.rosa_auth_kinesis_to_os_zip.get(release_url):
|
619
|
+
self.rosa_auth_kinesis_to_os_zip[release_url] = (
|
620
|
+
self.download_rosa_auth_kinesis_to_os_zip(release_url)
|
621
|
+
)
|
622
|
+
return self.rosa_auth_kinesis_to_os_zip[release_url]
|
618
623
|
|
619
|
-
def
|
624
|
+
def download_rosa_auth_kinesis_to_os_zip(self, release_url: str) -> str:
|
620
625
|
github = self.init_github()
|
621
626
|
url = release_url.replace("https://", "").split("/")
|
622
627
|
repo_name = f"{url[1]}/{url[2]}"
|
@@ -639,14 +644,16 @@ class TerrascriptClient:
|
|
639
644
|
return zip_file
|
640
645
|
|
641
646
|
def get_logtoes_zip(self, release_url):
|
642
|
-
if not self.
|
643
|
-
with self.
|
647
|
+
if not self.rosa_auth_logtoes_zip:
|
648
|
+
with self.rosa_auth_logtoes_zip_lock:
|
644
649
|
# this may have already happened, so we check again
|
645
|
-
if not self.
|
650
|
+
if not self.rosa_auth_logtoes_zip:
|
646
651
|
self.token = get_default_config()["token"]
|
647
|
-
self.
|
648
|
-
|
649
|
-
|
652
|
+
self.rosa_auth_logtoes_zip = self.download_logtoes_zip(
|
653
|
+
ROSA_AUTH_LOGTOES_RELEASE
|
654
|
+
)
|
655
|
+
if release_url == ROSA_AUTH_LOGTOES_RELEASE:
|
656
|
+
return self.rosa_auth_logtoes_zip
|
650
657
|
return self.download_logtoes_zip(release_url)
|
651
658
|
|
652
659
|
def download_logtoes_zip(self, release_url):
|
@@ -663,28 +670,57 @@ class TerrascriptClient:
|
|
663
670
|
f.write(r.content)
|
664
671
|
return zip_file
|
665
672
|
|
666
|
-
def
|
667
|
-
if not self.
|
668
|
-
with self.
|
673
|
+
def get_rosa_auth_pre_signup_zip(self, release_url):
|
674
|
+
if not self.rosa_auth_pre_signup_zip:
|
675
|
+
with self.rosa_auth_pre_signup_zip_lock:
|
669
676
|
# this may have already happened, so we check again
|
670
|
-
if not self.
|
677
|
+
if not self.rosa_auth_pre_signup_zip:
|
671
678
|
self.token = get_default_config()["token"]
|
672
|
-
self.
|
673
|
-
self.
|
674
|
-
|
679
|
+
self.rosa_auth_pre_signup_zip = (
|
680
|
+
self.download_rosa_auth_pre_signup_zip(
|
681
|
+
ROSA_AUTH_PRE_SIGNUP_RELEASE
|
675
682
|
)
|
676
683
|
)
|
677
|
-
if release_url ==
|
678
|
-
return self.
|
679
|
-
return self.
|
684
|
+
if release_url == ROSA_AUTH_PRE_SIGNUP_RELEASE:
|
685
|
+
return self.rosa_auth_pre_signup_zip
|
686
|
+
return self.download_rosa_auth_pre_signup_zip(release_url)
|
680
687
|
|
681
|
-
def
|
688
|
+
def download_rosa_auth_pre_signup_zip(self, release_url):
|
682
689
|
headers = {"Authorization": "token " + self.token}
|
683
690
|
r = requests.get(GH_BASE_URL + "/" + release_url, headers=headers, timeout=60)
|
684
691
|
r.raise_for_status()
|
685
692
|
data = r.json()
|
686
693
|
zip_url = data["assets"][0]["browser_download_url"]
|
687
|
-
zip_file = "/tmp/
|
694
|
+
zip_file = "/tmp/RosaAuthPreSignUp-" + data["tag_name"] + ".zip"
|
695
|
+
if not os.path.exists(zip_file):
|
696
|
+
r = requests.get(zip_url, timeout=60)
|
697
|
+
r.raise_for_status()
|
698
|
+
with open(zip_file, "wb") as f:
|
699
|
+
f.write(r.content)
|
700
|
+
return zip_file
|
701
|
+
|
702
|
+
def get_rosa_auth_pre_token_zip(self, release_url):
|
703
|
+
if not self.rosa_auth_pre_token_zip:
|
704
|
+
with self.rosa_auth_pre_token_zip_lock:
|
705
|
+
# this may have already happened, so we check again
|
706
|
+
if not self.rosa_auth_pre_token_zip:
|
707
|
+
self.token = get_default_config()["token"]
|
708
|
+
self.rosa_auth_pre_token_zip = (
|
709
|
+
self.download_rosa_auth_pre_token_zip(
|
710
|
+
ROSA_AUTH_PRE_TOKEN_RELEASE
|
711
|
+
)
|
712
|
+
)
|
713
|
+
if release_url == ROSA_AUTH_PRE_TOKEN_RELEASE:
|
714
|
+
return self.rosa_auth_pre_token_zip
|
715
|
+
return self.download_rosa_auth_pre_token_zip(release_url)
|
716
|
+
|
717
|
+
def download_rosa_auth_pre_token_zip(self, release_url):
|
718
|
+
headers = {"Authorization": "token " + self.token}
|
719
|
+
r = requests.get(GH_BASE_URL + "/" + release_url, headers=headers, timeout=60)
|
720
|
+
r.raise_for_status()
|
721
|
+
data = r.json()
|
722
|
+
zip_url = data["assets"][0]["browser_download_url"]
|
723
|
+
zip_file = "/tmp/RosaAuthPreToken-" + data["tag_name"] + ".zip"
|
688
724
|
if not os.path.exists(zip_file):
|
689
725
|
r = requests.get(zip_url, timeout=60)
|
690
726
|
r.raise_for_status()
|
@@ -3697,7 +3733,7 @@ class TerrascriptClient:
|
|
3697
3733
|
data.aws_elasticsearch_domain(es_identifier, **es_domain)
|
3698
3734
|
)
|
3699
3735
|
|
3700
|
-
release_url = common_values.get("release_url",
|
3736
|
+
release_url = common_values.get("release_url", ROSA_AUTH_LOGTOES_RELEASE)
|
3701
3737
|
zip_file = self.get_logtoes_zip(release_url)
|
3702
3738
|
|
3703
3739
|
lambda_identifier = f"{identifier}-lambda"
|
@@ -4007,8 +4043,10 @@ class TerrascriptClient:
|
|
4007
4043
|
data.aws_elasticsearch_domain(es_identifier, **es_domain)
|
4008
4044
|
)
|
4009
4045
|
|
4010
|
-
release_url = common_values.get(
|
4011
|
-
|
4046
|
+
release_url = common_values.get(
|
4047
|
+
"release_url", ROSA_AUTH_KINESIS_TO_OS_RELEASE
|
4048
|
+
)
|
4049
|
+
zip_file = self.get_rosa_auth_kinesis_to_os_zip(release_url)
|
4012
4050
|
|
4013
4051
|
lambda_identifier = f"{identifier}-lambda"
|
4014
4052
|
lambda_values = {
|
@@ -5983,16 +6021,14 @@ class TerrascriptClient:
|
|
5983
6021
|
tf_resources.append(lambda_iam_role_resource)
|
5984
6022
|
|
5985
6023
|
# Setup + manage Lambda resources
|
5986
|
-
# pre-signup lambda
|
5987
|
-
release_url = common_values.get(
|
5988
|
-
"release_url", ROSA_AUTHENTICATOR_PRE_SIGNUP_RELEASE
|
5989
|
-
)
|
5990
|
-
zip_file = self.get_rosa_authenticator_zip(release_url)
|
5991
6024
|
|
6025
|
+
# pre-signup lambda
|
6026
|
+
release_url = common_values.get("release_url", ROSA_AUTH_PRE_SIGNUP_RELEASE)
|
6027
|
+
zip_file = self.get_rosa_auth_pre_signup_zip(release_url)
|
5992
6028
|
cognito_pre_signup_lambda_resource = aws_lambda_function(
|
5993
6029
|
"cognito_pre_signup",
|
5994
6030
|
function_name=f"ocm-{identifier}-cognito-pre-signup",
|
5995
|
-
runtime="
|
6031
|
+
runtime="nodejs18.x",
|
5996
6032
|
role=f"${{{lambda_iam_role_resource.arn}}}",
|
5997
6033
|
handler="index.handler",
|
5998
6034
|
filename=zip_file,
|
@@ -6001,6 +6037,21 @@ class TerrascriptClient:
|
|
6001
6037
|
)
|
6002
6038
|
tf_resources.append(cognito_pre_signup_lambda_resource)
|
6003
6039
|
|
6040
|
+
# pre-token lambda
|
6041
|
+
release_url = common_values.get("release_url", ROSA_AUTH_PRE_TOKEN_RELEASE)
|
6042
|
+
zip_file = self.get_rosa_auth_pre_token_zip(release_url)
|
6043
|
+
cognito_pre_token_lambda_resource = aws_lambda_function(
|
6044
|
+
"cognito_pre_token",
|
6045
|
+
function_name=f"ocm-{identifier}-cognito-pre-token",
|
6046
|
+
runtime="nodejs18.x",
|
6047
|
+
role=f"${{{lambda_iam_role_resource.arn}}}",
|
6048
|
+
handler="index.handler",
|
6049
|
+
filename=zip_file,
|
6050
|
+
source_code_hash='${filebase64sha256("' + zip_file + '")}',
|
6051
|
+
tracing_config={"mode": "PassThrough"},
|
6052
|
+
)
|
6053
|
+
tf_resources.append(cognito_pre_token_lambda_resource)
|
6054
|
+
|
6004
6055
|
# setup s3_client
|
6005
6056
|
# pattern followed from utils/state.py
|
6006
6057
|
# The variable "account" is the name of the AWS account we are reconciling
|
@@ -6084,7 +6135,8 @@ class TerrascriptClient:
|
|
6084
6135
|
"pool",
|
6085
6136
|
name=f"ocm-{identifier}-pool",
|
6086
6137
|
lambda_config={
|
6087
|
-
"pre_sign_up": f"${{{cognito_pre_signup_lambda_resource.arn}}}"
|
6138
|
+
"pre_sign_up": f"${{{cognito_pre_signup_lambda_resource.arn}}}",
|
6139
|
+
"pre_token_generation": f"${{{cognito_pre_token_lambda_resource.arn}}}",
|
6088
6140
|
},
|
6089
6141
|
**pool_args,
|
6090
6142
|
)
|
@@ -6100,6 +6152,16 @@ class TerrascriptClient:
|
|
6100
6152
|
)
|
6101
6153
|
tf_resources.append(cognito_pre_signup_lambda_permission_resource)
|
6102
6154
|
|
6155
|
+
# Finish up lambda - pre token
|
6156
|
+
cognito_pre_token_lambda_permission_resource = aws_lambda_permission(
|
6157
|
+
"cognito_pre_token_permission",
|
6158
|
+
action="lambda:InvokeFunction",
|
6159
|
+
function_name=cognito_pre_token_lambda_resource.function_name,
|
6160
|
+
source_arn=f"${{{cognito_user_pool_resource.arn}}}",
|
6161
|
+
principal="cognito-idp.amazonaws.com",
|
6162
|
+
)
|
6163
|
+
tf_resources.append(cognito_pre_token_lambda_permission_resource)
|
6164
|
+
|
6103
6165
|
# POOL DOMAIN
|
6104
6166
|
cognito_user_pool_domain_resource = aws_cognito_user_pool_domain(
|
6105
6167
|
"userpool_domain",
|
@@ -6582,7 +6644,7 @@ class TerrascriptClient:
|
|
6582
6644
|
response_parameters={
|
6583
6645
|
"method.response.header.Location": f"'{user_pool_url}/oauth2/authorize?client_id="
|
6584
6646
|
f"${{{cognito_user_pool_client.id}}}\u0026response_type=code"
|
6585
|
-
f"\u0026scope=openid+gateway/AccessToken\u0026redirect_uri={bucket_url}/"
|
6647
|
+
f"\u0026scope=email+openid+gateway/AccessToken\u0026redirect_uri={bucket_url}/"
|
6586
6648
|
"token.html'",
|
6587
6649
|
},
|
6588
6650
|
depends_on=["aws_api_gateway_integration.gw_integration_auth"],
|
{qontract_reconcile-0.10.2.dev291.dist-info → qontract_reconcile-0.10.2.dev292.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|