@@ -48,6 +48,7 @@ def __init__(
4848 self .lambda_name ,
4949 dynamoDBcomponent .table ,
5050 timeStreamComponent .timestream_table ,
51+ dynamoDBcomponent .key .arn
5152 )
5253 # create event bridge
5354 eventBridgeComponent = EventBridgeComponent (
@@ -61,9 +62,11 @@ def __init__(
6162 self .grafana_workspace_name ,
6263 )
6364
65+ self .grafana_workspace_id = grafanaWorkspace .grafana_workspace .id
66+
6467 # Create lambda function to rotate Grafana key
6568 grafanaLambdaComponent = GrafanaLambdaComponent (
66- self , "grafana_function" , self .grafana_lambda_name , grafanaWorkspace .grafana_workspace ,
69+ self , "grafana_function" , self .grafana_lambda_name , grafanaWorkspace .grafana_workspace , dynamoDBcomponent . key . arn
6770 )
6871
6972 # Create rotation rules to trigger every 29 days
@@ -72,7 +75,7 @@ def __init__(
7275 )
7376
7477class AwsGrafana (TerraformStack ):
75- def __init__ (self , scope : Construct , id : str ):
78+ def __init__ (self , scope : Construct , id : str , workspace_id : str ):
7679 super ().__init__ (scope , id )
7780
7881 AwsProvider (self , "AWS" )
@@ -82,19 +85,13 @@ def __init__(self, scope: Construct, id: str):
8285 "api_key" ,
8386 secret_id = "flight-controller/grafana-api-key" , # Secret name stored in AWS Secrets Manager
8487 )
85-
86- workspace_id = data_aws_secretsmanager_secret_version .DataAwsSecretsmanagerSecretVersion (
87- self ,
88- "workspace_id" ,
89- secret_id = "flight-controller/grafana-workspace-id" , # Secret name stored in AWS Secrets Manager
90- )
9188
9289 GrafanaProvider (
9390 self ,
9491 "Grafana" ,
9592 auth = api_key .secret_string ,
9693 url = "https://"
97- + workspace_id . secret_string
94+ + workspace_id
9895 + ".grafana-workspace.ap-southeast-2.amazonaws.com/" ,
9996 )
10097
@@ -109,7 +106,7 @@ def __init__(self, scope: Construct, id: str):
109106
110107core_stack = AwsCore (app , "aws_core" )
111108
112- grafana_dashboard_stack = AwsGrafana (app , "aws_grafana_dashboard" )
109+ grafana_dashboard_stack = AwsGrafana (app , "aws_grafana_dashboard" , core_stack . grafana_workspace_id )
113110
114111account_id = boto3 .client ("sts" ).get_caller_identity ()["Account" ]
115112
0 commit comments