From fb5b7e21d8ece7010b86560aa19485e3f8871b1a Mon Sep 17 00:00:00 2001 From: Paul Czarkowski Date: Mon, 11 Dec 2023 13:38:10 -0500 Subject: [PATCH] update to support new mandatory "billing account id" Signed-off-by: Paul Czarkowski --- galaxy.yml | 2 +- plugins/module_utils/ocm.py | 31 +++++++++++++++++++------------ roles/_vars/defaults/main.yml | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/galaxy.yml b/galaxy.yml index b3e3838..86f679f 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,6 +1,6 @@ namespace: rh_mobb name: rosa -version: 2.2.0 +version: 2.2.1 readme: README.md authors: - Paul Czarkowski diff --git a/plugins/module_utils/ocm.py b/plugins/module_utils/ocm.py index e6e240b..7db8031 100644 --- a/plugins/module_utils/ocm.py +++ b/plugins/module_utils/ocm.py @@ -131,6 +131,10 @@ def rosa_creator_arn(): client = boto3.client("sts") return client.get_caller_identity()["Arn"] +def aws_account_id(): + client = boto3.client("sts") + return client.get_caller_identity()["Account"] + def rosa_compute_node_count(params): # return the requested compute node count if set if params['compute_nodes']: @@ -158,7 +162,7 @@ def rosa_compute_nodes(params, availability_zones): ) return compute_nodes - + # return compute node object for non-autoscaling use case compute_nodes.compute = int(rosa_compute_node_count(params)) @@ -264,18 +268,21 @@ def create_cluster(api_instance, params): instance_iam_roles = ocm_client.InstanceIAMRoles( worker_role_arn = params['worker_iam_role'], ) - if not params['hosted_cp']: - instance_iam_roles.master_role_arn = params['controlplane_iam_role'] - else: - # correct the multi-az input for hosted control planes. hosted control plane is - # always considered multi-az because the control plane itself is multi-az. the + if params['hosted_cp']: + # correct the multi-az input for hosted control planes. hosted control plane is + # always considered multi-az because the control plane itself is multi-az. the # machine pools are managed differently. params['multi_az'] = True + # billing account id must be set (todo make it configurable) + billing_account_id = params['aws_account_id'] + else: + instance_iam_roles.master_role_arn = params['controlplane_iam_role'] + billing_account_id = None cluster = ocm_client.Cluster( api = api_visibility((params['private_link'] or params['private'])), - aws = ocm_client.AWS( - sts = ocm_client.STS( + aws = ocm_client.AWS( + sts = ocm_client.STS( enabled = params['sts'], auto_mode = False, #params['hosted_cp'], instance_iam_roles = instance_iam_roles, @@ -285,9 +292,9 @@ def create_cluster(api_instance, params): role_arn = params['role_arn'], support_role_arn = params['support_role_arn'], ), - - kms_key_arn=params['kms_key_arn'], - + + kms_key_arn=params['kms_key_arn'], + billing_account_id = billing_account_id, account_id = params['aws_account_id'], # audit_log etcd_encryption = ocm_client.AwsEtcdEncryption(), @@ -345,7 +352,7 @@ def create_cluster(api_instance, params): channel_group = "stable", ), - + ) try: diff --git a/roles/_vars/defaults/main.yml b/roles/_vars/defaults/main.yml index 6763fdc..73a9dd6 100644 --- a/roles/_vars/defaults/main.yml +++ b/roles/_vars/defaults/main.yml @@ -8,7 +8,7 @@ rosa_private_link: false rosa_disable_workload_monitoring: false rosa_hcp: false -rosa_version: "4.14.1" +rosa_version: "4.14.4" # disable autoscaling # rosa_compute_nodes: 3