-
Notifications
You must be signed in to change notification settings - Fork 90
fix: make arns of all task resources aws-partition aware #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
7a38877
723214e
bee2953
0c9b0f0
162f9db
ae85706
33d624b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,32 @@ | |
# permissions and limitations under the License. | ||
from __future__ import absolute_import | ||
|
||
from enum import Enum | ||
from stepfunctions.steps.states import Task | ||
from stepfunctions.steps.fields import Field | ||
from stepfunctions.steps.utils import resource_integration_arn_builder | ||
from stepfunctions.steps.integration_resources import IntegrationPattern, IntegrationServices, LambdaApi, GlueApi, BatchApi, EcsApi | ||
from stepfunctions.steps.utils import get_service_integration_arn | ||
from stepfunctions.steps.integration_resources import IntegrationPattern | ||
|
||
Lambda = "lambda" | ||
Glue = "glue" | ||
Ecs = "ecs" | ||
Batch = "batch" | ||
|
||
|
||
class LambdaApi(Enum): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit (not blocking): Not necessary to be a class |
||
Invoke = "invoke" | ||
|
||
|
||
class GlueApi(Enum): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not blocking: also agree that these don't need to be classes. If you do keep them as classes, we should include docstrings that explain what they are and their purpose :) |
||
StartJobRun = "startJobRun" | ||
|
||
|
||
class EcsApi(Enum): | ||
RunTask = "runTask" | ||
|
||
|
||
class BatchApi(Enum): | ||
SubmitJob = "submitJob" | ||
|
||
|
||
class LambdaStep(Task): | ||
|
@@ -44,14 +66,16 @@ def __init__(self, state_id, wait_for_callback=False, **kwargs): | |
""" | ||
Example resource arn: arn:aws:states:::lambda:invoke.waitForTaskToken | ||
""" | ||
kwargs[Field.Resource.value] = resource_integration_arn_builder(IntegrationServices.Lambda, | ||
LambdaApi.Invoke, | ||
IntegrationPattern.WaitForTaskToken) | ||
|
||
kwargs[Field.Resource.value] = get_service_integration_arn(Lambda, | ||
LambdaApi.Invoke, | ||
IntegrationPattern.WaitForTaskToken) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: indentation is off There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will fix |
||
else: | ||
""" | ||
Example resource arn: arn:aws:states:::lambda:invoke | ||
""" | ||
kwargs[Field.Resource.value] = resource_integration_arn_builder(IntegrationServices.Lambda, LambdaApi.Invoke) | ||
|
||
kwargs[Field.Resource.value] = get_service_integration_arn(Lambda, LambdaApi.Invoke) | ||
|
||
|
||
super(LambdaStep, self).__init__(state_id, **kwargs) | ||
|
@@ -82,15 +106,17 @@ def __init__(self, state_id, wait_for_completion=True, **kwargs): | |
""" | ||
Example resource arn: arn:aws:states:::glue:startJobRun.sync | ||
""" | ||
kwargs[Field.Resource.value] = resource_integration_arn_builder(IntegrationServices.Glue, | ||
GlueApi.StartJobRun, | ||
IntegrationPattern.WaitForCompletion) | ||
|
||
kwargs[Field.Resource.value] = get_service_integration_arn(Glue, | ||
GlueApi.StartJobRun, | ||
IntegrationPattern.WaitForCompletion) | ||
else: | ||
""" | ||
Example resource arn: arn:aws:states:::glue:startJobRun | ||
""" | ||
kwargs[Field.Resource.value] = resource_integration_arn_builder(IntegrationServices.Glue, | ||
GlueApi.StartJobRun) | ||
|
||
kwargs[Field.Resource.value] = get_service_integration_arn(Glue, | ||
GlueApi.StartJobRun) | ||
|
||
super(GlueStartJobRunStep, self).__init__(state_id, **kwargs) | ||
|
||
|
@@ -120,15 +146,17 @@ def __init__(self, state_id, wait_for_completion=True, **kwargs): | |
""" | ||
Example resource arn: arn:aws:states:::batch:submitJob.sync | ||
""" | ||
kwargs[Field.Resource.value] = resource_integration_arn_builder(IntegrationServices.Batch, | ||
BatchApi.SubmitJob, | ||
IntegrationPattern.WaitForCompletion) | ||
|
||
kwargs[Field.Resource.value] = get_service_integration_arn(Batch, | ||
BatchApi.SubmitJob, | ||
IntegrationPattern.WaitForCompletion) | ||
else: | ||
""" | ||
Example resource arn: arn:aws:states:::batch:submitJob | ||
""" | ||
kwargs[Field.Resource.value] = resource_integration_arn_builder(IntegrationServices.Batch, | ||
BatchApi.SubmitJob) | ||
|
||
kwargs[Field.Resource.value] = get_service_integration_arn(Batch, | ||
BatchApi.SubmitJob) | ||
|
||
super(BatchSubmitJobStep, self).__init__(state_id, **kwargs) | ||
|
||
|
@@ -158,14 +186,16 @@ def __init__(self, state_id, wait_for_completion=True, **kwargs): | |
""" | ||
Example resource arn: arn:aws:states:::ecs:runTask.sync | ||
""" | ||
kwargs[Field.Resource.value] = resource_integration_arn_builder(IntegrationServices.ECS, | ||
EcsApi.RunTask, | ||
IntegrationPattern.WaitForCompletion) | ||
|
||
kwargs[Field.Resource.value] = get_service_integration_arn(Ecs, | ||
EcsApi.RunTask, | ||
IntegrationPattern.WaitForCompletion) | ||
else: | ||
""" | ||
Example resource arn: arn:aws:states:::ecs:runTask | ||
""" | ||
kwargs[Field.Resource.value] = resource_integration_arn_builder(IntegrationServices.ECS, | ||
EcsApi.RunTask) | ||
|
||
kwargs[Field.Resource.value] = get_service_integration_arn(Ecs, | ||
EcsApi.RunTask) | ||
|
||
super(EcsRunTaskStep, self).__init__(state_id, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Variable names should written be in
snake_case
. Class names arePascalCase
. Constants inCAPITAL_SNAKE_CASE
. Repeats.