Skip to content

Commit

Permalink
feat: expose the regenerateAllDocumentationPerPackage state machine (#…
Browse files Browse the repository at this point in the history
…1494)

Exposes the orchestration construct. This is useful if you need to use
parts of within a large scope. For example, if you need to start the
execution of the `regenerateAllDocumentationPerPackage` in the
integration step of a CI/CD pipeline:

```ts
const constructHub = new ConstructHub(/*...*/);
constructHub.regenerateAllDocumentationPerPackage.grantPrincipal.addToPrincipalPolicy(
  new PolicyStatement({
    effect: Effect.ALLOW,
    actions: ['sts:AssumeRole'],
    principals: [cicdRole],
  })
);
```

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
  • Loading branch information
otaviomacedo authored Oct 8, 2024
1 parent 40aabdf commit 524ac52
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
13 changes: 13 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions src/backend/orchestration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ export class Orchestration extends Construct {
*/
public readonly regenerateAllDocumentation: IStateMachine;

/**
* The function operators can use to reprocess a specific package version
* through the backend data pipeline.
*/
public readonly regenerateAllDocumentationPerPackage: IStateMachine;

/**
* The function that builds the catalog.
*/
Expand Down Expand Up @@ -513,14 +519,17 @@ export class Orchestration extends Construct {

// The workflow is intended to be manually triggered by an operator to
// reprocess all package versions currently in store through the orchestrator.
this.regenerateAllDocumentation = new RegenerateAllDocumentation(
const regenerateAllDocumentation = new RegenerateAllDocumentation(
this,
'RegenerateAllDocumentation',
{
bucket: props.bucket,
stateMachine: this.stateMachine,
}
).stateMachine;
);
this.regenerateAllDocumentation = regenerateAllDocumentation.stateMachine;
this.regenerateAllDocumentationPerPackage =
regenerateAllDocumentation.processPackageVersions;

props.overviewDashboard.addConcurrentExecutionMetricToDashboard(
needsCatalogUpdateFunction,
Expand Down Expand Up @@ -671,6 +680,7 @@ interface RegenerateAllDocumentationProps {

class RegenerateAllDocumentation extends Construct {
public readonly stateMachine: StateMachine;
public readonly processPackageVersions: StateMachine;

public constructor(
scope: Construct,
Expand Down Expand Up @@ -772,6 +782,7 @@ class RegenerateAllDocumentation extends Construct {
timeout: Duration.hours(1),
tracingEnabled: true,
});
this.processPackageVersions = processPackageVersions;

// This workflow is broken into two sub-workflows because otherwise it hits the 25K events limit
// of StepFunction executions relatively quickly.
Expand Down
9 changes: 9 additions & 0 deletions src/construct-hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
FeatureFlags,
Category,
} from './webapp';
import { IStateMachine } from 'aws-cdk-lib/aws-stepfunctions';

/**
* Configuration for generating RSS and ATOM feed for the latest packages
Expand Down Expand Up @@ -269,6 +270,12 @@ export interface CodeArtifactDomainProps {
* Construct Hub.
*/
export class ConstructHub extends Construct implements iam.IGrantable {
/**
* The function operators can use to reprocess a specific package version
* through the backend data pipeline.
*/
public readonly regenerateAllDocumentationPerPackage: IStateMachine;

private readonly ingestion: Ingestion;
private readonly monitoring: Monitoring;

Expand Down Expand Up @@ -407,6 +414,8 @@ export class ConstructHub extends Construct implements iam.IGrantable {
vpcSecurityGroups,
feedBuilder,
});
this.regenerateAllDocumentationPerPackage =
orchestration.regenerateAllDocumentationPerPackage;

// rebuild the catalog when the deny list changes.
denyList.prune.onChangeInvoke(orchestration.catalogBuilder.function);
Expand Down

0 comments on commit 524ac52

Please sign in to comment.