From ff9710b9ced364f9762ed64c99d55886d363508b Mon Sep 17 00:00:00 2001 From: Matt Gresham Date: Fri, 12 May 2023 11:20:45 +1000 Subject: [PATCH] feat: add ability to add cloudwatch managed policy to nodes --- python-clusters/create-eks-cluster/cluster.json | 7 +++++++ python-clusters/create-eks-cluster/cluster.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/python-clusters/create-eks-cluster/cluster.json b/python-clusters/create-eks-cluster/cluster.json index 29c7d30..3df2d03 100644 --- a/python-clusters/create-eks-cluster/cluster.json +++ b/python-clusters/create-eks-cluster/cluster.json @@ -66,6 +66,13 @@ "mandatory" : true, "defaultValue" : true }, + { + "name": "enableCloudWatchPolicy", + "label": "Add CloudWatch policy", + "description": "Add CloudWatch IAM policy to cluster instances", + "type": "BOOLEAN", + "defaultValue": false + }, { "name": "privateCluster", "label": "Fully-private", diff --git a/python-clusters/create-eks-cluster/cluster.py b/python-clusters/create-eks-cluster/cluster.py index 3c9d42e..cf14ab6 100644 --- a/python-clusters/create-eks-cluster/cluster.py +++ b/python-clusters/create-eks-cluster/cluster.py @@ -127,6 +127,10 @@ def add_pre_bootstrap_commands(commands, yaml_dict): commands = node_pool.get("preBootstrapCommands", "") add_pre_bootstrap_commands(commands, yaml_dict) + if self.config.get('enableCloudWatchPolicy', True): + for node_pool_dict in yaml_dict['managedNodeGroups']: + node_pool_dict['iam']['withAddonPolicies']['cloudWatch'] = True + # whatever the setting, make the cluster from the yaml config yaml_loc = os.path.join(os.getcwd(), self.cluster_id +'_config.yaml') with open(yaml_loc, 'w') as outfile: