-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat(stepfunctions-tasks): add EKS call to SFN-tasks #12779
Conversation
Title does not follow the guidelines of Conventional Commits. Please adjust title before merge. |
@shivlaks |
/** | ||
* Name of the cluster | ||
*/ | ||
readonly clusterName: string; |
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.
why not take in an ICluster
and take properties out of it?
question: are step functions executions of EKS restricted to the account in which the state machine resides?
this is available as clusterName
in an ICluster
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.
Will use EKS L2 Construct instead in next commit.
/** | ||
* API endpoint to communicate with your cluster | ||
*/ | ||
readonly endpoint: string; |
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.
this is clusterEndpoint
from an ICluster
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.
Will use EKS L2 Construct instead in next commit.
/** | ||
* Base 64 encoded certificate data required to communicate with your cluster | ||
*/ | ||
readonly certificateAuthority: string; |
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.
this is available as clusterCertificateAuthorityData
from an ICluster
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.
Will use EKS L2 Construct instead in next commit.
/** | ||
* Method type of a EKS call | ||
*/ | ||
export enum MethodType { |
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.
choose a more specific name. It doesn't quite communicate the intent of the enum... maybe something like HttpMethods
or some appropriate qualifier that is less general from a naming perspective
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.
Will Change to HttpMethods in next commit.
import * as cdk from '@aws-cdk/core'; | ||
import { EksCall, MethodType } from '../../lib/eks/call'; | ||
|
||
describe('Call an EKS endpoint', () => { |
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.
missing tests for invalid service integration pattern (i.e. an error is thrown if RUN_JOB
is selected)
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.
Will add tests for run a job pattern in next commit.
|
||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, 'aws-stepfunctions-tasks-eks-call-integ'); |
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.
this test is not self contained. Please include verification steps, but more importantly create the EKS cluster as a part of the integration test.
The test should create a state machine that can be executed successfully. Right now it has a dependency that an EKS job already exists called clusterName
, but this is not self-contained.
Verification steps should look something like this
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.
Modified integ test in the latest commit
Pull request has been modified.
Commit: b831188 Description:
Testing:
|
It looks like the fix is complete. Would you please re-review it? |
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.
getting closer! - would also love a review/input from @iliapolo who is the maintainer of the eks
module in the cdk
]; | ||
|
||
protected readonly taskMetrics?: sfn.TaskMetricsConfig; | ||
protected readonly taskPolicies?: iam.PolicyStatement[]; |
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.
probably worth a comment why task policies are not being set in this integration
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.
Added a comment in latest commit.
requestBody: sfn.TaskInput.fromObject({ | ||
RequestBody: 'requestBody', | ||
}), |
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.
should the type of requestBody
be sfn.TaskInput
? it's currently not configured in that way.
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.
Yes, that's a good point. Changed the requestBody
to be sfn.TaskInput
readonly httpPath: string; | ||
|
||
/** | ||
* Query Parameters part of HTTP request |
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: would be helpful to include doc links and or purpose of query parameters. the current doc strings don't add much information from the parameter names
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.
Query parameters would look something like this: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#-strong-write-operations-cronjob-v1beta1-batch-strong- I'm not sure if it would be helpful to include an example such as this
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.
gotcha, I agree. maybe using it in the readme example would be helpful for users though.
* Request body part of HTTP request | ||
* @default - No request body | ||
*/ | ||
readonly requestBody?: { [key: string]: any }; |
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.
this does not support paths: i.e. how could you supply $.blah
please change the type to sfn.TaskInput
and also add a test for it.
the same applies to any parameters that support state input json path.
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.
Changed to sfn.TaskInput and added more coverage tests
Pull request has been modified.
Updating branch to re-trigger build |
CertificateAuthority: this.props.cluster.clusterCertificateAuthorityData, | ||
Endpoint: this.props.cluster.clusterEndpoint, |
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.
Are these parameters required for successfully making the call? Note that if ICluster
is imported, these properties might not be defined, and will throw an exception.
I would extract these and do:
try {
const ca = this.props.cluster.clusterCertificateAuthorityData;
} catch (err) {
// if its required, throw an error here with the right context
// if its not required, just pass
}
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.
Thanks for the feedback, I'll add validation for ClusterName, ClusterEndpoint and clusterCertificateAuthorityData, as well as coverage tests for these cases
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.
With some testing I think the error thrown from the eks module has the valid context in our case.
for eks:call I'm extracting clusterName
, clusterEndpoint
, and clusterCertificateAuthorityData
from ICluster, for example if clusterEndpoint is not defined, it will throw exception with message "clusterEndpoint" is not defined for this imported cluster
, which is sufficient to show the context of the error.
All three are required to make the call, I'll just add coverage test to reflect this case
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.
@shivlaks Do you think "clusterEndpoint" is not defined for this imported cluster
is sufficient or more details needs to be added such as Cluster Endpoint is not defined for this imported cluster, this field is required for eks:call task.
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.
@NovakGu that seems sensible. let's keep it simple. I generally like the format of <validation error><remediation (if any)>
i.e.
The clusterEndpoint
property must be specified when using an imported Cluster.
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.
@shivlaks @iliapolo
Added validation for clusterEndpoint
and clusterCertificateAuthorityData
.
clusterName
is required when import a cluster or creating a new cluster so I'm not double checking it here.
After changes
- if an given cluster does not have cluster Endpoint it will throw with error
The "clusterEndpoint" property must be specified when using an imported Cluster.
- If an given cluster does not have certAuth it will throw with error
The "clusterCertificateAuthorityData" property must be specified when using an imported Cluster.
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.
LGTM. added a do-not-merge
so @iliapolo can also take a look in case he had any additional feedback.
LGTM |
Taking over the ownership of original PR #11738
feat(stepfunctions-tasks): support for EKS Call
Implementation
Update package @aws-cdk/aws-stepfunctions-tasks to include support for EKS Call
API as per documentation here:
https://docs.aws.amazon.com/step-functions/latest/dg/connect-eks.html
Includes support for the following Amazon EKS API calls:
eks:call
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license