diff --git a/.github/workflows/deploy-examples.yml b/.github/workflows/deploy-examples.yml index 6e6c031..64e3a63 100644 --- a/.github/workflows/deploy-examples.yml +++ b/.github/workflows/deploy-examples.yml @@ -75,7 +75,6 @@ jobs: env: AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} LAMBDA_ENDPOINT: ${{ secrets.LAMBDA_ENDPOINT_BETA }} - INVOKE_ACCOUNT_ID: ${{ secrets.INVOKE_ACCOUNT_ID_BETA }} KMS_KEY_ARN: ${{ secrets.KMS_KEY_ARN }} run: | # Build function name diff --git a/.gitignore b/.gitignore index b8781d3..de54ec5 100644 --- a/.gitignore +++ b/.gitignore @@ -30,5 +30,7 @@ dist/ .idea .env +.durable_executions + examples/build/* examples/*.zip diff --git a/examples/cli.py b/examples/cli.py index 322fa05..3de993e 100755 --- a/examples/cli.py +++ b/examples/cli.py @@ -66,7 +66,9 @@ def build_examples(): # Copy example functions logger.info("Copying examples from %s", src_dir) - shutil.copytree(src_dir, build_dir / "src") + for file_path in src_dir.rglob("*"): + if file_path.is_file(): + shutil.copy2(file_path, build_dir / file_path.name) logger.info("Build completed successfully") return True @@ -296,13 +298,10 @@ def get_aws_config(): "region": os.getenv("AWS_REGION", "us-west-2"), "lambda_endpoint": os.getenv("LAMBDA_ENDPOINT"), "account_id": os.getenv("AWS_ACCOUNT_ID"), - "invoke_account_id": os.getenv("INVOKE_ACCOUNT_ID"), "kms_key_arn": os.getenv("KMS_KEY_ARN"), } - if not all( - [config["account_id"], config["lambda_endpoint"], config["invoke_account_id"]] - ): + if not all([config["account_id"], config["lambda_endpoint"]]): msg = "Missing required environment variables" raise ValueError(msg) @@ -406,26 +405,6 @@ def deploy_function(example_name: str, function_name: str | None = None): except lambda_client.exceptions.ResourceNotFoundException: lambda_client.create_function(**function_config, Code={"ZipFile": zip_content}) - # Update invoke permission for worker account using put_resource_policy - function_arn = f"arn:aws:lambda:{config['region']}:{config['account_id']}:function:{function_name}" - - policy_document = { - "Version": "2012-10-17", - "Statement": [ - { - "Sid": "dex-invoke-permission", - "Effect": "Allow", - "Principal": {"AWS": config["invoke_account_id"]}, - "Action": "lambda:InvokeFunction", - "Resource": f"{function_arn}:*", - } - ], - } - - lambda_client.put_resource_policy( - ResourceArn=function_arn, Policy=json.dumps(policy_document) - ) - logger.info("Function deployed successfully! %s", function_name) return True diff --git a/examples/examples-catalog.json b/examples/examples-catalog.json index 13d7608..30c7e21 100644 --- a/examples/examples-catalog.json +++ b/examples/examples-catalog.json @@ -21,7 +21,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/step.py" + "path": "./src/step/step.py" }, { "name": "Step with Name", @@ -32,7 +32,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/step_with_name.py" + "path": "./src/step/step_with_name.py" }, { "name": "Step with Retry", @@ -43,7 +43,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/step_with_retry.py" + "path": "./src/step/step_with_retry.py" }, { "name": "Wait State", @@ -54,7 +54,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/wait.py" + "path": "./src/wait/wait.py" }, { "name": "Callback", @@ -65,7 +65,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/callback.py" + "path": "./src/callback/callback.py" }, { "name": "Wait for Callback", @@ -76,7 +76,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/wait_for_callback.py" + "path": "./src/wait_for_callback/wait_for_callback.py" }, { "name": "Run in Child Context", @@ -87,7 +87,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/run_in_child_context.py" + "path": "./src/run_in_child_context/run_in_child_context.py" }, { "name": "Parallel Operations", @@ -98,7 +98,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/parallel.py" + "path": "./src/parallel/parallel.py" }, { "name": "Map Operations", @@ -109,7 +109,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/map_operations.py" + "path": "./src/map/map_operations.py" }, { "name": "Block Example", @@ -120,7 +120,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/block_example.py" + "path": "./src/block_example/block_example.py" }, { "name": "Logger Example", @@ -131,7 +131,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/logger_example.py" + "path": "./src/logger_example/logger_example.py" }, { "name": "Steps with Retry", @@ -142,7 +142,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/steps_with_retry.py" + "path": "./src/step/steps_with_retry.py" }, { "name": "Wait for Condition", @@ -153,7 +153,7 @@ "RetentionPeriodInDays": 7, "ExecutionTimeout": 300 }, - "path": "./src/wait_for_condition.py" + "path": "./src/wait_for_condition/wait_for_condition.py" } ] } diff --git a/examples/src/block_example.py b/examples/src/block_example/block_example.py similarity index 100% rename from examples/src/block_example.py rename to examples/src/block_example/block_example.py diff --git a/examples/src/callback.py b/examples/src/callback/callback.py similarity index 100% rename from examples/src/callback.py rename to examples/src/callback/callback.py diff --git a/examples/src/callback_with_timeout.py b/examples/src/callback/callback_with_timeout.py similarity index 100% rename from examples/src/callback_with_timeout.py rename to examples/src/callback/callback_with_timeout.py diff --git a/examples/src/logger_example.py b/examples/src/logger_example/logger_example.py similarity index 100% rename from examples/src/logger_example.py rename to examples/src/logger_example/logger_example.py diff --git a/examples/src/map_operations.py b/examples/src/map/map_operations.py similarity index 100% rename from examples/src/map_operations.py rename to examples/src/map/map_operations.py diff --git a/examples/src/parallel.py b/examples/src/parallel/parallel.py similarity index 100% rename from examples/src/parallel.py rename to examples/src/parallel/parallel.py diff --git a/examples/src/parallel_first_successful.py b/examples/src/parallel/parallel_first_successful.py similarity index 100% rename from examples/src/parallel_first_successful.py rename to examples/src/parallel/parallel_first_successful.py diff --git a/examples/src/run_in_child_context.py b/examples/src/run_in_child_context/run_in_child_context.py similarity index 100% rename from examples/src/run_in_child_context.py rename to examples/src/run_in_child_context/run_in_child_context.py diff --git a/examples/src/step.py b/examples/src/step/step.py similarity index 100% rename from examples/src/step.py rename to examples/src/step/step.py diff --git a/examples/src/step_no_name.py b/examples/src/step/step_no_name.py similarity index 100% rename from examples/src/step_no_name.py rename to examples/src/step/step_no_name.py diff --git a/examples/src/step_semantics_at_most_once.py b/examples/src/step/step_semantics_at_most_once.py similarity index 100% rename from examples/src/step_semantics_at_most_once.py rename to examples/src/step/step_semantics_at_most_once.py diff --git a/examples/src/step_with_exponential_backoff.py b/examples/src/step/step_with_exponential_backoff.py similarity index 100% rename from examples/src/step_with_exponential_backoff.py rename to examples/src/step/step_with_exponential_backoff.py diff --git a/examples/src/step_with_name.py b/examples/src/step/step_with_name.py similarity index 100% rename from examples/src/step_with_name.py rename to examples/src/step/step_with_name.py diff --git a/examples/src/step_with_retry.py b/examples/src/step/step_with_retry.py similarity index 100% rename from examples/src/step_with_retry.py rename to examples/src/step/step_with_retry.py diff --git a/examples/src/steps_with_retry.py b/examples/src/step/steps_with_retry.py similarity index 100% rename from examples/src/steps_with_retry.py rename to examples/src/step/steps_with_retry.py diff --git a/examples/src/wait.py b/examples/src/wait/wait.py similarity index 100% rename from examples/src/wait.py rename to examples/src/wait/wait.py diff --git a/examples/src/wait_with_name.py b/examples/src/wait/wait_with_name.py similarity index 100% rename from examples/src/wait_with_name.py rename to examples/src/wait/wait_with_name.py diff --git a/examples/src/wait_for_callback.py b/examples/src/wait_for_callback/wait_for_callback.py similarity index 100% rename from examples/src/wait_for_callback.py rename to examples/src/wait_for_callback/wait_for_callback.py diff --git a/examples/src/wait_for_condition.py b/examples/src/wait_for_condition/wait_for_condition.py similarity index 100% rename from examples/src/wait_for_condition.py rename to examples/src/wait_for_condition/wait_for_condition.py diff --git a/examples/test/test_block_example.py b/examples/test/block_example/test_block_example.py similarity index 98% rename from examples/test/test_block_example.py rename to examples/test/block_example/test_block_example.py index 3d220a6..7d648f6 100644 --- a/examples/test/test_block_example.py +++ b/examples/test/block_example/test_block_example.py @@ -3,7 +3,7 @@ import pytest from aws_durable_execution_sdk_python.execution import InvocationStatus -from src import block_example +from src.block_example import block_example from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_callback.py b/examples/test/callback/test_callback.py similarity index 96% rename from examples/test/test_callback.py rename to examples/test/callback/test_callback.py index ae46a95..4d9f95f 100644 --- a/examples/test/test_callback.py +++ b/examples/test/callback/test_callback.py @@ -3,7 +3,7 @@ import pytest from aws_durable_execution_sdk_python.execution import InvocationStatus -from src import callback +from src.callback import callback from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_callback_permutations.py b/examples/test/callback/test_callback_permutations.py similarity index 95% rename from examples/test/test_callback_permutations.py rename to examples/test/callback/test_callback_permutations.py index 9c1e661..36d9e5b 100644 --- a/examples/test/test_callback_permutations.py +++ b/examples/test/callback/test_callback_permutations.py @@ -3,7 +3,7 @@ import pytest from aws_durable_execution_sdk_python.execution import InvocationStatus -from src import callback_with_timeout +from src.callback import callback_with_timeout from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_logger_example.py b/examples/test/logger_example/test_logger_example.py similarity index 96% rename from examples/test/test_logger_example.py rename to examples/test/logger_example/test_logger_example.py index 30290b5..2087e72 100644 --- a/examples/test/test_logger_example.py +++ b/examples/test/logger_example/test_logger_example.py @@ -4,7 +4,7 @@ from aws_durable_execution_sdk_python.execution import InvocationStatus from aws_durable_execution_sdk_python.lambda_service import OperationType -from src import logger_example +from src.logger_example import logger_example from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_map_operations.py b/examples/test/map/test_map_operations.py similarity index 96% rename from examples/test/test_map_operations.py rename to examples/test/map/test_map_operations.py index c784942..28b1e94 100644 --- a/examples/test/test_map_operations.py +++ b/examples/test/map/test_map_operations.py @@ -4,7 +4,7 @@ from aws_durable_execution_sdk_python.execution import InvocationStatus from aws_durable_execution_sdk_python.lambda_service import OperationType -from src import map_operations +from src.map import map_operations from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_parallel.py b/examples/test/parallel/test_parallel.py similarity index 96% rename from examples/test/test_parallel.py rename to examples/test/parallel/test_parallel.py index 5878648..cce24ac 100644 --- a/examples/test/test_parallel.py +++ b/examples/test/parallel/test_parallel.py @@ -4,7 +4,7 @@ from aws_durable_execution_sdk_python.execution import InvocationStatus from aws_durable_execution_sdk_python.lambda_service import OperationType -from src import parallel +from src.parallel import parallel from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_run_in_child_context.py b/examples/test/run_in_child_context/test_run_in_child_context.py similarity index 93% rename from examples/test/test_run_in_child_context.py rename to examples/test/run_in_child_context/test_run_in_child_context.py index 1bc5b26..61bf200 100644 --- a/examples/test/test_run_in_child_context.py +++ b/examples/test/run_in_child_context/test_run_in_child_context.py @@ -3,7 +3,7 @@ import pytest from aws_durable_execution_sdk_python.execution import InvocationStatus -from src import run_in_child_context +from src.run_in_child_context import run_in_child_context from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_step.py b/examples/test/step/test_step.py similarity index 96% rename from examples/test/test_step.py rename to examples/test/step/test_step.py index 3fde032..63d7929 100644 --- a/examples/test/test_step.py +++ b/examples/test/step/test_step.py @@ -3,7 +3,7 @@ import pytest from aws_durable_execution_sdk_python.execution import InvocationStatus -from src import step +from src.step import step from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_step_permutations.py b/examples/test/step/test_step_permutations.py similarity index 96% rename from examples/test/test_step_permutations.py rename to examples/test/step/test_step_permutations.py index d46b733..04a0a80 100644 --- a/examples/test/test_step_permutations.py +++ b/examples/test/step/test_step_permutations.py @@ -4,7 +4,7 @@ from aws_durable_execution_sdk_python.execution import InvocationStatus from aws_durable_execution_sdk_python.lambda_service import OperationType -from src import step_no_name, step_with_exponential_backoff, step_with_name +from src.step import step_no_name, step_with_exponential_backoff, step_with_name from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_step_semantics_at_most_once.py b/examples/test/step/test_step_semantics_at_most_once.py similarity index 95% rename from examples/test/test_step_semantics_at_most_once.py rename to examples/test/step/test_step_semantics_at_most_once.py index fd8908f..a67892e 100644 --- a/examples/test/test_step_semantics_at_most_once.py +++ b/examples/test/step/test_step_semantics_at_most_once.py @@ -4,7 +4,7 @@ from aws_durable_execution_sdk_python.execution import InvocationStatus from aws_durable_execution_sdk_python.lambda_service import OperationType -from src import step_semantics_at_most_once +from src.step import step_semantics_at_most_once from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_step_with_retry.py b/examples/test/step/test_step_with_retry.py similarity index 96% rename from examples/test/test_step_with_retry.py rename to examples/test/step/test_step_with_retry.py index 9f4f884..cf7bc8d 100644 --- a/examples/test/test_step_with_retry.py +++ b/examples/test/step/test_step_with_retry.py @@ -4,7 +4,7 @@ from aws_durable_execution_sdk_python.execution import InvocationStatus from aws_durable_execution_sdk_python.lambda_service import OperationType -from src import step_with_retry +from src.step import step_with_retry from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_steps_with_retry.py b/examples/test/step/test_steps_with_retry.py similarity index 96% rename from examples/test/test_steps_with_retry.py rename to examples/test/step/test_steps_with_retry.py index 452ed5f..88b8b8b 100644 --- a/examples/test/test_steps_with_retry.py +++ b/examples/test/step/test_steps_with_retry.py @@ -4,7 +4,7 @@ from aws_durable_execution_sdk_python.execution import InvocationStatus from aws_durable_execution_sdk_python.lambda_service import OperationType -from src import steps_with_retry +from src.step import steps_with_retry from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_wait.py b/examples/test/wait/test_wait.py similarity index 97% rename from examples/test/test_wait.py rename to examples/test/wait/test_wait.py index ae3408d..66cd627 100644 --- a/examples/test/test_wait.py +++ b/examples/test/wait/test_wait.py @@ -3,7 +3,7 @@ import pytest from aws_durable_execution_sdk_python.execution import InvocationStatus -from src import wait +from src.wait import wait from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_wait_permutations.py b/examples/test/wait/test_wait_permutations.py similarity index 95% rename from examples/test/test_wait_permutations.py rename to examples/test/wait/test_wait_permutations.py index 6f33787..bc39d21 100644 --- a/examples/test/test_wait_permutations.py +++ b/examples/test/wait/test_wait_permutations.py @@ -3,7 +3,7 @@ import pytest from aws_durable_execution_sdk_python.execution import InvocationStatus -from src import wait_with_name +from src.wait import wait_with_name from test.conftest import deserialize_operation_payload diff --git a/examples/test/test_wait_for_condition.py b/examples/test/wait_for_condition/test_wait_for_condition.py similarity index 95% rename from examples/test/test_wait_for_condition.py rename to examples/test/wait_for_condition/test_wait_for_condition.py index 51187a1..89e1bd7 100644 --- a/examples/test/test_wait_for_condition.py +++ b/examples/test/wait_for_condition/test_wait_for_condition.py @@ -4,7 +4,7 @@ from aws_durable_execution_sdk_python.execution import InvocationStatus from aws_durable_execution_sdk_python.lambda_service import OperationType -from src import wait_for_condition +from src.wait_for_condition import wait_for_condition from test.conftest import deserialize_operation_payload