-
Notifications
You must be signed in to change notification settings - Fork 4k
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 support for CodeBuild StartBuild API #9757
feat(stepfunctions-tasks): add support for CodeBuild StartBuild API #9757
Conversation
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.
hey @DaWyz - this is a valiant effort and we appreciate the contribution.
at a cursory glance, it feels like we are duplicating some of the modeling in the aws-codebuild
module.
I'd suggest taking a step back and scaffolding out support for this service integration.
as a first pass, how about we take a pass without overrides modeled yet.
We will need to support them as well, but to keep this PR moving, it would help substantially to introduce the ability to start a build, by providing an IProject
and any other properties that are not representative of overrides.
what do you think?
packages/@aws-cdk/aws-stepfunctions-tasks/lib/codebuild/start-build.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/codebuild/start-build.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/codebuild/start-build.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/codebuild/start-build.ts
Outdated
Show resolved
Hide resolved
import * as sfn from '@aws-cdk/aws-stepfunctions'; | ||
import * as cdk from '@aws-cdk/core'; | ||
|
||
import { integrationResourceArn, validatePatternSupported } from '../private/task-utils'; |
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 file feels really large, can we break it down?
would any of this apply for StopBuild
- if so we should start moving shared types out.
take a look at the EcsRunTask
service integration for inspiration on how to break this down
'codebuild:BatchGetBuilds', | ||
'codebuild:BatchGetReports', |
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.
does StartBuild
need these permissions? when would they be used?
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.
Good point. I will remove them as I don't think they are useful for the startBuild part.
Do I need codebuild:StopBuild
? I was thinking it might be useful when stopping a Step Function execution but I'm not actually sure stopping the execution would try to stop the codebuild (Haven't tested this part and just started working with Step Functions a couple of weeks ago).
@shivlaks. Thanks for the review. I was kind of hoping you would say that. I was not really happy with the code of this PR (class too big. It was a pain to implement the I like the idea of a smaller PR without having the support for all the override properties. Can I suggest implementing What is the best place to get some help if I need to ask for some guidelines on how to implement things (like the |
Only allowing to pass the CodeBuild project and environment variables for now. The rest to come in future iteration.
@shivlaks, I updated the PR and reduced the scope to only passing the CodeBuild Project and environmentVariables. Could you have a look at it again ? Also, Am I allowed to use the codebuild.CfnProject.EnvironmentVariableProperty |
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.
much cleaner! thanks for simplifying this, it's starting to look pretty close to what i had in mind for a first 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.
nit: don't think these blank lines are needed
* A set of environment variables that overrides, for this build only, | ||
* the latest ones already defined in the build project. | ||
* | ||
* @default No override |
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.
* @default No override | |
* @default - No overrides |
readonly project: codebuild.IProject; | ||
/** | ||
* A set of environment variables that overrides, for this build only, | ||
* the latest ones already defined in the build project. |
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.
does this describe the default behaviour? maybe it belongs as part of the @default
doc string
let startBuild = new tasks.CodeBuildStartBuild(this, 'build-task', { | ||
project: project, | ||
environmentVariablesOverride: { | ||
ZONE: { |
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.
curious: any reason why ZONE
is all caps? or is it case insensitive when compared to the originally defined environment variables which calls it zone
?
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.
I usually set the environment variables in all caps (e.g.: AWS_REGION, NODE_ENV, etc...). Zone is just a random variable name. Happy to change if you think it's confusing.
} | ||
|
||
const app = new cdk.App(); | ||
new StartBuildStack(app, 'aws-stepfunctions-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.
probably better to give this stack name an id that specifies it's a codebuild integ test
EnvironmentVariablesOverride: this.props.environmentVariablesOverride | ||
? codebuild.Project | ||
.serializeEnvVariables(this.props.environmentVariablesOverride) | ||
.map((environmentVariable: codebuild.CfnProject.EnvironmentVariableProperty) => { |
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.
re: your question around codebuild.CfnProject.EnvironmentVariableProperty
- since this is not exposed in the public API / surface area that users can interact with, it's acceptable.
I think it's worth asking whether this is the right mechanism to produce the output we want.
What's the alternative? since the function is pretty small, is it maybe better to avoid converting to this Cfn
type. Since the module is stable and it's a public static method, I don't think it's an issue since it's not exposed. what do you think?
The thing that makes me wary is that ultimately we're producing ASL and not CloudFormation here so it feels like a roundabout way to get there.
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.
I see what you mean. I was just trying to reuse the existing serializeEnvVariables
from the codebuild.Project
class. It's a small method and I can probably go with writing my own and it's going to avoid the round trip.
See the implementation below.
private serializeEnvVariables(environmentVariables: { [name: string]: codebuild.BuildEnvironmentVariable }) {
return Object.keys(environmentVariables).map(name => ({
Name: name,
Type: environmentVariables[name].type || codebuild.BuildEnvironmentVariableType.PLAINTEXT,
Value: environmentVariables[name].value,
}));
}
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.
awesome turnaround on this! we really appreciate the contribution!!! 🎉
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Implementation
Update package
@aws-cdk/aws-stepfunctions-tasks
to include support for CodeBuild StartBuild API as per documentation here: https://docs.aws.amazon.com/step-functions/latest/dg/connect-codebuild.htmlIncludes support for the following Amazon SageMaker API calls:
StartBuild
Closes #8043
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license