Closed ca-nguyen closed 2 years ago
Thanks for the review @shivlaks !
all the locations where a service integration pattern is now accepted also need a test case exercising an "unsupported" integration pattern.
Added the unite tests for unsupported integration_patterns
in the latest commit
I also added the integration_pattern
arg in the EksCallStep
constructor for consistency with the other steps (it was the only one that was missing - omitted previously since it only supports one of the integration patterns)
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository
Description
Update Amazon EKS service integration to use
integration_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 in commit (Add support for Nested Step Functions) that uses the
integration_pattern
arg in the step constructor to build the resource.Support for Amazon EKS service integration was added in this commit, but not released yet. A later commit (Add support for Nested Step Functions) introduced a new implementation pattern using the
IntegrationPattern
enum as input to construct the step instead of thewait_for_completion
flag. (See PR for more detail on rationale behind the implementation).Solution
Replace the
wait_for_completion
flag withintegration_pattern
arg for the step construction:IntegrationPattern
is used to build theResource
arn as follow:See Service Integration Patterns for more details
Apply changes to the following steps:
arn:aws:states:::eks:runJob
arn:aws:states:::eks:runJob.sync
arn: arn:aws:states:::eks:call
rn:aws:states:::eks:createCluster
arn:aws:states:::eks:createCluster.sync
arn:aws:states:::eks:deleteCluster
arn:aws:states:::eks:deleteCluster.sync
arn:aws:states:::eks:createFargateProfile
arn:aws:states:::eks:createFargateProfile.sync
arn:aws:states:::eks:deleteFargateProfile
arn:aws:states:::eks:deleteFargateProfile.sync
arn:aws:states:::eks:createNodegroup
arn:aws:states:::eks:createNodegroup.sync
arn:aws:states:::eks:deleteNodegroup
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
Manual tests
EKS cluster management
Created step machine to test several eks steps (based on the
Manage EKS cluster
sample project):create_node_group_step = EksCreateNodegroupStep( "Create Node Group", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={ 'ClusterName': 'ExampleCluster', 'NodegroupName': 'ExampleNodegroup', 'NodeRole':,
'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 steps
path=Chain([create_cluster_step, create_node_group_step, run_job_step, call_delete_job_step, delete_node_group, delete_cluster_step])
Define workflow
workflow = Workflow( name="EKSStateMachineExample", definition=path, role=
)
workflow.create() workflow.execute()
create_fargate_profile_step = EksCreateFargateProfileStep( "Create Fargate profile", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={ 'ClusterName':,
'FargateProfileName': 'ExampleFargateProfile',
'PodExecutionRoleArn': ,
'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':,
'FargateProfileName': 'ExampleFargateProfile'
}
)
Chain the steps
path=Chain([create_fargate_profile_step, delete_fargate_profile_step])
Define the workflow
workflow = Workflow( name="EKSFargateProfileExample", definition=path, role=
)
workflow.create() workflow.execute()