├── source ├── tests │ ├── cdk_solution_helper │ │ ├── aws_lambda │ │ │ ├── python │ │ │ │ └── fixtures │ │ │ │ │ ├── hash_fixture │ │ │ │ │ ├── a │ │ │ │ │ │ └── z.txt │ │ │ │ │ ├── c.txt │ │ │ │ │ └── z │ │ │ │ │ │ └── a.txt │ │ │ │ │ ├── requirements.txt │ │ │ │ │ ├── Pipfile │ │ │ │ │ ├── pyproject.toml │ │ │ │ │ └── lambda │ │ │ │ │ └── package │ │ │ │ │ ├── minimal │ │ │ │ │ └── __init__.py │ │ │ │ │ └── setup.py │ │ │ ├── java │ │ │ │ └── fixtures │ │ │ │ │ └── java_sample │ │ │ │ │ ├── settings.gradle │ │ │ │ │ ├── gradle │ │ │ │ │ └── wrapper │ │ │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ │ │ └── gradle-wrapper.properties │ │ │ │ │ ├── src │ │ │ │ │ ├── main │ │ │ │ │ │ └── java │ │ │ │ │ │ │ └── example │ │ │ │ │ │ │ ├── Handler.java │ │ │ │ │ │ │ └── UserData.java │ │ │ │ │ └── test │ │ │ │ │ │ └── java │ │ │ │ │ │ └── example │ │ │ │ │ │ └── HandlerTest.java │ │ │ │ │ └── build.gradle │ │ │ └── cfn_custom_resources │ │ │ │ └── resource_hash │ │ │ │ └── test_resource_name_cdk.py │ │ ├── __init__.py │ │ ├── helpers │ │ │ └── test_logger.py │ │ ├── test_cfn_nag_suppressions.py │ │ └── test_mappings.py │ ├── fixtures │ │ └── config │ │ │ └── users.csv │ ├── __init__.py │ ├── aws_lambda │ │ ├── create_filter │ │ │ └── test_create_filter_handler.py │ │ ├── create_dataset │ │ │ └── test_dataset_handler.py │ │ ├── create_schema │ │ │ └── create_schema_handler.py │ │ ├── create_dataset_group │ │ │ └── test_dataset_group_handler.py │ │ ├── create_solution │ │ │ └── test_create_solution_handler.py │ │ ├── create_event_tracker │ │ │ └── test_create_event_tracker_handler.py │ │ ├── create_dataset_import_job │ │ │ └── test_dataset_import_job_handler.py │ │ ├── create_solution_version │ │ │ └── test_create_solution_version_handler.py │ │ └── create_batch_inference_job │ │ │ └── test_batch_inference_job_handler.py │ └── test_personalize_stack.py ├── cdk_solution_helper_py │ ├── helpers_cdk │ │ └── aws_solutions │ │ │ └── cdk │ │ │ ├── aws_lambda │ │ │ ├── cfn_custom_resources │ │ │ │ ├── resource_hash │ │ │ │ │ ├── src │ │ │ │ │ │ ├── custom_resources │ │ │ │ │ │ │ ├── requirements.txt │ │ │ │ │ │ │ └── __init__.py │ │ │ │ │ │ └── __init__.py │ │ │ │ │ └── __init__.py │ │ │ │ ├── resource_name │ │ │ │ │ ├── src │ │ │ │ │ │ ├── custom_resources │ │ │ │ │ │ │ ├── requirements.txt │ │ │ │ │ │ │ └── __init__.py │ │ │ │ │ │ └── __init__.py │ │ │ │ │ └── __init__.py │ │ │ │ ├── solutions_metrics │ │ │ │ │ ├── src │ │ │ │ │ │ ├── custom_resources │ │ │ │ │ │ │ ├── requirements.txt │ │ │ │ │ │ │ └── __init__.py │ │ │ │ │ │ └── __init__.py │ │ │ │ │ └── __init__.py │ │ │ │ └── __init__.py │ │ │ ├── layers │ │ │ │ ├── aws_lambda_powertools │ │ │ │ │ ├── requirements │ │ │ │ │ │ └── requirements.txt │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── layer.py │ │ │ │ └── __init__.py │ │ │ ├── __init__.py │ │ │ ├── java │ │ │ │ └── __init__.py │ │ │ ├── python │ │ │ │ └── __init__.py │ │ │ └── environment_variable.py │ │ │ ├── scripts │ │ │ └── __init__.py │ │ │ ├── stepfunctions │ │ │ └── __init__.py │ │ │ ├── tools │ │ │ └── __init__.py │ │ │ ├── helpers │ │ │ ├── __init__.py │ │ │ └── logger.py │ │ │ ├── aspects.py │ │ │ └── __init__.py │ ├── requirements-dev.txt │ ├── CHANGELOG.md │ └── helpers_common │ │ └── aws_solutions │ │ └── core │ │ └── __init__.py ├── images │ └── solution-architecture.jpg ├── .coveragerc ├── infrastructure │ ├── personalize │ │ ├── aws_lambda │ │ │ ├── layers │ │ │ │ ├── aws_solutions │ │ │ │ │ ├── requirements │ │ │ │ │ │ └── requirements.txt │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── layer.py │ │ │ │ └── __init__.py │ │ │ ├── __init__.py │ │ │ └── functions │ │ │ │ ├── create_timestamp.py │ │ │ │ ├── prepare_input.py │ │ │ │ └── create_scheduled_task.py │ │ ├── __init__.py │ │ ├── sns │ │ │ └── __init__.py │ │ ├── cloudwatch │ │ │ └── __init__.py │ │ ├── step_functions │ │ │ ├── __init__.py │ │ │ ├── schedules.py │ │ │ └── dataset_imports_fragment.py │ │ └── s3 │ │ │ ├── data_bucket.py │ │ │ ├── __init__.py │ │ │ └── access_logs_bucket.py │ ├── cdk.json │ ├── __init__.py │ └── deploy.py ├── scheduler │ ├── cdk │ │ └── aws_solutions │ │ │ └── scheduler │ │ │ └── cdk │ │ │ ├── aws_lambda │ │ │ ├── scheduler │ │ │ │ ├── requirements.txt │ │ │ │ ├── __init__.py │ │ │ │ └── handler.py │ │ │ ├── get_next_scheduled_event │ │ │ │ ├── gradle │ │ │ │ │ └── wrapper │ │ │ │ │ │ ├── gradle-wrapper.properties │ │ │ │ │ │ └── gradle-wrapper.jar │ │ │ │ ├── settings.gradle │ │ │ │ ├── src │ │ │ │ │ ├── main │ │ │ │ │ │ └── java │ │ │ │ │ │ │ └── com │ │ │ │ │ │ │ └── amazonaws │ │ │ │ │ │ │ └── solutions │ │ │ │ │ │ │ └── schedule_sfn_task │ │ │ │ │ │ │ ├── ScheduleException.java │ │ │ │ │ │ │ ├── ScheduleEvent.java │ │ │ │ │ │ │ └── HandleScheduleEvent.java │ │ │ │ │ └── test │ │ │ │ │ │ └── java │ │ │ │ │ │ └── com │ │ │ │ │ │ └── amazonaws │ │ │ │ │ │ └── solutions │ │ │ │ │ │ └── schedule_sfn_task │ │ │ │ │ │ └── HandleScheduleEventTest.java │ │ │ │ └── build.gradle │ │ │ └── __init__.py │ │ │ └── __init__.py │ ├── CHANGELOG.md │ └── common │ │ └── aws_solutions │ │ └── scheduler │ │ └── common │ │ ├── scripts │ │ └── __init__.py │ │ ├── __init__.py │ │ └── task_resource.py ├── requirements-dev.txt ├── pytest.ini └── aws_lambda │ ├── __init__.py │ ├── s3_event │ └── __init__.py │ ├── shared │ ├── __init__.py │ ├── personalize │ │ └── __init__.py │ ├── notifiers │ │ └── __init__.py │ ├── resource │ │ ├── schema.py │ │ ├── filter.py │ │ ├── campaign.py │ │ ├── event_tracker.py │ │ ├── batch_inference_job.py │ │ ├── dataset_import_job.py │ │ ├── solution_version.py │ │ ├── dataset.py │ │ ├── solution.py │ │ ├── dataset_group.py │ │ └── base.py │ ├── exceptions.py │ └── date_helpers.py │ ├── create_campaign │ └── __init__.py │ ├── create_config │ ├── __init__.py │ └── handler.py │ ├── create_dataset │ └── __init__.py │ ├── create_filter │ └── __init__.py │ ├── create_schema │ ├── __init__.py │ └── handler.py │ ├── create_solution │ └── __init__.py │ ├── prepare_input │ ├── __init__.py │ └── handler.py │ ├── create_dataset_group │ └── __init__.py │ ├── create_event_tracker │ └── __init__.py │ ├── create_timestamp │ ├── __init__.py │ └── handler.py │ ├── sns_notification │ └── __init__.py │ ├── create_dataset_import_job │ └── __init__.py │ ├── create_solution_version │ └── __init__.py │ └── create_batch_inference_job │ └── __init__.py ├── .github ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── CODE_OF_CONDUCT.md ├── CHANGELOG.md ├── .gitignore └── NOTICE.txt /source/tests/cdk_solution_helper/aws_lambda/python/fixtures/hash_fixture/a/z.txt: -------------------------------------------------------------------------------- 1 | a -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/python/fixtures/hash_fixture/c.txt: -------------------------------------------------------------------------------- 1 | c -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/python/fixtures/hash_fixture/z/a.txt: -------------------------------------------------------------------------------- 1 | z -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/python/fixtures/requirements.txt: -------------------------------------------------------------------------------- 1 | ./package -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/python/fixtures/Pipfile: -------------------------------------------------------------------------------- 1 | [packages] 2 | minimal = {path = "./package"} -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/java/fixtures/java_sample/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'java_sample' 2 | 3 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/resource_hash/src/custom_resources/requirements.txt: -------------------------------------------------------------------------------- 1 | crhelper==2.0.6 -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/resource_name/src/custom_resources/requirements.txt: -------------------------------------------------------------------------------- 1 | crhelper==2.0.6 -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/layers/aws_lambda_powertools/requirements/requirements.txt: -------------------------------------------------------------------------------- 1 | aws-lambda-powertools==1.15.0 -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/solutions_metrics/src/custom_resources/requirements.txt: -------------------------------------------------------------------------------- 1 | requests==2.24.0 2 | crhelper==2.0.6 -------------------------------------------------------------------------------- /source/images/solution-architecture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/My-Machine-Learning-Projects-CT/maintaining-personalized-experiences-with-machine-learning/main/source/images/solution-architecture.jpg -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. 6 | -------------------------------------------------------------------------------- /source/.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | omit = 3 | infrastructure/setup.py 4 | infrastructure/cdk.out/* 5 | tests/* 6 | source = 7 | infrastructure 8 | aws_lambda 9 | cdk_solution_helper_py 10 | scheduler 11 | 12 | [report] 13 | fail_under = 80.0 -------------------------------------------------------------------------------- /source/infrastructure/personalize/aws_lambda/layers/aws_solutions/requirements/requirements.txt: -------------------------------------------------------------------------------- 1 | ../../../../../../cdk_solution_helper_py/helpers_common 2 | ../../../../../../scheduler/common 3 | avro==1.10.2 4 | cronex==0.1.3.1 5 | jmespath==0.10.0 6 | parsedatetime==2.6 -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/scheduler/requirements.txt: -------------------------------------------------------------------------------- 1 | avro==1.10.2 2 | cronex==0.1.3.1 3 | jmespath==0.10.0 4 | parsedatetime==2.6 5 | ../../../../../../../scheduler/common 6 | ../../../../../../../cdk_solution_helper_py/helpers_common 7 | -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/java/fixtures/java_sample/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/My-Machine-Learning-Projects-CT/maintaining-personalized-experiences-with-machine-learning/main/source/tests/cdk_solution_helper/aws_lambda/java/fixtures/java_sample/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/java/fixtures/java_sample/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/requirements-dev.txt: -------------------------------------------------------------------------------- 1 | aws-cdk.core>=1.126.0 2 | aws-cdk.aws_lambda>=1.126.0 3 | black 4 | boto3>=1.17.49 5 | requests>=2.24.0 6 | crhelper>=2.0.6 7 | Click 8 | moto 9 | pipenv 10 | poetry 11 | pytest 12 | pytest-cov>=2.11.1 13 | pytest-mock>=3.5.1 14 | tox 15 | tox-pyenv 16 | -e helpers_cdk 17 | -e helpers_common -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/My-Machine-Learning-Projects-CT/maintaining-personalized-experiences-with-machine-learning/main/source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /source/tests/fixtures/config/users.csv: -------------------------------------------------------------------------------- 1 | USER_ID,AGE,GENDER 2 | 0,71,F 3 | 1,67,M 4 | 2,25,F 5 | 3,70,F 6 | 4,28,F 7 | 5,34,F 8 | 6,66,F 9 | 7,74,F 10 | 8,79,F 11 | 9,57,M 12 | 10,58,M 13 | 11,18,M 14 | 12,88,M 15 | 13,73,F 16 | 14,77,F 17 | 15,23,F 18 | 16,85,M 19 | 17,31,M 20 | 18,48,M 21 | 19,44,M 22 | 20,24,F 23 | 21,63,M 24 | 22,66,F 25 | 23,21,F 26 | 24,81,M 27 | -------------------------------------------------------------------------------- /source/scheduler/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [1.1.0] - 2021-11-11 8 | ### Added 9 | - initial release 10 | 11 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [1.0.0] - 2021-09-23 8 | ### Added 9 | - initial release 10 | 11 | -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/python/fixtures/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "python-bundling" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["AWS Solutions Builders"] 6 | 7 | [tool.poetry.dependencies] 8 | python = "^3.7" 9 | minimal = {path = "package"} 10 | 11 | [tool.poetry.dev-dependencies] 12 | 13 | [build-system] 14 | requires = ["poetry-core>=1.0.0"] 15 | build-backend = "poetry.core.masonry.api" -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/java/fixtures/java_sample/src/main/java/example/Handler.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import com.amazonaws.services.lambda.runtime.Context; 4 | import com.amazonaws.services.lambda.runtime.RequestHandler; 5 | 6 | public class Handler implements RequestHandler { 7 | 8 | @Override 9 | public UserData handleRequest(UserData input, Context context) { 10 | UserData output = input; 11 | output.setGreeting("Hello there " + input.getName()); 12 | return output; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this solution 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the feature you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /source/requirements-dev.txt: -------------------------------------------------------------------------------- 1 | avro==1.10.2 2 | black 3 | boto3 4 | aws_cdk.core==1.126.0 5 | aws_cdk.aws_stepfunctions_tasks==1.126.0 6 | aws_solutions_constructs.aws_lambda_sns==1.126.0 7 | requests==2.24.0 8 | crhelper==2.0.6 9 | cronex==0.1.3.1 10 | moto==2.0.8 11 | parsedatetime==2.6 12 | pytest 13 | pytest-cov>=2.11.1 14 | pytest-env>=0.6.2 15 | pytest-mock>=3.5.1 16 | pyyaml==5.4.1 17 | responses==0.14.0 18 | tenacity>=8.0.1 19 | -e cdk_solution_helper_py/helpers_cdk 20 | -e cdk_solution_helper_py/helpers_common 21 | -e scheduler/cdk 22 | -e scheduler/common 23 | aws-lambda-powertools>=1.15.0 24 | docker==5.0.0 25 | -e infrastructure -------------------------------------------------------------------------------- /source/infrastructure/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "python3 deploy.py", 3 | "context": { 4 | "SOLUTION_NAME": "Maintaining Personalized Experiences with Machine Learning", 5 | "SOLUTION_ID": "SO0170", 6 | "SOLUTION_VERSION": "v1.1.0", 7 | "@aws-cdk/core:newStyleStackSynthesis": "true", 8 | "@aws-cdk/core:enableStackNameDuplicates": "true", 9 | "aws-cdk:enableDiffNoFail": "true", 10 | "@aws-cdk/core:stackRelativeExports": "true", 11 | "@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true, 12 | "@aws-cdk/aws-secretsmanager:parseOwnedSecretName": true, 13 | "@aws-cdk/aws-kms:defaultKeyPolicies": true, 14 | "@aws-cdk/aws-s3:grantWriteWithoutAcl": true 15 | } 16 | } -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/java/fixtures/java_sample/src/test/java/example/HandlerTest.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import org.junit.jupiter.api.BeforeEach; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.*; 7 | 8 | class HandlerTest { 9 | Handler handler; 10 | UserData userData; 11 | 12 | @BeforeEach 13 | void setUp() { 14 | handler = new Handler(); 15 | userData = new UserData("AWS Solutions"); 16 | } 17 | 18 | @Test 19 | void handleRequest() { 20 | UserData result = this.handler.handleRequest(userData, null); 21 | assert result.getGreeting().equals("Hello there AWS Solutions"); 22 | } 23 | } -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/java/fixtures/java_sample/src/main/java/example/UserData.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class UserData { 4 | public UserData() { 5 | } 6 | 7 | public UserData(String name) { 8 | this.name = name; 9 | } 10 | 11 | public String getName() { 12 | return name; 13 | } 14 | 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | 19 | private String name = ""; 20 | 21 | public String getGreeting() { 22 | return greeting; 23 | } 24 | 25 | public void setGreeting(String greeting) { 26 | this.greeting = greeting; 27 | } 28 | 29 | private String greeting = ""; 30 | } 31 | -------------------------------------------------------------------------------- /source/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | env = 3 | MOTO_ACCOUNT_ID=111111111111 4 | POWERTOOLS_TRACE_DISABLED=1 5 | SOLUTION_ID=SO0170test 6 | SOLUTION_VERSION=v99.99.99 7 | SOLUTION_NAME=Maintaining Personalized Experiences with Machine Learning 8 | AWS_REGION=us-east-1 9 | AWS_DEFAULT_REGION=us-east-1 10 | DDB_SCHEDULES_TABLE=scheduler 11 | DDB_SCHEDULER_STEPFUNCTION=arn:aws:states:us-east-1:111111111111:stateMachine:personalizestack-personalize-scheduler 12 | POWERTOOLS_SERVICE_NAME=personalize_solution_teststack 13 | POWERTOOLS_METRICS_NAMESPACE=personalize_solution_teststack 14 | norecursedirs = cdk.out* 15 | markers= 16 | no_cdk_lambda_mock: marks test that need to build AWS Lambda Functions or Layers with CDK -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for 11 | * the specific language governing permissions and limitations under the License. 12 | */ 13 | 14 | rootProject.name = 'sfn-schedule-task' -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/src/main/java/com/amazonaws/solutions/schedule_sfn_task/ScheduleException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for 11 | * the specific language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.amazonaws.solutions.schedule_sfn_task; 15 | 16 | public class ScheduleException extends RuntimeException { 17 | public ScheduleException(String message) { 18 | super(message); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [1.1.0] - 2021-11-22 8 | ### Added 9 | - The solution now creates an Amazon EventBridge event bus, and puts messages to the bus when resources have been 10 | created by the workflow. This can be useful when integrating with external systems. 11 | - The solution now contains a command line interface (CLI) that allows schedule creation for existing resources in 12 | Amazon Personalize. 13 | 14 | ## [1.0.1] - 2021-10-01 15 | ### Added 16 | - The solution now exports the Amazon SNS Topic ARN as `SNSTopicArn`. 17 | 18 | ### Changed 19 | - The SNS message format will change based on the protocol used. For Amazon SQS and Email-JSON endpoints, a JSON payload 20 | will be sent. The message sent to subscribed Email endpoints is unchanged. 21 | - The Amazon CloudWatch dashboard deployed by the solution will be replaced with a dashboard containing the stack's 22 | region name. 23 | 24 | ## [1.0.0] - 2021-09-23 25 | ### Added 26 | - All files, initial version 27 | -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/java/fixtures/java_sample/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | } 8 | 9 | dependencies { 10 | implementation 'com.amazonaws:aws-lambda-java-core:1.2.1' 11 | implementation 'com.amazonaws:aws-lambda-java-events:3.1.0' 12 | runtimeOnly 'com.amazonaws:aws-lambda-java-log4j2:1.2.0' 13 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' 14 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0' 15 | } 16 | 17 | test { 18 | useJUnitPlatform() 19 | } 20 | 21 | task packageFat(type: Zip) { 22 | from compileJava 23 | from processResources 24 | into('lib') { 25 | from configurations.runtimeClasspath 26 | } 27 | dirMode = 0755 28 | fileMode = 0755 29 | } 30 | 31 | task packageLibs(type: Zip) { 32 | into('java/lib') { 33 | from configurations.runtimeClasspath 34 | } 35 | dirMode = 0755 36 | fileMode = 0755 37 | } 38 | 39 | task packageSkinny(type: Zip) { 40 | from compileJava 41 | from processResources 42 | } 43 | 44 | java { 45 | sourceCompatibility = JavaVersion.VERSION_11 46 | targetCompatibility = JavaVersion.VERSION_11 47 | } 48 | 49 | build.dependsOn packageSkinny -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Please complete the following information about the solution:** 20 | - [ ] Version: [e.g. v0.0.1] 21 | 22 | To get the version of the solution, you can look at the description of the created CloudFormation stack. For example, "(SO0170) Maintaining Personalized Experiences with Machine Learning [...]". 23 | 24 | - [ ] Region: [e.g. us-east-1] 25 | - [ ] Was the solution modified from the version published on this repository? 26 | - [ ] If the answer to the previous question was yes, are the changes available on GitHub? 27 | - [ ] Have you checked your [service quotas](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html) for the sevices this solution uses? 28 | - [ ] Were there any errors in the CloudWatch Logs? 29 | 30 | **Screenshots** 31 | If applicable, add screenshots to help explain your problem (please **DO NOT include sensitive information**). 32 | 33 | **Additional context** 34 | Add any other context about the problem here. 35 | -------------------------------------------------------------------------------- /source/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/infrastructure/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/s3_event/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_campaign/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_config/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_dataset/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_filter/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_schema/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_solution/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/prepare_input/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_dataset_group/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_event_tracker/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_timestamp/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/personalize/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/sns_notification/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/sns/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_dataset_import_job/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_solution_version/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/create_batch_inference_job/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/aws_lambda/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/cloudwatch/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/step_functions/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/scripts/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/java/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/scheduler/common/aws_solutions/scheduler/common/scripts/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/python/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/aws_lambda/layers/aws_solutions/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/stepfunctions/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/scheduler/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/layers/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Modified based on https://www.gitignore.io/api/visualstudiocode,python 2 | 3 | # compiled output 4 | **/global-s3-assets 5 | **/regional-s3-assets 6 | **/build-s3-assets 7 | **/open-source 8 | **/tmp 9 | 10 | ### Python ### 11 | # Byte-compiled / optimized / DLL files 12 | __pycache__/ 13 | *.py[cod] 14 | *$py.class 15 | 16 | # Python Distribution / packaging 17 | *.egg-info/ 18 | *.egg 19 | 20 | # Python Virtual Environments 21 | **/venv* 22 | **/.venv* 23 | .python-version 24 | 25 | ## Python Testing 26 | **/.pytest_cache 27 | **/.coverage 28 | **/coverage-reports/ 29 | 30 | # linting, scanning configurations, sonarqube 31 | .scannerwork/ 32 | 33 | ### VisualStudioCode ### 34 | .vscode/* 35 | 36 | ### IntelliJ/ PyCharm ### 37 | **/.idea/* 38 | 39 | # System Files 40 | **/.DS_Store 41 | 42 | # CDK 43 | **/cdk.out 44 | 45 | # Glue 46 | .glue/* 47 | 48 | # Generated test assets 49 | source/infrastructure/tests/assets/* 50 | !source/infrastructure/tests/assets/.keep 51 | source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/build 52 | source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/.gradle 53 | source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/.idea 54 | 55 | # gradle build files 56 | **/.gradle/* 57 | 58 | # java build files 59 | **/java/**/build 60 | 61 | # python build files 62 | source/cdk_solution_helper_py/helpers_cdk/build/* 63 | source/cdk_solution_helper_py/helpers_common/build/* 64 | source/scheduler/common/build/* 65 | source/scheduler/cdk/build/* -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/resource_hash/src/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/resource_name/src/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/solutions_metrics/src/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/notifiers/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from shared.notifiers.notify_eventbridge import NotifyEventBridge 15 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/resource_hash/src/custom_resources/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/resource_name/src/custom_resources/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/solutions_metrics/src/custom_resources/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/tools/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | from aws_solutions.cdk.tools.cleaner import Cleaner 15 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/resource/schema.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from shared.resource import Resource 14 | 15 | 16 | class Schema(Resource): 17 | pass 18 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/resource/filter.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from shared.resource.base import Resource 14 | 15 | 16 | class Filter(Resource): 17 | pass 18 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/resource/campaign.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from shared.resource.base import Resource 14 | 15 | 16 | class Campaign(Resource): 17 | pass 18 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | from aws_solutions.cdk.helpers.copytree import copytree, ignore_globs 15 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/aws_lambda/layers/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from personalize.aws_lambda.layers.aws_solutions.layer import SolutionsLayer 15 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/resource/event_tracker.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from shared.resource.base import Resource 14 | 15 | 16 | class EventTracker(Resource): 17 | pass 18 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/resource/batch_inference_job.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from shared.resource.base import Resource 14 | 15 | 16 | class BatchInferenceJob(Resource): 17 | pass 18 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/s3/data_bucket.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from personalize.s3.utils import SecureBucket 15 | 16 | 17 | class DataBucket(SecureBucket): 18 | pass 19 | -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/python/fixtures/lambda/package/minimal/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | 15 | def function_in_package(): 16 | return "hello from function_in_package" 17 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/s3/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from personalize.s3.access_logs_bucket import AccessLogsBucket 15 | from personalize.s3.data_bucket import DataBucket 16 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/resource/dataset_import_job.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from shared.resource.base import Resource 14 | 15 | 16 | class DatasetImportJob(Resource): 17 | has_soft_limit = True 18 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/s3/access_logs_bucket.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from personalize.s3.utils import SecureBucket 15 | 16 | 17 | class AccessLogsBucket(SecureBucket): 18 | pass 19 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/resource_hash/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | from aws_solutions.cdk.aws_lambda.cfn_custom_resources.resource_hash.hash import ( 15 | ResourceHash, 16 | ) 17 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/resource_name/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | from aws_solutions.cdk.aws_lambda.cfn_custom_resources.resource_name.name import ( 15 | ResourceName, 16 | ) 17 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/cfn_custom_resources/solutions_metrics/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | from aws_solutions.cdk.aws_lambda.cfn_custom_resources.solutions_metrics.metrics import ( 15 | Metrics, 16 | ) 17 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/layers/aws_lambda_powertools/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from aws_solutions.cdk.aws_lambda.layers.aws_lambda_powertools.layer import ( 15 | PowertoolsLayer, 16 | ) 17 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/step_functions/schedules.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from dataclasses import dataclass 15 | 16 | from aws_cdk.aws_stepfunctions import StateMachineFragment 17 | 18 | 19 | @dataclass 20 | class Schedules: 21 | dataset_import: StateMachineFragment 22 | -------------------------------------------------------------------------------- /source/tests/aws_lambda/create_filter/test_create_filter_handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import pytest 15 | 16 | from aws_lambda.create_filter.handler import lambda_handler 17 | 18 | 19 | def test_create_filter(): 20 | with pytest.raises(ValueError): 21 | lambda_handler({}, None) 22 | -------------------------------------------------------------------------------- /source/tests/aws_lambda/create_dataset/test_dataset_handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import pytest 15 | 16 | from aws_lambda.create_dataset.handler import lambda_handler 17 | 18 | 19 | def test_create_dataset_handler(): 20 | with pytest.raises(ValueError): 21 | lambda_handler({}, None) 22 | -------------------------------------------------------------------------------- /source/tests/aws_lambda/create_schema/create_schema_handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import pytest 15 | 16 | from aws_lambda.create_schema.handler import lambda_handler 17 | 18 | 19 | def test_create_schema_handler(): 20 | with pytest.raises(ValueError): 21 | lambda_handler({}, None) 22 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/resource/solution_version.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from shared.resource.base import Resource 14 | from shared.resource.batch_inference_job import BatchInferenceJob 15 | 16 | 17 | class SolutionVersion(Resource): 18 | children = [BatchInferenceJob()] 19 | has_soft_limit = True 20 | -------------------------------------------------------------------------------- /source/tests/aws_lambda/create_dataset_group/test_dataset_group_handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import pytest 15 | 16 | from aws_lambda.create_dataset_group.handler import lambda_handler 17 | 18 | 19 | def test_handler(): 20 | with pytest.raises(ValueError): 21 | lambda_handler({}, None) 22 | -------------------------------------------------------------------------------- /source/tests/aws_lambda/create_solution/test_create_solution_handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import pytest 15 | 16 | from aws_lambda.create_solution.handler import lambda_handler 17 | 18 | 19 | def test_create_solution(): 20 | with pytest.raises(ValueError): 21 | lambda_handler({}, None) 22 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/resource/dataset.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from shared.resource.base import Resource 14 | from shared.resource.dataset_import_job import DatasetImportJob 15 | 16 | 17 | class Dataset(Resource): 18 | children = [DatasetImportJob()] 19 | allowed_types = {"INTERACTIONS", "ITEMS", "USERS"} 20 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/resource/solution.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from shared.resource.base import Resource 14 | from shared.resource.campaign import Campaign 15 | from shared.resource.solution_version import SolutionVersion 16 | 17 | 18 | class Solution(Resource): 19 | children = [Campaign(), SolutionVersion()] 20 | -------------------------------------------------------------------------------- /source/tests/aws_lambda/create_event_tracker/test_create_event_tracker_handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import pytest 15 | 16 | from aws_lambda.create_event_tracker.handler import lambda_handler 17 | 18 | 19 | def test_create_event_tracker(): 20 | with pytest.raises(ValueError): 21 | lambda_handler({}, None) 22 | -------------------------------------------------------------------------------- /source/tests/aws_lambda/create_dataset_import_job/test_dataset_import_job_handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import pytest 15 | 16 | from aws_lambda.create_dataset_import_job.handler import lambda_handler 17 | 18 | 19 | def test_create_dataset_import_job_handler(): 20 | with pytest.raises(ValueError): 21 | lambda_handler({}, None) 22 | -------------------------------------------------------------------------------- /source/tests/aws_lambda/create_solution_version/test_create_solution_version_handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import pytest 15 | 16 | from aws_lambda.create_solution_version.handler import lambda_handler 17 | 18 | 19 | def test_create_solution_version_handler(): 20 | with pytest.raises(ValueError): 21 | lambda_handler({}, None) 22 | -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/python/fixtures/lambda/package/setup.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | from setuptools import setup 15 | 16 | setup( 17 | name="minimal", 18 | version="0.1", 19 | description="a small package for testing", 20 | author="AWS Solutions Builders", 21 | packages=["minimal"], 22 | zip_safe=True, 23 | ) 24 | -------------------------------------------------------------------------------- /source/tests/aws_lambda/create_batch_inference_job/test_batch_inference_job_handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import pytest 15 | 16 | from aws_lambda.create_batch_inference_job.handler import lambda_handler 17 | 18 | 19 | def test_create_batch_inference_job_handler(): 20 | with pytest.raises(ValueError): 21 | lambda_handler({}, None) 22 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_common/aws_solutions/core/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | from aws_solutions.core.config import Config 15 | 16 | config = Config() 17 | 18 | from aws_solutions.core.helpers import ( 19 | get_aws_region, 20 | get_aws_partition, 21 | get_service_client, 22 | get_service_resource, 23 | get_aws_account, 24 | ) 25 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/resource/dataset_group.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from shared.resource.base import Resource 14 | from shared.resource.dataset import Dataset 15 | from shared.resource.event_tracker import EventTracker 16 | from shared.resource.filter import Filter 17 | from shared.resource.solution import Solution 18 | 19 | 20 | class DatasetGroup(Resource): 21 | children = [Dataset(), Filter(), Solution(), EventTracker()] 22 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/exceptions.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | 15 | class ResourcePending(Exception): 16 | pass 17 | 18 | 19 | class SolutionVersionPending(Exception): 20 | pass 21 | 22 | 23 | class ResourceFailed(Exception): 24 | pass 25 | 26 | 27 | class ResourceInvalid(Exception): 28 | pass 29 | 30 | 31 | class ResourceNeedsUpdate(Exception): 32 | pass 33 | 34 | 35 | class NotificationError(Exception): 36 | pass 37 | -------------------------------------------------------------------------------- /source/scheduler/common/aws_solutions/scheduler/common/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | TASK_PK = "name" 15 | TASK_SK = "version" 16 | CRON_ANY_WILDCARD = "?" 17 | CRON_MIN_MAX_YEAR = (1970, 2199) 18 | 19 | 20 | from aws_solutions.scheduler.common.base import Scheduler 21 | from aws_solutions.scheduler.common.schedule import Schedule, ScheduleError 22 | from aws_solutions.scheduler.common.task import Task 23 | from aws_solutions.scheduler.common.task_resource import TaskResource 24 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/step_functions/dataset_imports_fragment.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from aws_cdk.aws_stepfunctions import ( 4 | StateMachineFragment, 5 | Chain, 6 | Parallel, 7 | JsonPath, 8 | State, 9 | INextable, 10 | ) 11 | from aws_cdk.core import Construct 12 | 13 | from personalize.aws_lambda.functions import ( 14 | CreateSchema, 15 | CreateDataset, 16 | CreateDatasetImportJob, 17 | ) 18 | from personalize.step_functions.dataset_import_fragment import DatasetImportFragment 19 | 20 | 21 | class DatasetImportsFragment(StateMachineFragment): 22 | def __init__( 23 | self, 24 | scope: Construct, 25 | construct_id: str, 26 | create_schema: CreateSchema, 27 | create_dataset: CreateDataset, 28 | create_dataset_import_job: CreateDatasetImportJob, 29 | ): 30 | super().__init__(scope, construct_id) 31 | 32 | dataset_management_functions = { 33 | "create_schema": create_schema, 34 | "create_dataset": create_dataset, 35 | "create_dataset_import_job": create_dataset_import_job, 36 | } 37 | 38 | self.chain = Chain.start( 39 | Parallel(self, "Create and Import Datasets", result_path=JsonPath.DISCARD) 40 | .branch( 41 | DatasetImportFragment( 42 | self, "Interactions", **dataset_management_functions 43 | ) 44 | ) 45 | .branch( 46 | DatasetImportFragment(self, "Users", **dataset_management_functions) 47 | ) 48 | .branch( 49 | DatasetImportFragment(self, "Items", **dataset_management_functions) 50 | ) 51 | ) 52 | 53 | @property 54 | def start_state(self) -> State: 55 | return self.chain.start_state 56 | 57 | @property 58 | def end_states(self) -> List[INextable]: 59 | return self.chain.end_states 60 | -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/__init__.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from aws_solutions.scheduler.cdk.aws_lambda.create_scheduled_task import ( 15 | CreateScheduledTask, 16 | ) 17 | from aws_solutions.scheduler.cdk.aws_lambda.delete_scheduled_task import ( 18 | DeleteScheduledTask, 19 | ) 20 | from aws_solutions.scheduler.cdk.aws_lambda.read_scheduled_task import ReadScheduledTask 21 | from aws_solutions.scheduler.cdk.aws_lambda.update_scheduled_task import ( 22 | UpdateScheduledTask, 23 | ) 24 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/environment_variable.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from dataclasses import dataclass, field 15 | 16 | from aws_cdk.aws_lambda import IFunction 17 | 18 | 19 | @dataclass 20 | class EnvironmentVariable: 21 | scope: IFunction 22 | name: str 23 | value: str = field(default="") 24 | 25 | def __post_init__(self): 26 | if not self.value: 27 | self.value = self.scope.node.try_get_context(self.name) 28 | self.scope.add_environment(self.name, self.value) 29 | 30 | def __str__(self): 31 | return self.value 32 | -------------------------------------------------------------------------------- /source/tests/test_personalize_stack.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import aws_cdk.core as cdk 15 | 16 | from infrastructure.personalize.stack import PersonalizeStack 17 | 18 | 19 | def test_personalize_stack_email(solution): 20 | app = cdk.App(context=solution.context) 21 | PersonalizeStack( 22 | app, 23 | "PersonalizeStack", 24 | description="meta-stack", 25 | template_filename="maintaining-personalized-experiences-with-machine-learning.template", 26 | ) 27 | synth = app.synth() 28 | 29 | # ensure the email parameter is present 30 | assert synth.get_stack("PersonalizeStack").template["Parameters"]["Email"] 31 | -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/helpers/test_logger.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | import logging 15 | 16 | from aws_solutions.cdk.helpers.logger import Logger 17 | 18 | 19 | def test_logger(caplog): 20 | logger = Logger.get_logger("test-logger") 21 | logger.propagate = True # for test 22 | 23 | assert logger.level == logging.INFO 24 | 25 | with caplog.at_level(logging.INFO): 26 | logger.critical("CRITICAL") 27 | logger.error("ERROR") 28 | logger.warning("WARNING") 29 | logger.info("INFO") 30 | logging.debug("DEBUG") 31 | 32 | for level in "CRITICAL ERROR WARNING INFO".split(" "): 33 | assert level in caplog.text 34 | -------------------------------------------------------------------------------- /source/aws_lambda/create_timestamp/handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import datetime 15 | from typing import Dict, Any 16 | 17 | from aws_lambda_powertools import Logger, Tracer 18 | from aws_lambda_powertools.utilities.typing import LambdaContext 19 | 20 | logger = Logger() 21 | tracer = Tracer() 22 | 23 | 24 | @tracer.capture_lambda_handler 25 | def lambda_handler(event: Dict[str, Any], context: LambdaContext) -> str: 26 | """Create a timestamp matching YYYY_mm_dd_HH_MM_SS 27 | :param event: AWS Lambda Event 28 | :param context: AWS Lambda Context 29 | :return: the timestamp (string) 30 | """ 31 | return datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S") 32 | -------------------------------------------------------------------------------- /source/aws_lambda/prepare_input/handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from typing import Dict, Any 15 | 16 | from aws_lambda_powertools import Logger, Tracer, Metrics 17 | from aws_lambda_powertools.utilities.typing import LambdaContext 18 | 19 | from shared.sfn_middleware import set_workflow_config 20 | 21 | logger = Logger() 22 | tracer = Tracer() 23 | metrics = Metrics() 24 | 25 | 26 | def lambda_handler(event: Dict[str, Any], context: LambdaContext) -> Dict: 27 | """Add timeStarted to the workflowConfig of all items 28 | :param event: AWS Lambda Event 29 | :param context: AWS Lambda Context 30 | :return: the modified input 31 | """ 32 | config = set_workflow_config(event) 33 | return config 34 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aspects.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | import jsii 14 | from aws_cdk.core import CfnCondition, IAspect, IConstruct 15 | 16 | 17 | @jsii.implements(IAspect) 18 | class ConditionalResources: 19 | """Mark any CDK construct as conditional (this is useful to apply to stacks and L2+ constructs)""" 20 | 21 | def __init__(self, condition: CfnCondition): 22 | self.condition = condition 23 | 24 | def visit(self, node: IConstruct): 25 | if "is_cfn_element" in dir(node) and node.is_cfn_element(node): 26 | node.cfn_options.condition = self.condition 27 | elif "is_cfn_element" in dir(node.node.default_child): 28 | node.node.default_child.cfn_options.condition = self.condition 29 | -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for 11 | * the specific language governing permissions and limitations under the License. 12 | */ 13 | 14 | plugins { 15 | id 'java' 16 | id 'jacoco' 17 | id 'org.sonarqube' version '3.3' 18 | } 19 | 20 | group 'com.amazonaws.solutions' 21 | version '1.0-SNAPSHOT' 22 | 23 | repositories { 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' 29 | testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.0' 30 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0' 31 | implementation 'com.amazonaws:aws-lambda-java-core:1.2.1' 32 | implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.1000') 33 | implementation 'org.quartz-scheduler:quartz:2.3.2' 34 | } 35 | 36 | java { 37 | sourceCompatibility = JavaVersion.VERSION_11 38 | targetCompatibility = JavaVersion.VERSION_11 39 | } 40 | 41 | jacocoTestReport { 42 | reports { 43 | xml.enabled true 44 | csv.enabled false 45 | html.enabled false 46 | } 47 | } 48 | 49 | test { 50 | useJUnitPlatform() 51 | } 52 | test.finalizedBy jacocoTestReport 53 | 54 | sonarqube { 55 | properties { 56 | property "sonar.sourceEncoding", "UTF-8" 57 | } 58 | } 59 | 60 | tasks.named('sonarqube').configure { 61 | dependsOn test 62 | } 63 | 64 | task buildZip(type: Zip) { 65 | from compileJava 66 | from processResources 67 | into('lib') { 68 | from configurations.runtimeClasspath 69 | } 70 | } 71 | 72 | build.dependsOn buildZip -------------------------------------------------------------------------------- /source/aws_lambda/shared/date_helpers.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import datetime 15 | 16 | import parsedatetime as pdt 17 | from aws_lambda_powertools import Logger 18 | 19 | logger = Logger() 20 | 21 | 22 | def parse_datetime(tm: str) -> int: 23 | if "month" in tm: 24 | logger.warning( 25 | "while months are supported, they are based off of the calendar of the start of year 1 CE" 26 | ) 27 | if "year" in tm: 28 | logger.warning( 29 | "while years are supported, they are based off of the calendar of the start of year 1 CE" 30 | ) 31 | 32 | start_of_time = datetime.datetime.min 33 | cal = pdt.Calendar(version=pdt.VERSION_CONTEXT_STYLE) 34 | timedelta = cal.parseDT(tm, sourceTime=start_of_time)[0] - start_of_time 35 | return int(timedelta.total_seconds()) 36 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/helpers/logger.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | import logging 15 | 16 | 17 | class Logger: 18 | """Set up a logger fo this package""" 19 | 20 | @classmethod 21 | def get_logger(cls, name: str) -> logging.Logger: 22 | """ 23 | Gets the current logger for this package 24 | :param name: the name of the logger 25 | :return: the logger 26 | """ 27 | logger = logging.getLogger(name) 28 | if not len(logger.handlers): 29 | logger.setLevel(logging.INFO) 30 | handler = logging.StreamHandler() 31 | formatter = logging.Formatter("[%(levelname)s]\t%(name)s\t%(message)s") 32 | handler.setFormatter(formatter) 33 | logger.addHandler(handler) 34 | logger.propagate = False 35 | return logger 36 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/aws_lambda/functions/create_timestamp.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from pathlib import Path 14 | 15 | from aws_cdk.core import Construct 16 | 17 | from aws_solutions.cdk.stepfunctions.solutionstep import SolutionStep 18 | 19 | 20 | class CreateTimestamp(SolutionStep): 21 | def __init__( 22 | self, 23 | scope: Construct, 24 | id: str, 25 | layers=None, 26 | ): 27 | super().__init__( 28 | scope, 29 | id, 30 | layers=layers, 31 | entrypoint=( 32 | Path(__file__).absolute().parents[4] 33 | / "aws_lambda" 34 | / "create_timestamp" 35 | / "handler.py" 36 | ), 37 | ) 38 | 39 | def _set_permissions(self): 40 | pass # NOSONAR (python:S1186) - no permissions required 41 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Maintaining Personalized Experiences with Machine Learning 2 | 3 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | Licensed under the Apache License Version 2.0 (the "License"). You may not use this file except 5 | in compliance with the License. A copy of the License is located at http://www.apache.org/licenses/ 6 | or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 7 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for the 8 | specific language governing permissions and limitations under the License. 9 | 10 | ********************** 11 | THIRD PARTY COMPONENTS 12 | ********************** 13 | This software includes third party software subject to the following copyrights: 14 | 15 | Apache Avro under the Apache License 2.0 16 | AWS Lambda Java Support Libraries under the Apache License Version 2.0 17 | AWS Lambda Powertools for Python under the MIT No Attribution license 18 | AWS SDK under the Apache License Version 2.0 19 | boto3 under the Apache License Version 2.0 20 | black under the Massachusetts Institute of Technology (MIT) license 21 | click under the BSD 3-Clause license 22 | coverage under the Apache License Version 2.0 23 | crhelper under the Apache License Version 2.0 24 | cronex under the Massachusetts Institute of Technology (MIT) license 25 | docker-py under the Apache License Version 2.0 26 | Gradle under the Apache License Version 2.0 27 | jmespath under the Apache License Version 2.0 28 | junit under the Eclipse Public License Version 2.0 29 | moto under the Apache License Version 2.0 30 | pytest under the Massachusetts Institute of Technology (MIT) license 31 | pytest-cov under the Massachusetts Institute of Technology (MIT) license 32 | pytest-mock under the Massachusetts Institute of Technology (MIT) license 33 | pytest-env under the Massachusetts Institute of Technology (MIT) license 34 | PyYAML under the Massachusetts Institute of Technology (MIT) license 35 | requests under the Apache License Version 2.0 36 | requests-mock under the Apache License Version 2.0 37 | rich under the Massachusetts Institute of Technology (MIT) license 38 | tenacity under the Apache License Version 2.0 39 | quartz-scheduler under the Apache License Version 2.0 40 | 41 | The Apache License Version Version 2.0 is included in LICENSE.txt. -------------------------------------------------------------------------------- /source/infrastructure/personalize/aws_lambda/layers/aws_solutions/layer.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from pathlib import Path 15 | 16 | from aws_cdk.core import Construct, Stack 17 | 18 | from aws_solutions.cdk.aws_lambda.python.layer import SolutionsPythonLayerVersion 19 | 20 | 21 | class SolutionsLayer(SolutionsPythonLayerVersion): 22 | def __init__(self, scope: Construct, construct_id: str, **kwargs): 23 | requirements_path: Path = Path(__file__).absolute().parent / "requirements" 24 | super().__init__(scope, construct_id, requirements_path, **kwargs) 25 | 26 | @staticmethod 27 | def get_or_create(scope: Construct, **kwargs): 28 | stack = Stack.of(scope) 29 | construct_id = "SolutionsLayer-DAE8E12F-3DEA-43FB-A4AA-E55AC50BD2E9" 30 | exists = stack.node.try_find_child(construct_id) 31 | if exists: 32 | return exists 33 | return SolutionsLayer(stack, construct_id, **kwargs) 34 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/aws_lambda/functions/prepare_input.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from pathlib import Path 15 | 16 | from aws_cdk.core import Construct 17 | 18 | from aws_solutions.cdk.stepfunctions.solutionstep import SolutionStep 19 | 20 | 21 | class PrepareInput(SolutionStep): 22 | def __init__( 23 | self, 24 | scope: Construct, 25 | id: str, 26 | layers=None, 27 | ): 28 | super().__init__( 29 | scope, 30 | id, 31 | layers=layers, 32 | entrypoint=( 33 | Path(__file__).absolute().parents[4] 34 | / "aws_lambda" 35 | / "prepare_input" 36 | / "handler.py" 37 | ), 38 | libraries=[Path(__file__).absolute().parents[4] / "aws_lambda" / "shared"], 39 | ) 40 | 41 | def _set_permissions(self): 42 | pass # NOSONAR (python:S1186) - no permissions required 43 | -------------------------------------------------------------------------------- /source/scheduler/common/aws_solutions/scheduler/common/task_resource.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | import dataclasses 15 | import functools 16 | 17 | from aws_solutions.scheduler.common.schedule import Schedule 18 | from aws_solutions.scheduler.common.task import Task 19 | 20 | 21 | class TaskResource: 22 | """Used as a decorator on AWS Lambda Functions to transform the AWS Lambda Event input as a Task""" 23 | 24 | def __init__(self, func): 25 | functools.update_wrapper(self, func) 26 | self.func = func 27 | 28 | def __call__(self, *args, **kwargs): 29 | task: Task = Task(**args[0]) 30 | task: Task = self.func(task, args[1], **kwargs) 31 | 32 | if not task: 33 | return None 34 | else: 35 | # convert the schedule into a string 36 | if isinstance(task.schedule, Schedule): 37 | task.schedule = task.schedule.expression 38 | return dataclasses.asdict(task) 39 | -------------------------------------------------------------------------------- /source/infrastructure/personalize/aws_lambda/functions/create_scheduled_task.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from pathlib import Path 14 | 15 | from aws_cdk.core import Construct 16 | 17 | from aws_solutions.cdk.stepfunctions.solutionstep import SolutionStep 18 | 19 | 20 | class CreateScheduledTask(SolutionStep): 21 | def __init__( 22 | self, 23 | scope: Construct, 24 | id: str, 25 | layers=None, 26 | ): 27 | super().__init__( 28 | scope, 29 | id, 30 | layers=layers, 31 | entrypoint=( 32 | Path(__file__).absolute().parents[4] 33 | / "aws_lambda" 34 | / "create_scheduled_task" 35 | / "handler.py" 36 | ), 37 | libraries=[Path(__file__).absolute().parents[4] / "aws_lambda" / "shared"], 38 | ) 39 | 40 | def _set_permissions(self): 41 | pass # NOSONAR (python:S1186) - no permissions required 42 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/aws_lambda/layers/aws_lambda_powertools/layer.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from pathlib import Path 15 | 16 | from aws_cdk.core import Construct, Stack 17 | 18 | from aws_solutions.cdk.aws_lambda.python.layer import SolutionsPythonLayerVersion 19 | 20 | 21 | class PowertoolsLayer(SolutionsPythonLayerVersion): 22 | def __init__(self, scope: Construct, construct_id: str, **kwargs): 23 | requirements_path: Path = Path(__file__).absolute().parent / "requirements" 24 | super().__init__(scope, construct_id, requirements_path, **kwargs) 25 | 26 | @staticmethod 27 | def get_or_create(scope: Construct, **kwargs): 28 | stack = Stack.of(scope) 29 | construct_id = "PowertoolsLayer-8E932F0F-197D-4026-A354-23D184C2A624" 30 | exists = stack.node.try_find_child(construct_id) 31 | if exists: 32 | return exists 33 | return PowertoolsLayer(stack, construct_id, **kwargs) 34 | -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/src/main/java/com/amazonaws/solutions/schedule_sfn_task/ScheduleEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for 11 | * the specific language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.amazonaws.solutions.schedule_sfn_task; 15 | 16 | public class ScheduleEvent { 17 | private String schedule; 18 | private String next; 19 | 20 | public ScheduleEvent() { 21 | } 22 | 23 | public String getNext() { 24 | return next; 25 | } 26 | 27 | public String setNext(String next) { 28 | this.next = next; 29 | return next; 30 | } 31 | 32 | public void setSchedule(String schedule) { 33 | /* 34 | cron schedules have 7 fields (seconds, minutes, hours, day-of-month month day-of-week and year), we use only the 35 | last 6 fields (omitting seconds). To do this, we always set seconds to 0, and keep the remainder of the provided 36 | schedule. When generating a next scheduled time, we use a random number of seconds in the minute to avoid hot 37 | spots at the start of each minute. An example string schedule provided might look like * * * * ? * (e.g. every 38 | minute) 39 | */ 40 | schedule = validateSchedule(schedule); 41 | this.schedule = "0 " + schedule; 42 | } 43 | 44 | public String getSchedule() { 45 | return schedule; 46 | } 47 | 48 | private String validateSchedule(String schedule) { 49 | schedule = schedule 50 | .replace("cron(", "") 51 | .replace(")", ""); 52 | 53 | String[] fields = schedule.split("\\s+"); 54 | 55 | if(fields.length != 6) { 56 | throw new ScheduleException("schedule " + schedule + " is not a valid schedule (requires 6 fields)"); 57 | } 58 | return schedule; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/test_cfn_nag_suppressions.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | from aws_cdk.core import CfnResource, App, Stack 15 | 16 | from aws_solutions.cdk.cfn_nag import add_cfn_nag_suppressions, CfnNagSuppression 17 | 18 | 19 | def test_cfn_nag_suppression(): 20 | rule_id = "W10" 21 | reason = "some reason" 22 | sup = CfnNagSuppression(rule_id=rule_id, reason=reason) 23 | 24 | assert sup.rule_id == rule_id 25 | assert sup.reason == reason 26 | 27 | 28 | def test_add_cfn_nag_suppression(): 29 | app = App() 30 | stack = Stack(app) 31 | resource = CfnResource(stack, "test", type="Custom::Test") 32 | 33 | add_cfn_nag_suppressions( 34 | resource, 35 | [ 36 | CfnNagSuppression(rule_id="W1", reason="reason 1"), 37 | CfnNagSuppression("W2", "reason 2"), 38 | ], 39 | ) 40 | 41 | assert resource.get_metadata("cfn_nag") == { 42 | "rules_to_suppress": [ 43 | {"id": "W1", "reason": "reason 1"}, 44 | {"id": "W2", "reason": "reason 2"}, 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/test_mappings.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | import pytest 14 | from aws_cdk.core import App, Stack 15 | 16 | from aws_solutions.cdk.mappings import Mappings 17 | 18 | 19 | @pytest.mark.parametrize("send_data,result", [(True, "Yes"), (False, "No")]) 20 | def test_mappings(send_data, result): 21 | solution_id = "SO001" 22 | app = App() 23 | stack = Stack(app) 24 | Mappings(stack, solution_id=solution_id, send_anonymous_usage_data=send_data) 25 | 26 | template = app.synth().stacks[0].template 27 | 28 | assert template["Mappings"]["Solution"]["Data"]["ID"] == solution_id 29 | assert template["Mappings"]["Solution"]["Data"]["Version"] == "%%SOLUTION_VERSION%%" 30 | assert template["Mappings"]["Solution"]["Data"]["SendAnonymousUsageData"] == result 31 | 32 | assert ( 33 | template["Mappings"]["SourceCode"]["General"]["S3Bucket"] == "%%BUCKET_NAME%%" 34 | ) 35 | assert ( 36 | template["Mappings"]["SourceCode"]["General"]["KeyPrefix"] 37 | == "%%SOLUTION_NAME%%/%%SOLUTION_VERSION%%" 38 | ) 39 | -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/src/test/java/com/amazonaws/solutions/schedule_sfn_task/HandleScheduleEventTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for 11 | * the specific language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.amazonaws.solutions.schedule_sfn_task; 15 | 16 | import org.junit.jupiter.api.Assertions; 17 | import org.junit.jupiter.api.BeforeEach; 18 | import org.junit.jupiter.api.DisplayName; 19 | import org.junit.jupiter.api.Test; 20 | import org.junit.jupiter.params.ParameterizedTest; 21 | import org.junit.jupiter.params.provider.ValueSource; 22 | 23 | import java.text.DateFormat; 24 | import java.text.SimpleDateFormat; 25 | 26 | 27 | class HandleScheduleEventTest { 28 | private ScheduleEvent event; 29 | private HandleScheduleEvent handler; 30 | 31 | @BeforeEach 32 | public void setUp() { 33 | event = new ScheduleEvent(); 34 | handler = new HandleScheduleEvent(); 35 | } 36 | 37 | @Test 38 | @DisplayName("returns ISO 8601 in UTC with seconds") 39 | public void testScheduleEventOutput() { 40 | this.event.setSchedule("cron(* * * * ? *)"); 41 | String result = handler.handleRequest(this.event, null); 42 | 43 | DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); 44 | Assertions.assertDoesNotThrow(() -> { 45 | sdf.parse(result); 46 | }); 47 | } 48 | 49 | @ParameterizedTest 50 | @ValueSource(strings = {"cron(1)", "* * * * * *", "* * *", "* * * * *"}) 51 | @DisplayName("com.amazonaws.solutions.schedule_sfn_task.ScheduleEvent invalid representation raises com.amazonaws.solutions.schedule_sfn_task.ScheduleException") 52 | public void testScheduleEventInvalid(String schedule) { 53 | Assertions.assertThrows(ScheduleException.class, () -> { 54 | this.event.setSchedule(schedule); 55 | handler.handleRequest(this.event, null); 56 | }); 57 | } 58 | } -------------------------------------------------------------------------------- /source/aws_lambda/create_schema/handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from typing import Dict, Any 15 | 16 | from aws_lambda_powertools import Logger, Tracer, Metrics 17 | from aws_lambda_powertools.utilities.typing import LambdaContext 18 | 19 | from shared.sfn_middleware import PersonalizeResource 20 | 21 | logger = Logger() 22 | tracer = Tracer() 23 | metrics = Metrics() 24 | 25 | 26 | @metrics.log_metrics 27 | @tracer.capture_lambda_handler 28 | @PersonalizeResource( 29 | resource="schema", 30 | config={ 31 | "name": { 32 | "source": "event", 33 | "path": "serviceConfig.name", 34 | }, 35 | "schema": {"source": "event", "path": "serviceConfig.schema", "as": "string"}, 36 | }, 37 | ) 38 | def lambda_handler(event: Dict[str, Any], context: LambdaContext) -> Dict: 39 | """Create a schema in Amazon Personalize based on the configuration in `event` 40 | :param event: AWS Lambda Event 41 | :param context: AWS Lambda Context 42 | :return: the configured schema 43 | """ 44 | return event.get("resource") # return the resource 45 | -------------------------------------------------------------------------------- /source/infrastructure/deploy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # ###################################################################################################################### 4 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 5 | # # 6 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 7 | # with the License. You may obtain a copy of the License at # 8 | # # 9 | # http://www.apache.org/licenses/LICENSE-2.0 # 10 | # # 11 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 12 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 13 | # the specific language governing permissions and limitations under the License. # 14 | # ###################################################################################################################### 15 | 16 | import logging 17 | from pathlib import Path 18 | 19 | from aws_cdk import core as cdk 20 | 21 | from aws_solutions.cdk import CDKSolution 22 | from personalize.stack import PersonalizeStack 23 | 24 | logger = logging.getLogger("cdk-helper") 25 | solution = CDKSolution(cdk_json_path=Path(__file__).parent.absolute() / "cdk.json") 26 | 27 | 28 | @solution.context.requires("SOLUTION_NAME") 29 | @solution.context.requires("SOLUTION_ID") 30 | @solution.context.requires("SOLUTION_VERSION") 31 | @solution.context.requires("BUCKET_NAME") 32 | def build_app(context): 33 | app = cdk.App(context=context) 34 | PersonalizeStack( 35 | app, 36 | "PersonalizeStack", 37 | description=f"Deploy, deliver and maintain personalized experiences with Amazon Personalize", 38 | template_filename="maintaining-personalized-experiences-with-machine-learning.template", 39 | synthesizer=solution.synthesizer, 40 | ) 41 | return app.synth() 42 | 43 | 44 | if __name__ == "__main__": 45 | build_app() 46 | -------------------------------------------------------------------------------- /source/aws_lambda/create_config/handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | import json 14 | import os 15 | 16 | from aws_lambda_powertools import Logger, Tracer, Metrics 17 | from aws_lambda_powertools.metrics import MetricUnit 18 | from aws_lambda_powertools.utilities.data_classes import S3Event 19 | 20 | from shared.personalize.service_model import ServiceModel 21 | from shared.personalize_service import Personalize 22 | 23 | 24 | logger = Logger() 25 | tracer = Tracer() 26 | metrics = Metrics() 27 | 28 | 29 | @metrics.log_metrics 30 | @tracer.capture_lambda_handler 31 | def lambda_handler(event, context): 32 | """Generate and return a solution configuration file derived from the properties of a dataset group 33 | :param dict event: AWS Lambda Event (in this case, the dataset group and schedules) 34 | :param context: AWS Lambda Context 35 | :return: Dict 36 | """ 37 | dataset_group_name = event["datasetGroupName"] 38 | schedules = event.get("schedules") 39 | 40 | cli = Personalize() 41 | model = ServiceModel(cli, dataset_group_name=dataset_group_name) 42 | return model.get_config(dataset_group_name=dataset_group_name, schedules=schedules) 43 | -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/get_next_scheduled_event/src/main/java/com/amazonaws/solutions/schedule_sfn_task/HandleScheduleEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for 11 | * the specific language governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.amazonaws.solutions.schedule_sfn_task; 15 | 16 | import com.amazonaws.services.lambda.runtime.Context; 17 | import com.amazonaws.services.lambda.runtime.RequestHandler; 18 | import org.quartz.CronExpression; 19 | 20 | import java.security.SecureRandom; 21 | import java.text.ParseException; 22 | import java.text.SimpleDateFormat; 23 | import java.time.Instant; 24 | import java.util.Date; 25 | import java.util.TimeZone; 26 | 27 | public class HandleScheduleEvent implements RequestHandler { 28 | @Override 29 | public String handleRequest(ScheduleEvent event, Context context) { 30 | try { 31 | setNextSchedule(event); 32 | } catch (ParseException e) { 33 | throw new ScheduleException(e.getMessage()); 34 | } 35 | return event.getNext(); 36 | } 37 | 38 | private ScheduleEvent setNextSchedule(ScheduleEvent event) throws ParseException { 39 | String schedule = event.getSchedule(); 40 | SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); 41 | dateFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); 42 | 43 | // create the expression (this throws a ParseException on failure) 44 | CronExpression expression = new CronExpression(schedule); 45 | 46 | // set up the next date as a string 47 | int seconds = getRandomSeconds(); 48 | Date dt = Date.from(expression.getNextValidTimeAfter(Date.from(Instant.now())).toInstant().plusSeconds(seconds)); 49 | String dtText = dateFormatter.format(dt); 50 | event.setNext(event.setNext(dtText)); 51 | 52 | return event; 53 | } 54 | 55 | private int getRandomSeconds() { 56 | SecureRandom random = new SecureRandom(); 57 | return random.nextInt(60); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /source/aws_lambda/shared/resource/base.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | from __future__ import annotations 14 | 15 | from typing import List 16 | 17 | from aws_solutions.core import get_aws_partition, get_aws_region, get_aws_account 18 | from shared.resource.name import ResourceName 19 | 20 | 21 | class Resource: 22 | children: List[Resource] = [] 23 | has_soft_limit: bool = False 24 | 25 | def __init__(self): 26 | name = self.__class__.__name__ 27 | name = name[0].lower() + name[1:] 28 | self.name = ResourceName(name) 29 | 30 | def arn(self, name: str, **kwargs) -> str: 31 | if self.name.camel == "solutionVersion": 32 | arn_prefix = f"arn:{get_aws_partition()}:personalize:{get_aws_region()}:{get_aws_account()}" 33 | return f"{arn_prefix}:solution/{name}/{kwargs.get('sv_id', 'unknown')}" 34 | else: 35 | arn_prefix = f"arn:{get_aws_partition()}:personalize:{get_aws_region()}:{get_aws_account()}" 36 | return f"{arn_prefix}:{self.name.dash}/{name}" 37 | 38 | def __eq__(self, other): 39 | return self.name.camel == other.name.camel 40 | 41 | def __hash__(self): 42 | return hash(self.name.camel) 43 | -------------------------------------------------------------------------------- /source/scheduler/cdk/aws_solutions/scheduler/cdk/aws_lambda/scheduler/handler.py: -------------------------------------------------------------------------------- 1 | # ###################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ###################################################################################################################### 13 | 14 | from typing import Dict 15 | 16 | from aws_lambda_powertools import Logger, Tracer, Metrics 17 | from aws_lambda_powertools.utilities.typing import LambdaContext 18 | 19 | from aws_solutions.scheduler.common import ( 20 | Scheduler, 21 | Task, 22 | TaskResource, 23 | ) 24 | 25 | logger = Logger() 26 | tracer = Tracer() 27 | scheduler = Scheduler() 28 | metrics = Metrics(service="Scheduler") 29 | 30 | 31 | @metrics.log_metrics 32 | @tracer.capture_lambda_handler 33 | @TaskResource 34 | def create_schedule(task: Task, _: LambdaContext) -> Dict: 35 | return scheduler.create(task) 36 | 37 | 38 | @metrics.log_metrics 39 | @tracer.capture_lambda_handler 40 | @TaskResource 41 | def read_schedule(task: Task, _: LambdaContext) -> Dict: 42 | return scheduler.read(task) 43 | 44 | 45 | @metrics.log_metrics 46 | @tracer.capture_lambda_handler 47 | @TaskResource 48 | def update_schedule(task: Task, _: LambdaContext) -> Dict: 49 | return scheduler.update(task) 50 | 51 | 52 | @metrics.log_metrics 53 | @tracer.capture_lambda_handler 54 | @TaskResource 55 | def delete_schedule(task: Task, _: LambdaContext) -> Dict: 56 | return scheduler.delete(task) 57 | -------------------------------------------------------------------------------- /source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/__init__.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | from pathlib import Path 15 | 16 | from aws_solutions.cdk.context import SolutionContext 17 | from aws_solutions.cdk.stack import SolutionStack 18 | from aws_solutions.cdk.synthesizers import SolutionStackSubstitions 19 | 20 | 21 | class CDKSolution: 22 | """ 23 | A CDKSolution stores helper utilities for building AWS Solutions using the AWS CDK in Python 24 | 25 | :type cdk_json_path: Path 26 | :param cdk_json_path: The full path to the cdk.json context for your application 27 | :type qualifier: str 28 | :param qualifier: A string that is added to all resources in the CDK bootstrap stack. The default value has no significance. 29 | """ 30 | 31 | def __init__(self, cdk_json_path: Path, qualifier="hnb659fds"): 32 | self.qualifier = qualifier 33 | self.context = SolutionContext(cdk_json_path=cdk_json_path) 34 | self.synthesizer = SolutionStackSubstitions(qualifier=self.qualifier) 35 | 36 | def reset(self) -> None: 37 | """ 38 | Get a new synthesizer for this CDKSolution - useful for testing 39 | :return: None 40 | """ 41 | self.synthesizer = SolutionStackSubstitions(qualifier=self.qualifier) 42 | -------------------------------------------------------------------------------- /source/tests/cdk_solution_helper/aws_lambda/cfn_custom_resources/resource_hash/test_resource_name_cdk.py: -------------------------------------------------------------------------------- 1 | # ##################################################################################################################### 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # 5 | # with the License. You may obtain a copy of the License at # 6 | # # 7 | # http://www.apache.org/licenses/LICENSE-2.0 # 8 | # # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed # 10 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for # 11 | # the specific language governing permissions and limitations under the License. # 12 | # ##################################################################################################################### 13 | 14 | import pytest 15 | from aws_cdk.core import Stack, App 16 | from constructs import Construct 17 | 18 | from aws_solutions.cdk.aws_lambda.cfn_custom_resources.resource_name.name import ( 19 | ResourceName, 20 | ) 21 | 22 | 23 | class SomeStack(Stack): 24 | def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: 25 | super().__init__(scope, construct_id, **kwargs) 26 | self.name_1 = ResourceName(self, "name_1", purpose="var_1", max_length=32) 27 | self.name_2 = ResourceName(self, "name_2", purpose="var_2", max_length=32) 28 | 29 | 30 | @pytest.fixture 31 | def resource_naming_stack(): 32 | app = App() 33 | SomeStack(app, "some-test-naming") 34 | yield app.synth().get_stack("some-test-naming").template 35 | 36 | 37 | def test_resource_service_tokens(resource_naming_stack): 38 | # There should be only one lambda function generated. 39 | service_tokens = [ 40 | resource["Properties"]["ServiceToken"] 41 | for resource in resource_naming_stack["Resources"].values() 42 | if resource["Type"] == "Custom::ResourceName" 43 | ] 44 | assert all(st == service_tokens[0] for st in service_tokens) 45 | --------------------------------------------------------------------------------