Description
Update Amazon EKS service integration to useintegration_pattern input instead orwait_for_completion flag.
Fixes #(issue) -N/A
Why is the change necessary?
This change is necessary for consistency with the new service integration implementation pattern introduced incommit (Add support for Nested Step Functions) that uses theintegration_pattern arg in the step constructor to build the resource.
Support for Amazon EKS service integration was added in thiscommit, but notreleased yet.
A latercommit (Add support for Nested Step Functions) introduced a new implementation pattern using theIntegrationPattern enum as input to construct the step instead of thewait_for_completion flag. (SeePR for more detail on rationale behind the implementation).
Solution
Replace thewait_for_completion flag withintegration_pattern arg for the step construction:
TheIntegrationPattern is used to build theResource arn as follow:
| IntegrationPattern | Resource | Doc |
|---|
| WaitForCompletion | "arn:aws:states:::states:eks:createCluster.sync" | Run A job |
| CallAndContinue | "arn:aws:states:::states:eks:createCluster" | Request Response |
SeeService Integration Patterns for more details
Apply changes to the following steps:
- EksRunJob to create a Task state that allows you to run a job on your Amazon EKS cluster
- CallAndContinue:
arn:aws:states:::eks:runJob - WaitForCompletion:
arn:aws:states:::eks:runJob.sync
- EksCall to create a Task state that allows you to use the Kubernetes API to read and write Kubernetes resource objects via a Kubernetes API endpoint
- CallAndContinue:
arn: arn:aws:states:::eks:call
- EksCreateClusterStep to create a Task state that creates an Amazon EKS cluster
- CallAndContinue: a
rn:aws:states:::eks:createCluster - WaitForCompletion:
arn:aws:states:::eks:createCluster.sync
- EksDeleteClusterStep to create a Task state that deletes an Amazon EKS cluster
- CallAndContinue:
arn:aws:states:::eks:deleteCluster - WaitForCompletion:
arn:aws:states:::eks:deleteCluster.sync
- EksCreateFargateProfileStep to create a Task state that creates a Fargate profile
- CallAndContinue:
arn:aws:states:::eks:createFargateProfile - WaitForCompletion:
arn:aws:states:::eks:createFargateProfile.sync
- EksDeleteFargateProfileStep to create a Task state that deletes a Fargate profile
- CallAndContinue:
arn:aws:states:::eks:deleteFargateProfile - WaitForCompletion:
arn:aws:states:::eks:deleteFargateProfile.sync
- EksCreateNodeGroupStep to create a Task state that creates a node group
- CallAndContinue:
arn:aws:states:::eks:createNodegroup - WaitForCompletion:
arn:aws:states:::eks:createNodegroup.sync
- EksDeleteNodeGroupStep to create a Task state that deletes a node group
- CallAndContinue:
arn:aws:states:::eks:deleteNodegroup - WaitForCompletion:
arn:aws:states:::eks:deleteNodegroup.sync
Normally, replacing a constructor argument would be a breaking change, but since we have not released support for Amazon EKS service integration yet, it is acceptable to do so. After next release, it making such changes will be considered as not being backward compatible.
Testing
- Updated unit tests for all resources
- No integ tests added as external resources were required for testing
- Manual test done for all resources
Manual tests
EKS cluster management
Created step machine to test several eks steps (based on theManage EKS cluster sample project):
create_cluster_step = EksCreateClusterStep( "Create Eks cluster", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={ 'Name': 'ExampleCluster', 'ResourcesVpcConfig': { 'SubnetIds': [ 'subnet-XXXXXXXXXXXXXXXXX', 'subnet-XXXXXXXXXXXXXXXXX' ] }, 'RoleArn': <execution_role_arn> }, result_path="$.eks")create_node_group_step = EksCreateNodegroupStep( "Create Node Group", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={ 'ClusterName': 'ExampleCluster', 'NodegroupName': 'ExampleNodegroup', 'NodeRole': <node_role_arn>, 'Subnets': [ 'subnet-XXXXXXXXXXXXXXXXX', 'subnet-XXXXXXXXXXXXXXXXX' ] }, result_path="$.nodegroup")run_job_step = EksRunJobStep("Run Job", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={ 'ClusterName': 'ExampleCluster', 'CertificateAuthority.$': '$.eks.Cluster.CertificateAuthority.Data', 'Endpoint.$': '$.eks.Cluster.Endpoint', 'LogOptions': { 'RetrieveLogs': True }, 'Job': { 'apiVersion': 'batch/v1', 'kind': 'Job', 'metadata': { 'name': 'example-job' }, 'spec': { 'backoffLimit': 0, 'template': { 'metadata': { 'name': 'example-job' }, 'spec': { 'containers': [ { 'name': 'pi-20', 'image': 'perl', 'command': ['perl'], 'args': [ '-Mbignum=bpi', '-wle', 'print bpi(20)' ] } ], 'restartPolicy': 'Never' } } } } }, result_path="$.RunJobResult")call_delete_job_step = EksCallStep("Call", parameters={ 'ClusterName': 'ExampleCluster', 'CertificateAuthority.$': '$.eks.Cluster.CertificateAuthority.Data', 'Endpoint.$': '$.eks.Cluster.Endpoint', 'Method': 'DELETE', 'Path': '/apis/batch/v1/namespaces/default/jobs/example-job', })delete_node_group = EksDeleteNodegroupStep( "Delete Node Group", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={ 'ClusterName': 'ExampleCluster', 'NodegroupName': 'ExampleNodegroup' })delete_cluster_step = EksDeleteClusterStep( "Delete Eks cluster", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={ 'Name': 'ExampleCluster' })# Chain the stepspath=Chain([create_cluster_step, create_node_group_step, run_job_step, call_delete_job_step, delete_node_group, delete_cluster_step])# Define workflowworkflow = Workflow( name="EKSStateMachineExample", definition=path, role=<workflow_execution_arn>)workflow.create()workflow.execute()
Fargate profile creation/deletion test
Using an existing cluster <cluster_name>, create Fargate profile and delete it once profile creation succeeds
create_fargate_profile_step = EksCreateFargateProfileStep( "Create Fargate profile", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={ 'ClusterName': <cluster_name>, 'FargateProfileName': 'ExampleFargateProfile', 'PodExecutionRoleArn': <pod_execution_role_arn>, 'Selectors': [{ 'Namespace': 'my-namespace', 'Labels': {'my-label': 'my-value'} }], 'Subnets': [ 'subnet-XXXXXXXX' ] })delete_fargate_profile_step = EksDeleteFargateProfileStep( "Delete Fargate profile", integration_pattern=IntegrationPattern.CallAndContinue, parameters={ 'ClusterName': <cluster_name>, 'FargateProfileName': 'ExampleFargateProfile' })# Chain the stepspath=Chain([create_fargate_profile_step, delete_fargate_profile_step])# Define the workflowworkflow = Workflow( name="EKSFargateProfileExample", definition=path, role=<workflow_execution_role>)workflow.create()workflow.execute()
Pull Request Checklist
Please check all boxes (including N/A items)
Testing
Documentation
Title and description
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.
Uh oh!
There was an error while loading.Please reload this page.
Description
Update Amazon EKS service integration to use
integration_patterninput instead orwait_for_completionflag.Fixes #(issue) -N/A
Why is the change necessary?
This change is necessary for consistency with the new service integration implementation pattern introduced incommit (Add support for Nested Step Functions) that uses the
integration_patternarg in the step constructor to build the resource.Support for Amazon EKS service integration was added in thiscommit, but notreleased yet.
A latercommit (Add support for Nested Step Functions) introduced a new implementation pattern using the
IntegrationPatternenum as input to construct the step instead of thewait_for_completionflag. (SeePR for more detail on rationale behind the implementation).Solution
Replace the
wait_for_completionflag withintegration_patternarg for the step construction:The
IntegrationPatternis used to build theResourcearn as follow:SeeService Integration Patterns for more details
Apply changes to the following steps:
arn:aws:states:::eks:runJobarn:aws:states:::eks:runJob.syncarn: arn:aws:states:::eks:callrn:aws:states:::eks:createClusterarn:aws:states:::eks:createCluster.syncarn:aws:states:::eks:deleteClusterarn:aws:states:::eks:deleteCluster.syncarn:aws:states:::eks:createFargateProfilearn:aws:states:::eks:createFargateProfile.syncarn:aws:states:::eks:deleteFargateProfilearn:aws:states:::eks:deleteFargateProfile.syncarn:aws:states:::eks:createNodegrouparn:aws:states:::eks:createNodegroup.syncarn:aws:states:::eks:deleteNodegrouparn:aws:states:::eks:deleteNodegroup.syncNormally, replacing a constructor argument would be a breaking change, but since we have not released support for Amazon EKS service integration yet, it is acceptable to do so. After next release, it making such changes will be considered as not being backward compatible.
Testing
Manual tests
EKS cluster management
Created step machine to test several eks steps (based on the
Manage EKS clustersample project):Fargate profile creation/deletion test
Using an existing cluster <cluster_name>, create Fargate profile and delete it once profile creation succeeds
Pull Request Checklist
Please check all boxes (including N/A items)
Testing
Documentation
Title and description
Fixes #xxx-N/ABy submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.