Skip to content

Commit

Permalink
add v2.1.1 release candidate to github
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwow committed Sep 11, 2023
1 parent 55ecea6 commit 3620443
Show file tree
Hide file tree
Showing 20 changed files with 77 additions and 72 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.1.1] - 2023-09-11

### Fixed

- Resolve a defect in the reporting of anonymous metrics that prevents CloudFormation events from being properly recorded.

## [2.1.0] - 2023-06-01

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ sh deployment/run-unit-tests.sh

## Collection of operational metrics

This solution collects anonymous operational metrics to help AWS improve the
This solution collects anonymized operational metrics to help AWS improve the
quality of features of the solution. For more information, including how to disable
this capability, please see the [implementation guide](https://docs.aws.amazon.com/solutions/latest/amazon-marketing-cloud-uploader-from-aws/collection-of-operational-metrics.html).

Expand Down
8 changes: 4 additions & 4 deletions deployment/amazon-marketing-cloud-uploader-from-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Parameters:

Conditions:
EnableCmkEncryptionCondition: !Not [!Equals [!Ref CustomerManagedKey, ""]]
EnableAnonymousData: !Equals [ !FindInMap [AnonymousData,SendAnonymousData,Data], Yes]
EnableAnonymousData: !Equals [ !FindInMap [AnonymizedData,SendAnonymizedData,Data], Yes]

Mappings:
Application:
Expand All @@ -32,8 +32,8 @@ Mappings:
TemplateKeyPrefix: "%%SOLUTION_NAME%%/%%VERSION%%"
RegionalS3Bucket: "%%REGIONAL_BUCKET_NAME%%"
CodeKeyPrefix: "%%SOLUTION_NAME%%/%%VERSION%%"
AnonymousData:
SendAnonymousData:
AnonymizedData:
SendAnonymizedData:
Data: Yes

Resources:
Expand Down Expand Up @@ -842,7 +842,7 @@ Resources:
ArtifactBucketName: !Ref ArtifactBucket
DataBucketName: !Ref DataBucketName
CustomerManagedKey: !Ref CustomerManagedKey
EnableAnonymousData: !FindInMap [AnonymousData,SendAnonymousData,Data]
EnableAnonymousData: !FindInMap [AnonymizedData,SendAnonymizedData,Data]
AnonymousDataLogger: !Ref AnonymousDataCustomResource
SolutionId: !FindInMap [ "Application", "Solution", "Id" ]
UUID: !GetAtt AnonymousDataUuid.UUID
Expand Down
1 change: 0 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ sonar.exclusions= \
source/tests/**/*, \
source/**/tests/**/*, \
source/deployment/**/*, \
source/website/**/*, \
source/**/package/**/*, \
source/**/dist/**/*

Expand Down
16 changes: 2 additions & 14 deletions source/anonymous_data_logger/anonymous_data_logger.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##############################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
# #
# Licensed under the Apache License Version 2.0 (the "License"). #
# You may not use this file except in compliance with the License. #
# A copy of the License is located at #
# #
# http://www.apache.org/licenses/ #
# #
# or in the "license" file accompanying this file. This file is distributed #
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, #
# express or implied. See the License for the specific language governing #
# permissions and limitations under the License. #
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
##############################################################################
#
# PURPOSE:
Expand Down
17 changes: 2 additions & 15 deletions source/anonymous_data_logger/anonymous_lib/cfnresponse.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##############################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
# #
# Licensed under the Apache License Version 2.0 (the "License"). #
# You may not use this file except in compliance with the License. #
# A copy of the License is located at #
# #
# http://www.apache.org/licenses/ #
# #
# or in the "license" file accompanying this file. This file is distributed #
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, #
# express or implied. See the License for the specific language governing #
# permissions and limitations under the License. #
##############################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

import json

Expand Down
19 changes: 3 additions & 16 deletions source/anonymous_data_logger/anonymous_lib/metrics.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##############################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
# #
# Licensed under the Apache License Version 2.0 (the "License"). #
# You may not use this file except in compliance with the License. #
# A copy of the License is located at #
# #
# http://www.apache.org/licenses/ #
# #
# or in the "license" file accompanying this file. This file is distributed #
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, #
# express or implied. See the License for the specific language governing #
# permissions and limitations under the License. #
##############################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

import datetime
import json
Expand All @@ -30,6 +17,6 @@ def send_metrics(config):
url = "https://metrics.awssolutionsbuilder.com/generic"
data = json.dumps(metrics).encode("utf8")
headers = {"content-type": "application/json"}
req = requests.post(url, headers=headers, data=metrics, timeout=15)
req = requests.post(url, headers=headers, data=data, timeout=15)
print("RESPONSE CODE:: {}".format(req.text))
print("METRICS SENT:: {}".format(metrics))
2 changes: 2 additions & 0 deletions source/glue/library/city_normalizer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import re


Expand Down
2 changes: 2 additions & 0 deletions source/glue/library/default_normalizer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import re


Expand Down
2 changes: 2 additions & 0 deletions source/glue/library/email_normalizer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import re


Expand Down
2 changes: 2 additions & 0 deletions source/glue/library/phone_normalizer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import phonenumbers


Expand Down
2 changes: 2 additions & 0 deletions source/glue/library/read_write.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import json
import re
import sys
Expand Down
2 changes: 2 additions & 0 deletions source/glue/library/state_normalizer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import re

USStateAbbreviation = {
Expand Down
2 changes: 2 additions & 0 deletions source/glue/library/transform.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import hashlib

import pandas as pd
Expand Down
2 changes: 2 additions & 0 deletions source/glue/library/zip_normalizer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import re


Expand Down
4 changes: 2 additions & 2 deletions source/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-e amc_uploader
aws-xray-sdk==2.12.0
awswrangler==3.2.1
awswrangler==3.3.0
boto3==1.26.158
botocore==1.29.158
moto==4.1.2
moto==4.2.0
pandas==2.0.2
phonenumbers==8.13.14
pytest==7.3.2
Expand Down
4 changes: 2 additions & 2 deletions source/tests/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
aws-xray-sdk>=2.12.0
awswrangler==3.2.1
awswrangler==3.3.0
boto3==1.26.158
chalice==1.29.0
moto==4.1.11
moto==4.2.0
pyparsing==3.1.0
pytest==7.3.2
pytest-mock==3.11.1
Expand Down
51 changes: 37 additions & 14 deletions source/tests/unit_test/amc_uploader/test_amc_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

import json
from unittest.mock import MagicMock, patch

import os
import boto3
import pytest
from moto import mock_sts, mock_dynamodb

Expand All @@ -25,7 +26,7 @@ def test_configs():
+ "/etl_output_data.json-2022_01_06-09:01:00.gz",
"s3_fact_key2": "amc/dataset_id/PT1M/"
+ BASE64_ENCODED_AMC_ENDPOINT
+ "/filename",
+ "/invalid_filename",
"s3_fact_key3": "amc/dataset_id/P1D/"
+ BASE64_ENCODED_AMC_ENDPOINT
+ "/etl_output_data.json-2022_01_06-09:01:00.gz",
Expand Down Expand Up @@ -176,46 +177,68 @@ def test_start_fact_upload(
):
from amc_uploader.amc_uploader import _start_fact_upload

mock_session_response.mount = MagicMock()

mock_session_response.return_value.get.return_value = MagicMock(
status_code=200, text=json.dumps({"period": "PT1M_FAIL"})
)
mock_response_put.return_value = None # this is not called

# test invalid file names
# The following test exercises the logic for handling invalid filenames.
# Filenames should look like this, "etl_output_data.json-2022_01_06-09:01:00.gz"
data = _start_fact_upload(
test_configs["s3_bucket"], test_configs["s3_fact_key2"]
)
assert data["Status"] == "Error"
assert str(data["Message"]) == "list index out of range"

# Uploads are performed asynchronously by the amc_uploader.py Lambda function.
# That function is triggered by S3 when the Glue ETL job saves its results.
# If an upload fails, then amc_uploader.py saves the error message to DynamoDB
# so that the front-end can show the error message to the user.
#
# The following test exercises that logic by trying to upload a dataset with an
# invalid time period, called "PT1M_FAIL".
dynamodb = boto3.resource("dynamodb", region_name=os.environ["AWS_REGION"])
params = {
"TableName": os.environ["UPLOAD_FAILURES_TABLE_NAME"],
"KeySchema": [
{"AttributeName": "destination_endpoint", "KeyType": "HASH"},
{"AttributeName": "dataset_id", "KeyType": "RANGE"},
],
"AttributeDefinitions": [
{"AttributeName": "destination_endpoint", "AttributeType": "S"},
{"AttributeName": "dataset_id", "AttributeType": "S"},
],
"BillingMode": "PAY_PER_REQUEST",
}
dynamodb.create_table(**params)
mock_session_response.mount = MagicMock()
mock_session_response.return_value.get.return_value = MagicMock(
status_code=200, text=json.dumps({"period": "PT1M_FAIL"})
)
mock_response_put.return_value = MagicMock(
status_code=200, text=json.dumps("Looks good")
)

# test invalid dataset time period
data = _start_fact_upload(
test_configs["s3_bucket"], test_configs["s3_fact_key"]
)
assert data["Status"] == "Error"
assert str(data["Message"]) == "Failed to update dataset time period."

# The following test exercises the logic for uploading a valid dataset.
mock_session_response.return_value.get.return_value = MagicMock(
status_code=200, text=json.dumps({"period": "P1D"})
)
mock_response_put.return_value = None # this is not called

expected_data = {"upload": [{"some_upload": "data"}]}

mock_response_post.return_value = MagicMock(
status_code=200, text=json.dumps(expected_data)
)
assert expected_data == json.loads(
_start_fact_upload(
test_configs["s3_bucket"], test_configs["s3_fact_key3"]
)
)

# The following test exercises the logic for an AMC server error.
expected_data = {"message": "fake server error"}
mock_response_post.return_value = MagicMock(
status_code=500, text=json.dumps(expected_data)
)
assert expected_data == json.loads(
_start_fact_upload(
test_configs["s3_bucket"], test_configs["s3_fact_key3"]
Expand Down
2 changes: 1 addition & 1 deletion source/website/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amcufa",
"version": "2.1.0",
"version": "2.1.1",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
3 changes: 1 addition & 2 deletions source/website/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ SPDX-License-Identifier: Apache-2.0
</template>

<script>
import { Auth } from 'aws-amplify';
import { Hub } from 'aws-amplify';
import { Auth, Hub } from 'aws-amplify';
export default {
name: "Login",
Expand Down

0 comments on commit 3620443

Please sign in to comment.