Skip to content

Commit f33eb06

Browse files
authored
release 4.4.0 (#1347)
* release 4.4.0 * fix parameters
1 parent 1108029 commit f33eb06

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

cfn-templates/cid-cfn.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# https://github.com/aws-samples/aws-cudos-framework-deployment/blob/main/cfn-templates/cid-cfn.yml
22
AWSTemplateFormatVersion: '2010-09-09'
3-
Description: Deployment of Cloud Intelligence Dashboards v4.3.7 - AWS Solution SO9011
3+
Description: Deployment of Cloud Intelligence Dashboards v4.4.0 - AWS Solution SO9011
44
Metadata:
55
AWS::CloudFormation::Interface:
66
ParameterGroups:
@@ -2075,7 +2075,7 @@ Resources:
20752075
SourceBucket: !Ref ReferenceAssetsBucket
20762076
DestinationBucket: !Ref LocalAssetsBucket
20772077
Keys:
2078-
- 'cid-resource-lambda-layer/cid-4.3.7.zip' #replace version here if needed
2078+
- 'cid-resource-lambda-layer/cid-4.4.0.zip' #replace version here if needed
20792079

20802080
CidResourceLambdaLayer:
20812081
Type: AWS::Lambda::LayerVersion
@@ -2090,7 +2090,7 @@ Resources:
20902090
- LambdaLayerBucketPrefixIsManaged
20912091
- !FindInMap [RegionMap, !Ref 'AWS::Region', BucketName]
20922092
- !Sub '${LambdaLayerBucketPrefix}-${AWS::Region}' # Region added for backward compatibility
2093-
S3Key: 'cid-resource-lambda-layer/cid-4.3.7.zip' #replace version here if needed
2093+
S3Key: 'cid-resource-lambda-layer/cid-4.4.0.zip' #replace version here if needed
20942094
CompatibleRuntimes:
20952095
- python3.10
20962096
- python3.11

cid/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = '4.3.7'
1+
__version__ = '4.4.0'
22

cid/helpers/parameter_store.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,20 @@ def load(self):
3535
def _to_sql_str(self, val):
3636
if val is None:
3737
return "''"
38-
return "'" + str(json.dumps(val)).replace("'", "''") + "'"
38+
39+
# If it's already a JSON string, don't re-encode
40+
if isinstance(val, str):
41+
try:
42+
json.loads(val)
43+
# It's already JSON, just escape for SQL
44+
return "'" + val.replace("'", "''") + "'"
45+
except json.JSONDecodeError:
46+
pass
47+
return "'" + json.dumps(val).replace("'", "''") + "'"
3948

4049
def _from_sql_str(self, string):
41-
if string.endswith(']') and string.startswith('[') and string.count("'") >=2:
42-
# this is an old style parameters so transform it to json readable form from __repr__
43-
string = string.replace("'",'"')
50+
if string.endswith(']') and string.startswith('[') and string.count("'") >= 2:
51+
string = string.replace("'", '"')
4452
try:
4553
return json.loads(string)
4654
except json.JSONDecodeError:
@@ -67,13 +75,18 @@ def load_parameters(self, context):
6775
# get any context and then override with specific context
6876
for line in sorted(data, key=lambda x: x.get('date', '')): # latest should override
6977
val = self._from_sql_str(line.get('value'))
70-
any_parameters[line.get('parameter')] = val
78+
key = self._from_sql_str(line.get('parameter'))
79+
any_parameters[key] = val
7180
if line.get('context') == str(context):
72-
context_parameters[line.get('parameter')] = val
81+
context_parameters[key] = val
7382
return any_parameters | context_parameters
7483

7584
def dump_parameters(self, params, context=None):
7685
data = self.load()
86+
data = [ line # avoid buggy records
87+
for line in data
88+
if '\\' not in str(line)
89+
]
7790
logger.trace(f'loaded parameters {data}')
7891
params = dict(params)
7992
date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
@@ -96,4 +109,10 @@ def dump_parameters(self, params, context=None):
96109
})
97110

98111
logger.trace(f'dumping parameters {data}')
99-
self.dump(data)
112+
self.dump(data)
113+
114+
if __name__ == '__main__':
115+
from cid.helpers import Athena
116+
import boto3
117+
pc = ParametersController(Athena(boto3.session.Session()))
118+
pc.load_parameters('aaa')

0 commit comments

Comments
 (0)