-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(stepfunctions-tasks): add EKS call to SFN-tasks #12779
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 all commits
ea41033
d6d55e5
fb639aa
b831188
26150b4
db84626
6f545ed
5796a70
1130675
af0dee4
b5556e9
453bd85
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 |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| import * as eks from '@aws-cdk/aws-eks'; | ||
| import * as iam from '@aws-cdk/aws-iam'; | ||
| import * as sfn from '@aws-cdk/aws-stepfunctions'; | ||
| import { Construct } from 'constructs'; | ||
| import { integrationResourceArn, validatePatternSupported } from '../private/task-utils'; | ||
|
|
||
| /** | ||
| * Properties for calling a EKS endpoint with EksCall | ||
| * @experimental | ||
| */ | ||
| export interface EksCallProps extends sfn.TaskStateBaseProps { | ||
|
|
||
| /** | ||
| * The EKS cluster | ||
| */ | ||
| readonly cluster: eks.ICluster; | ||
|
|
||
| /** | ||
| * HTTP method ("GET", "POST", "PUT", ...) part of HTTP request | ||
| */ | ||
| readonly httpMethod: HttpMethods; | ||
|
|
||
| /** | ||
| * HTTP path of the Kubernetes REST API operation | ||
| * For example: /api/v1/namespaces/default/pods | ||
| */ | ||
| readonly httpPath: string; | ||
|
|
||
| /** | ||
| * Query Parameters part of HTTP request | ||
|
Contributor
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: 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
Contributor
Author
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. 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
Contributor
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. gotcha, I agree. maybe using it in the readme example would be helpful for users though. |
||
| * @default - no query parameters | ||
| */ | ||
| readonly queryParameters?: { [key: string]: string[] }; | ||
|
|
||
| /** | ||
| * Request body part of HTTP request | ||
| * @default - No request body | ||
| */ | ||
| readonly requestBody?: sfn.TaskInput; | ||
| } | ||
|
|
||
| /** | ||
| * Call a EKS endpoint as a Task | ||
| * | ||
| * @see https://docs.aws.amazon.com/step-functions/latest/dg/connect-eks.html | ||
| * @experimental | ||
| */ | ||
| export class EksCall extends sfn.TaskStateBase { | ||
|
|
||
| private static readonly SUPPORTED_INTEGRATION_PATTERNS: sfn.IntegrationPattern[] = [ | ||
| sfn.IntegrationPattern.REQUEST_RESPONSE, | ||
| ]; | ||
|
|
||
| /** No policies are required due to eks:call is an Http service integration and does not call and EKS API directly | ||
| * @see https://docs.aws.amazon.com/step-functions/latest/dg/connect-eks.html#connect-eks-permissions | ||
| */ | ||
| protected readonly taskMetrics?: sfn.TaskMetricsConfig; | ||
| protected readonly taskPolicies?: iam.PolicyStatement[]; | ||
|
Contributor
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. probably worth a comment why task policies are not being set in this integration
Contributor
Author
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. Added a comment in latest commit. |
||
|
|
||
| private readonly integrationPattern: sfn.IntegrationPattern; | ||
|
|
||
| private readonly clusterEndpoint: string; | ||
| private readonly clusterCertificateAuthorityData: string; | ||
|
|
||
| constructor(scope: Construct, id: string, private readonly props: EksCallProps) { | ||
| super(scope, id, props); | ||
| this.integrationPattern = props.integrationPattern ?? sfn.IntegrationPattern.REQUEST_RESPONSE; | ||
|
|
||
| validatePatternSupported(this.integrationPattern, EksCall.SUPPORTED_INTEGRATION_PATTERNS); | ||
|
|
||
| try { | ||
| this.clusterEndpoint = this.props.cluster.clusterEndpoint; | ||
| } catch (e) { | ||
| throw new Error('The "clusterEndpoint" property must be specified when using an imported Cluster.'); | ||
| } | ||
|
|
||
| try { | ||
| this.clusterCertificateAuthorityData = this.props.cluster.clusterCertificateAuthorityData; | ||
| } catch (e) { | ||
| throw new Error('The "clusterCertificateAuthorityData" property must be specified when using an imported Cluster.'); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Provides the EKS Call service integration task configuration | ||
| * @internal | ||
| */ | ||
| protected _renderTask(): any { | ||
| return { | ||
| Resource: integrationResourceArn('eks', 'call', this.integrationPattern), | ||
| Parameters: sfn.FieldUtils.renderObject({ | ||
| ClusterName: this.props.cluster.clusterName, | ||
| CertificateAuthority: this.clusterCertificateAuthorityData, | ||
| Endpoint: this.clusterEndpoint, | ||
| Method: this.props.httpMethod, | ||
| Path: this.props.httpPath, | ||
| QueryParameters: this.props.queryParameters, | ||
| RequestBody: this.props.requestBody?.value, | ||
| }), | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Method type of a EKS call | ||
| */ | ||
| export enum HttpMethods { | ||
| /** | ||
| * Retrieve data from a server at the specified resource | ||
| */ | ||
| GET = 'GET', | ||
|
|
||
| /** | ||
| * Send data to the API endpoint to create or update a resource | ||
| */ | ||
| POST = 'POST', | ||
|
|
||
| /** | ||
| * Send data to the API endpoint to update or create a resource | ||
| */ | ||
| PUT = 'PUT', | ||
|
|
||
| /** | ||
| * Delete the resource at the specified endpoint | ||
| */ | ||
| DELETE = 'DELETE', | ||
|
|
||
| /** | ||
| * Apply partial modifications to the resource | ||
| */ | ||
| PATCH = 'PATCH', | ||
|
|
||
| /** | ||
| * Retrieve data from a server at the specified resource without the response body | ||
| */ | ||
| HEAD = 'HEAD' | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.