Skip to content

Commit f1300c4

Browse files
authored
add deployment type (#1241)
1 parent 92c11cf commit f1300c4

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

cfn-templates/cid-cfn.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Metadata:
4040
- DeployCUDOSDashboard
4141
- DataBucketsKmsKeysArns
4242
- ShareDashboard
43+
- DeploymentType
4344
- CreateLocalAssetsBucket
4445
- ReferenceAssetsBucket
4546
- Label:
@@ -105,6 +106,8 @@ Metadata:
105106
default: "Create Local Assets Bucket"
106107
ReferenceAssetsBucket:
107108
default: "Reference Assets Bucket Name"
109+
DeploymentType:
110+
default: "Type of Deployment - Please do not change"
108111
CurrencySymbol:
109112
default: "Currency Symbol"
110113
cfn-lint:
@@ -262,9 +265,18 @@ Parameters:
262265
CurrencySymbol:
263266
Type: String
264267
Description: 'Currency Symbol. Please align with Currency of your CUR. Only supported for China region.'
265-
Default: "USD"
266-
AllowedValues:
268+
Default: "$"
269+
AllowedValues:
267270
# Only currency symbols supported by QS
271+
- "$" # US Dollar
272+
- "£" # British Pound
273+
- "" # Euro
274+
- "¥" # Japanese Yen
275+
- "" # South Korean Won
276+
- "kr" # Danish Krone
277+
- "NT" # Taiwan Dollar
278+
- "" # Indian Rupee
279+
# for backward compatibility
268280
- "USD" # US Dollar $
269281
- "GBP" # British Pound £
270282
- "EUR" # Euro €
@@ -273,6 +285,13 @@ Parameters:
273285
- "DKK" # Danish Krone kr
274286
- "TWD" # Taiwan Dollar NT
275287
- "INR" # Indian Rupee ₹
288+
DeploymentType:
289+
Type: String
290+
Description: 'Internal Deployment Type'
291+
Default: "Lambda"
292+
AllowedValues:
293+
- "Lambda"
294+
- "Terraform"
276295

277296
Conditions:
278297
NeedCUDOSDashboard: !Equals [ !Ref DeployCUDOSDashboard, "yes" ]
@@ -607,7 +626,7 @@ Resources:
607626
ZipFile: |
608627
# Legacy lambda - will be deleted in next major update
609628
import cfnresponse
610-
629+
611630
def lambda_handler(event, context):
612631
cfnresponse.send(event, context, cfnresponse.SUCCESS, {}, 'keep_it_constant', 'legacy')
613632
Metadata:
@@ -1855,6 +1874,7 @@ Resources:
18551874
- !Ref CidResourceLambdaLayer
18561875
Environment:
18571876
Variables:
1877+
AWS_DEPLOYMENT_TYPE: !Ref DeploymentType
18581878
athena_workgroup: !If [ NeedAthenaWorkgroup, !Ref MyAthenaWorkGroup, !Ref AthenaWorkgroup ]
18591879
quicksight_datasource_id: !Select [ 1, !Split [ '/', !GetAtt CidAthenaDataSource.Arn]]
18601880
quicksight_datasource_role_arn: !If [ NeedQuickSightDataSourceRole, !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/${QuickSightDataSourceRole}", "" ]

cid/common.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,22 @@ def export(self, **kwargs):
282282
export_analysis(self.qs, self.athena, glue=self.glue)
283283

284284
def track(self, action, dashboard_id):
285-
""" Send dashboard_id and account_id to adoption tracker """
285+
""" Send dashboard_id and account_id to CID adoption tracker """
286286
method = {'created':'PUT', 'updated':'PATCH', 'deleted': 'DELETE'}.get(action, None)
287287
if not method:
288288
logger.debug(f"This will not fail the deployment. Logging action {action} is not supported. This issue will be ignored")
289289
return
290-
endpoint = 'https://okakvoavfg.execute-api.eu-west-1.amazonaws.com/'
290+
endpoint = 'https://cid.workshops.aws.dev/adoption-tracking' # AWS Managed
291+
if os.environ.get('AWS_DEPLOYMENT_TYPE'):
292+
deployment_type = os.environ.get('AWS_DEPLOYMENT_TYPE')
293+
elif os.environ.get('AWS_EXECUTION_ENV', '').startswith('AWS_Lambda'):
294+
deployment_type = 'Lambda'
295+
else:
296+
deployment_type = 'CID'
291297
payload = {
292298
'dashboard_id': dashboard_id,
293299
'account_id': self.base.account_id,
294-
action + '_via': 'Lambda' if os.environ.get('AWS_EXECUTION_ENV', '').startswith('AWS_Lambda') else 'CID',
300+
action + '_via': deployment_type,
295301
}
296302
try:
297303
res = requests.request(

0 commit comments

Comments
 (0)