3
3
import logging
4
4
import shutil
5
5
import sys
6
- from typing import Callable , List
6
+ from typing import Callable , List , Tuple , Dict
7
7
8
8
import arkime_interactions .config_wrangling as config_wrangling
9
9
from aws_interactions .acm_interactions import upload_default_elb_cert
31
31
logger = logging .getLogger (__name__ )
32
32
33
33
def cmd_cluster_create (profile : str , region : str , name : str , expected_traffic : float , spi_days : int , history_days : int , replicas : int ,
34
- pcap_days : int , preconfirm_usage : bool , just_print_cfn : bool , capture_cidr : str , viewer_cidr : str , viewer_prefix_list : str ):
34
+ pcap_days : int , preconfirm_usage : bool , just_print_cfn : bool , capture_cidr : str , viewer_cidr : str , viewer_prefix_list : str ,
35
+ extra_tags : List [Dict [str , str ]]):
35
36
logger .debug (f"Invoking cluster-create with profile '{ profile } ' and region '{ region } '" )
36
37
37
38
aws_provider = AwsClientProvider (aws_profile = profile , aws_region = region )
@@ -50,7 +51,7 @@ def cmd_cluster_create(profile: str, region: str, name: str, expected_traffic: f
50
51
51
52
# Generate our capacity plan, then confirm it's what the user expected and it's safe to proceed with the operation
52
53
previous_user_config = _get_previous_user_config (name , aws_provider )
53
- next_user_config = _get_next_user_config (name , expected_traffic , spi_days , history_days , replicas , pcap_days , viewer_prefix_list , aws_provider )
54
+ next_user_config = _get_next_user_config (name , expected_traffic , spi_days , history_days , replicas , pcap_days , viewer_prefix_list , extra_tags , aws_provider )
54
55
previous_capacity_plan = _get_previous_capacity_plan (name , aws_provider )
55
56
next_capacity_plan = _get_next_capacity_plan (next_user_config , previous_capacity_plan , capture_cidr , viewer_cidr , aws_provider )
56
57
@@ -82,9 +83,6 @@ def cmd_cluster_create(profile: str, region: str, name: str, expected_traffic: f
82
83
# Deploy the CFN resources
83
84
cdk_client .deploy (stacks_to_deploy , context = create_context )
84
85
85
- # Tag the OpenSearch Domain
86
- _tag_domain (name , aws_provider )
87
-
88
86
# Kick off Events to ensure that ISM is set up on the CFN-created OpenSearch Domain
89
87
_configure_ism (name , next_user_config .historyDays , next_user_config .spiDays , next_user_config .replicas , aws_provider )
90
88
@@ -156,7 +154,7 @@ def _get_previous_user_config(cluster_name: str, aws_provider: AwsClientProvider
156
154
return UserConfig (None , None , None , None , None )
157
155
158
156
def _get_next_user_config (cluster_name : str , expected_traffic : float , spi_days : int , history_days : int , replicas : int ,
159
- pcap_days : int , viewer_prefix_list : str , aws_provider : AwsClientProvider ) -> UserConfig :
157
+ pcap_days : int , viewer_prefix_list : str , extra_tags : str , aws_provider : AwsClientProvider ) -> UserConfig :
160
158
# At least one parameter isn't defined
161
159
if None in [expected_traffic , spi_days , replicas , pcap_days , history_days , viewer_prefix_list ]:
162
160
# Re-use the existing configuration if it exists
@@ -183,14 +181,16 @@ def _get_next_user_config(cluster_name: str, expected_traffic: float, spi_days:
183
181
user_config .pcapDays = pcap_days
184
182
if viewer_prefix_list is not None :
185
183
user_config .viewerPrefixList = viewer_prefix_list
184
+ if extra_tags is not None :
185
+ user_config .extraTags = extra_tags
186
186
return user_config
187
187
188
188
# Existing configuration doesn't exist, use defaults
189
189
except ssm_ops .ParamDoesNotExist :
190
- return UserConfig (expected_traffic , spi_days , history_days , replicas , pcap_days , viewer_prefix_list )
190
+ return UserConfig (expected_traffic , spi_days , history_days , replicas , pcap_days , viewer_prefix_list , extra_tags )
191
191
# All of the parameters defined
192
192
else :
193
- return UserConfig (expected_traffic , spi_days , history_days , replicas , pcap_days , viewer_prefix_list )
193
+ return UserConfig (expected_traffic , spi_days , history_days , replicas , pcap_days , viewer_prefix_list , extra_tags )
194
194
195
195
def _get_previous_capacity_plan (cluster_name : str , aws_provider : AwsClientProvider ) -> ClusterPlan :
196
196
# Pull the existing plan, if possible
@@ -358,21 +358,6 @@ def _configure_ism(cluster_name: str, history_days: int, spi_days: int, replicas
358
358
aws_provider
359
359
)
360
360
361
- def _tag_domain (cluster_name : str , aws_provider : AwsClientProvider ):
362
- os_domain_Arn = ssm_ops .get_ssm_param_json_value (
363
- constants .get_opensearch_domain_ssm_param_name (cluster_name ),
364
- "domainArn" ,
365
- aws_provider
366
- )
367
-
368
- opensearch_client = aws_provider .get_opensearch ()
369
- opensearch_client .add_tags (
370
- ARN = os_domain_Arn ,
371
- TagList = [
372
- {"Key" : "arkime_cluster" , "Value" : cluster_name },
373
- ]
374
- )
375
-
376
361
def _get_stacks_to_deploy (cluster_name : str , next_user_config : UserConfig , next_capacity_plan : ClusterPlan ) -> List [str ]:
377
362
# This list defines what actually gets deployed, as opposed to what the CDK has in its blueprint as being available
378
363
# to deploy.
0 commit comments