talkncloud / tnc-cup-client

npm client for tnc cup api
MIT License
6 stars 0 forks source link

duplicate data sent from the client to the api #13

Closed talkncloud closed 3 years ago

talkncloud commented 3 years ago

Certain items are being duplicated and sent to the API, here is the data sent to the API (output from the API as it's received from the client):

[{'api': {'Type': 'AWS::AppSync::GraphQLApi', 'Properties': {'AuthenticationType': 'AMAZON_COGNITO_USER_POOLS', 'Name': 'talkncloud', 'UserPoolConfig': {'AwsRegion': {'Ref': 'AWS::Region'}, 'DefaultAction': 'ALLOW', 'UserPoolId': {'Ref': 'tncup'}}}, 'Metadata': {'aws:cdk:path': 'AppsyncWafStack/api'}}}, {'waf': {'Type': 'AWS::WAFv2::WebACL', 'Properties': {'DefaultAction': {'Allow': {}}, 'Scope': 'REGIONAL', 'VisibilityConfig': {'CloudWatchMetricsEnabled': True, 'MetricName': 'tnc-firewall', 'SampledRequestsEnabled': True}, 'Description': 'ACL for talkncloud appsync', 'Rules': [{'Action': {'Count': {}}, 'Name': 'GeoMatch', 'Priority': 0, 'Statement': {'NotStatement': {'Statement': {'GeoMatchStatement': {'CountryCodes': ['AU']}}}}, 'VisibilityConfig': {'CloudWatchMetricsEnabled': True, 'MetricName': 'GeoMatch', 'SampledRequestsEnabled': True}}, {'Name': 'AWS-AWSManagedRulesCommonRuleSet', 'OverrideAction': {'None': {}}, 'Priority': 1, 'Statement': {'ManagedRuleGroupStatement': {'ExcludedRules': [{'Name': 'NoUserAgent_HEADER'}], 'Name': 'AWSManagedRulesCommonRuleSet', 'VendorName': 'AWS'}}, 'VisibilityConfig': {'CloudWatchMetricsEnabled': True, 'MetricName': 'AWS-AWSManagedRulesCommonRuleSet', 'SampledRequestsEnabled': True}}, {'Action': {'Block': {}}, 'Name': 'LimitRequests100', 'Priority': 2, 'Statement': {'RateBasedStatement': {'AggregateKeyType': 'IP', 'Limit': 100}}, 'VisibilityConfig': {'CloudWatchMetricsEnabled': True, 'MetricName': 'LimitRequests100', 'SampledRequestsEnabled': True}}]}, 'Metadata': {'aws:cdk:path': 'AppsyncWafStack/waf'}}}, {'tncup': {'Type': 'AWS::Cognito::UserPool', 'Properties': {'AdminCreateUserConfig': {'AllowAdminCreateUserOnly': True}}, 'Metadata': {'aws:cdk:path': 'AppsyncWafStack/tnc-up'}}}, {'api': {'Type': 'AWS::AppSync::GraphQLApi', 'Properties': {'AuthenticationType': 'AMAZON_COGNITO_USER_POOLS', 'Name': 'talkncloud', 'UserPoolConfig': {'AwsRegion': {'Ref': 'AWS::Region'}, 'DefaultAction': 'ALLOW', 'UserPoolId': {'Ref': 'tncup'}}}, 'Metadata': {'aws:cdk:path': 'AppsyncWafStack/api'}}}, {'waf': {'Type': 'AWS::WAFv2::WebACL', 'Properties': {'DefaultAction': {'Allow': {}}, 'Scope': 'REGIONAL', 'VisibilityConfig': {'CloudWatchMetricsEnabled': True, 'MetricName': 'tnc-firewall', 'SampledRequestsEnabled': True}, 'Description': 'ACL for talkncloud appsync', 'Rules': [{'Action': {'Count': {}}, 'Name': 'GeoMatch', 'Priority': 0, 'Statement': {'NotStatement': {'Statement': {'GeoMatchStatement': {'CountryCodes': ['AU']}}}}, 'VisibilityConfig': {'CloudWatchMetricsEnabled': True, 'MetricName': 'GeoMatch', 'SampledRequestsEnabled': True}}, {'Name': 'AWS-AWSManagedRulesCommonRuleSet', 'OverrideAction': {'None': {}}, 'Priority': 1, 'Statement': {'ManagedRuleGroupStatement': {'ExcludedRules': [{'Name': 'NoUserAgent_HEADER'}], 'Name': 'AWSManagedRulesCommonRuleSet', 'VendorName': 'AWS'}}, 'VisibilityConfig': {'CloudWatchMetricsEnabled': True, 'MetricName': 'AWS-AWSManagedRulesCommonRuleSet', 'SampledRequestsEnabled': True}}, {'Action': {'Block': {}}, 'Name': 'LimitRequests100', 'Priority': 2, 'Statement': {'RateBasedStatement': {'AggregateKeyType': 'IP', 'Limit': 100}}, 'VisibilityConfig': {'CloudWatchMetricsEnabled': True, 'MetricName': 'LimitRequests100', 'SampledRequestsEnabled': True}}]}, 'Metadata': {'aws:cdk:path': 'AppsyncWafStack/waf'}}}]

talkncloud commented 3 years ago

based on conversations, the current problem is that the configuration parameters of files, directories allows for duplicate reading of the files. e.g. a template in dir1/file1.json will be read but also if dir is set to dir1/ it will read the file again and post.

in hind sight this isn't the best design, for now we should handle a single file supplied as a parameter to the cli instead.

tnc-cup -t mytemplate.json

Note: this would be json or yaml which is currently supported by the client.

it is possible that in the future a directory of files would be required, but this is all that is required as of now.

by parsing a single file this will be remove the duplicate reading and remove 2 x local configuration parameters, that is files, directories.

talkncloud commented 3 years ago

resolved with merge