-
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(pipelines): stack-level steps #16215
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.
I like where this is going!
for (const approval of props.changeSetApproval) { | ||
for (const stack of approval.stacks) { | ||
// getStackByName will throw if stack does not exist | ||
const stackArtifact = assembly.getStackByName(stack.stackName); |
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 think I'd rather select the stack by selecting by construct path, that's guaranteed to be unique while stackName
is only likely to be unique.
stack.node.path
is the path, not sure which assembly.getStack()
you need to be using there. It might not exist, in which case you have to iterate over all artifacts, check only for the stack artifacts and compare the nodePath
(or hierarchicalId
) attributes.
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.
am hoping that the change to assembly.getStackArtifact(stackstep.stack.artifactId)
suffices.
packages/@aws-cdk/pipelines/lib/helpers-internal/pipeline-graph.ts
Outdated
Show resolved
Hide resolved
|
||
retGraph.add(stackGraph); | ||
|
||
stackGraph.add(deployNode); | ||
let firstDeployNode; | ||
if (prepareNode) { | ||
stackGraph.add(prepareNode); | ||
deployNode.dependOn(prepareNode); | ||
firstDeployNode = prepareNode; | ||
if (preNodeChain) { |
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 don't mind this tangle of if
s as a first pass to make it work, but I think there's more beautiful code in there that is more clear with less case analysis.
We want to express something like this:
if (changeSet && !prepare) {
throw error
}
// pre here
// prepare here
// changeset here
// deploy here
// post here
Feels that with a couple of properly-chosen helper functions (that deal transparently with undefined
s or empty arrays) we could get the code to read a lot more straightforward.
WDYT?
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 may need more discussion. Agree that the if
s is ugly. With my latest attempt to remove the node chains
, I've decided to utilize the existing addPrePost()
and add my own addChangeSet()
method. Now, the logic follows similarly to addWave
and other areas where it looks more like this:
// prepare here
// deploy here
// pre/changeset/post here, if necessary
While I do think there is still opportunity to clean things up, you may have to elaborate more on the properly-chosen helper functions to achieve this.
} | ||
for (const p of post) { | ||
const postNode = this.addAndRecurse(p, parent); | ||
postNode?.dependOn(...currentNodes.nodes); | ||
} | ||
return preNodes; |
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.
Not sure if modifying addPrePost()
like this is acceptable. The alternative option is to reuse a lot of this code, since all I really want to do is return a NodeCollection
to add stack-level dependencies on it later.
stackGraph.add(deployNode); | ||
|
||
// node or node collection that represents first point of contact in each stack | ||
let firstDeployNode; |
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.
it feels a little wrong to continue calling this firstDeployNode
given that it could be a node collection, but I'm not sure if it is that big of a deal.
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 like it!
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). |
Stack-level steps are available via the legacy API but not the modern API. This PR introduces the
stackSteps
property toAddStageOpts
, allowing the user to specify additional steps at the stack level rather than the stage level. You can specify a step using thepre
,changeSet
orpost
options.pre
steps happen beforestack.prepare
.changeSet
steps happen betweenstack.prepare
andstack.deploy
.post
steps happen afterstack.deploy
.A primary use case is to add a
ManualApprovalStep
instackSteps.changeSet
to verify changes to the stack before deployment.Closes #16148.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license