Skip to content

Commit 37184e1

Browse files
author
Alex Wang
committed
chore(sdk-testing): re-factor testing examples
- Refactor testing examples - Remove InvokeAccount for testing cases
1 parent 402a348 commit 37184e1

38 files changed

+34
-52
lines changed

.github/workflows/deploy-examples.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ jobs:
7575
env:
7676
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
7777
LAMBDA_ENDPOINT: ${{ secrets.LAMBDA_ENDPOINT_BETA }}
78-
INVOKE_ACCOUNT_ID: ${{ secrets.INVOKE_ACCOUNT_ID_BETA }}
7978
KMS_KEY_ARN: ${{ secrets.KMS_KEY_ARN }}
8079
run: |
8180
# Build function name

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ dist/
3030
.idea
3131
.env
3232

33+
.durable_executions
34+
3335
examples/build/*
3436
examples/*.zip

examples/cli.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def build_examples():
6666

6767
# Copy example functions
6868
logger.info("Copying examples from %s", src_dir)
69-
shutil.copytree(src_dir, build_dir / "src")
69+
for file_path in src_dir.rglob("*"):
70+
if file_path.is_file():
71+
shutil.copy2(file_path, build_dir / file_path.name)
7072

7173
logger.info("Build completed successfully")
7274
return True
@@ -296,12 +298,11 @@ def get_aws_config():
296298
"region": os.getenv("AWS_REGION", "us-west-2"),
297299
"lambda_endpoint": os.getenv("LAMBDA_ENDPOINT"),
298300
"account_id": os.getenv("AWS_ACCOUNT_ID"),
299-
"invoke_account_id": os.getenv("INVOKE_ACCOUNT_ID"),
300301
"kms_key_arn": os.getenv("KMS_KEY_ARN"),
301302
}
302303

303304
if not all(
304-
[config["account_id"], config["lambda_endpoint"], config["invoke_account_id"]]
305+
[config["account_id"], config["lambda_endpoint"]]
305306
):
306307
msg = "Missing required environment variables"
307308
raise ValueError(msg)
@@ -406,26 +407,6 @@ def deploy_function(example_name: str, function_name: str | None = None):
406407
except lambda_client.exceptions.ResourceNotFoundException:
407408
lambda_client.create_function(**function_config, Code={"ZipFile": zip_content})
408409

409-
# Update invoke permission for worker account using put_resource_policy
410-
function_arn = f"arn:aws:lambda:{config['region']}:{config['account_id']}:function:{function_name}"
411-
412-
policy_document = {
413-
"Version": "2012-10-17",
414-
"Statement": [
415-
{
416-
"Sid": "dex-invoke-permission",
417-
"Effect": "Allow",
418-
"Principal": {"AWS": config["invoke_account_id"]},
419-
"Action": "lambda:InvokeFunction",
420-
"Resource": f"{function_arn}:*",
421-
}
422-
],
423-
}
424-
425-
lambda_client.put_resource_policy(
426-
ResourceArn=function_arn, Policy=json.dumps(policy_document)
427-
)
428-
429410
logger.info("Function deployed successfully! %s", function_name)
430411
return True
431412

examples/examples-catalog.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"RetentionPeriodInDays": 7,
2222
"ExecutionTimeout": 300
2323
},
24-
"path": "./src/step.py"
24+
"path": "./src/step/step.py"
2525
},
2626
{
2727
"name": "Step with Name",
@@ -32,7 +32,7 @@
3232
"RetentionPeriodInDays": 7,
3333
"ExecutionTimeout": 300
3434
},
35-
"path": "./src/step_with_name.py"
35+
"path": "./src/step/step_with_name.py"
3636
},
3737
{
3838
"name": "Step with Retry",
@@ -43,7 +43,7 @@
4343
"RetentionPeriodInDays": 7,
4444
"ExecutionTimeout": 300
4545
},
46-
"path": "./src/step_with_retry.py"
46+
"path": "./src/step/step_with_retry.py"
4747
},
4848
{
4949
"name": "Wait State",
@@ -54,7 +54,7 @@
5454
"RetentionPeriodInDays": 7,
5555
"ExecutionTimeout": 300
5656
},
57-
"path": "./src/wait.py"
57+
"path": "./src/wait/wait.py"
5858
},
5959
{
6060
"name": "Callback",
@@ -65,7 +65,7 @@
6565
"RetentionPeriodInDays": 7,
6666
"ExecutionTimeout": 300
6767
},
68-
"path": "./src/callback.py"
68+
"path": "./src/callback/callback.py"
6969
},
7070
{
7171
"name": "Wait for Callback",
@@ -76,7 +76,7 @@
7676
"RetentionPeriodInDays": 7,
7777
"ExecutionTimeout": 300
7878
},
79-
"path": "./src/wait_for_callback.py"
79+
"path": "./src/wait_for_callback/wait_for_callback.py"
8080
},
8181
{
8282
"name": "Run in Child Context",
@@ -87,7 +87,7 @@
8787
"RetentionPeriodInDays": 7,
8888
"ExecutionTimeout": 300
8989
},
90-
"path": "./src/run_in_child_context.py"
90+
"path": "./src/run_in_child_context/run_in_child_context.py"
9191
},
9292
{
9393
"name": "Parallel Operations",
@@ -98,7 +98,7 @@
9898
"RetentionPeriodInDays": 7,
9999
"ExecutionTimeout": 300
100100
},
101-
"path": "./src/parallel.py"
101+
"path": "./src/parallel/parallel.py"
102102
},
103103
{
104104
"name": "Map Operations",
@@ -109,7 +109,7 @@
109109
"RetentionPeriodInDays": 7,
110110
"ExecutionTimeout": 300
111111
},
112-
"path": "./src/map_operations.py"
112+
"path": "./src/map/map_operations.py"
113113
},
114114
{
115115
"name": "Block Example",
@@ -120,7 +120,7 @@
120120
"RetentionPeriodInDays": 7,
121121
"ExecutionTimeout": 300
122122
},
123-
"path": "./src/block_example.py"
123+
"path": "./src/block_example/block_example.py"
124124
},
125125
{
126126
"name": "Logger Example",
@@ -131,7 +131,7 @@
131131
"RetentionPeriodInDays": 7,
132132
"ExecutionTimeout": 300
133133
},
134-
"path": "./src/logger_example.py"
134+
"path": "./src/logger_example/logger_example.py"
135135
},
136136
{
137137
"name": "Steps with Retry",
@@ -142,7 +142,7 @@
142142
"RetentionPeriodInDays": 7,
143143
"ExecutionTimeout": 300
144144
},
145-
"path": "./src/steps_with_retry.py"
145+
"path": "./src/step/steps_with_retry.py"
146146
},
147147
{
148148
"name": "Wait for Condition",
@@ -153,7 +153,7 @@
153153
"RetentionPeriodInDays": 7,
154154
"ExecutionTimeout": 300
155155
},
156-
"path": "./src/wait_for_condition.py"
156+
"path": "./src/wait_for_condition/wait_for_condition.py"
157157
}
158158
]
159159
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)