deployable-awscdk-app-ts
Version:
A projen project for Typescript AWS CDK App
240 lines (239 loc) • 11.1 kB
TypeScript
import { javascript } from 'projen';
import { JobStep, Job } from 'projen/lib/github/workflows-model';
import { CodeArtifactAuthProvider } from 'projen/lib/javascript';
import { DeployJobStrategy, DeployOptions, EnvironmentDeploymentDependencies, EnvironmentOptions } from './types';
export interface DeployableAwsCdkTypeScriptAppStepsFactoryProps {
/**
* Deployment options
*/
readonly deployOptions: DeployOptions;
/**
* Whether to check for active deployments before proceeding with deployment
*/
readonly checkActiveDeployment: boolean;
/**
* The name of the task to run before installing dependencies, if any
*/
readonly preInstallTaskName?: string;
/**
* The authentication provider for CodeArtifact, if any
*/
readonly authProvider?: CodeArtifactAuthProvider;
/**
* The npm config to set with the environment that is being deployed, if any
* Note: This is not supported for node versions above 18
*/
readonly npmConfigEnvironment?: string;
/**
* Deployment job strategy, whether to use a matrix job or multiple jobs for each environment
*/
readonly jobStrategy: DeployJobStrategy;
/**
* Environment deployment dependencies, if any
*/
readonly environmentDependencies?: EnvironmentDeploymentDependencies;
}
/**
* Factory to create reusable steps for the deployment workflow
* @experimental
*/
export declare class DeployableAwsCdkTypeScriptAppStepsFactory {
private readonly project;
private readonly props;
/**
* Validate that the provided environment deployment dependencies are valid
* @param deployOptions The deployment options
* @param environmentDependencies The environment deployment dependencies to validate
*/
static validateEnvironmentDeploymentDependencies(deployOptions: DeployOptions, environmentDependencies: EnvironmentDeploymentDependencies): void;
/**
* Create a new DeployableAwsCdkTypeScriptAppStepsFactory
* @param project The project
* @param props The factory properties
*/
constructor(project: javascript.NodeProject, props: DeployableAwsCdkTypeScriptAppStepsFactoryProps);
/**
* Condition to skip a step if an active deployment is already present
* @returns JobStep condition or undefined if checkActiveDeployment is false
*/
get skipIfAlreadyActiveDeploymentCondition(): JobStep | undefined;
get checkoutStep(): JobStep;
/**
* Step to run before installing dependencies if exists
* @returns JobStep or undefined if no preInstallTaskName is provided
*/
get preInstallDependenciesStep(): JobStep | undefined;
/**
* Step to check if there is an active deployment for the environment in the matrix strategy
* @returns JobStep
*/
get checkActiveDeploymentStepForMatrix(): JobStep | undefined;
/**
* Step to check if there is an active deployment for a specific environment
* @param environment The environment to check
* @returns JobStep
*/
getCheckActiveDeploymentStepForEnvironment(environment: string): JobStep | undefined;
/**
* Step to setup AWS credentials in the environment for the matrix strategy
* @returns JobStep[]
*/
get setupAwsCredentialsStepsForMatrix(): JobStep[];
/**
* Get the steps to setup AWS credentials for a specific environment
* @param environmentOptions The environment options
* @returns JobStep[]
*/
getSetupAwsCredentialsStepsForEnvironment(environmentOptions: EnvironmentOptions): JobStep[];
/**
* Step to setup AWS credentials in the environment for the matrix strategy
* @returns JobStep
*/
get setupAwsCredentialsInEnvironmentForMatrix(): JobStep;
/**
* Step to setup AWS credentials in the environment for a specific environment
* @param assumeRoleFlag Whether to assume a role, can be a boolean or a string for matrix strategy
* @param accessKeyIdSecretName The GitHub secret name for the access key ID
* @param secretAccessKeySecretName The GitHub secret name for the secret access key
* @param region The region
* @returns JobStep or undefined if no AWS credentials are provided,
* if assumeRoleFlag is boolean will be evaluated and return a JobStep only if false
* if assumeRoleFlag is string will always return a JobStep (for matrix strategy)
*/
getSetupAwsCredentialsInEnvironmentForEnvironment(assumeRoleFlag: boolean | string, accessKeyIdSecretName: string, secretAccessKeySecretName: string, region: string): JobStep | undefined;
/**
* Step to assume an AWS role for the matrix strategy
* @returns JobStep
*/
get assumeAwsRoleStepForMatrix(): JobStep;
/**
* Step to assume an AWS role for a specific environment
* @param assumeRoleFlag Whether to assume a role, can be a boolean or a string for matrix strategy
* @param accessKeyIdSecretName The GitHub secret name for the access key ID
* @param secretAccessKeySecretName The GitHub secret name for the secret access key
* @param region The region
* @param roleToAssume The role to assume
* @param assumeRoleDurationSeconds The duration for assuming the role
* @returns JobStep or undefined if assumeRoleFlag is boolean and false
* if assumeRoleFlag is string will always return a JobStep (for matrix strategy)
*/
getAssumeAwsRoleStepForEnvironment(assumeRoleFlag: boolean | string, accessKeyIdSecretName: string, secretAccessKeySecretName: string, region: string, roleToAssume: string, assumeRoleDurationSeconds?: string | number): JobStep | undefined;
/**
* Step to setup NPM config if provided
* @returns JobStep or undefined if no npmConfig is provided
*/
get setupNpmConfigForMatrix(): JobStep | undefined;
getSetupNpmConfigForEnvironment(environment: string): JobStep | undefined;
/**
* Get the step to run a specific script
* @param scriptName The name of the script to run
* @param stepName The name of the step in the workflow
* @param hasScriptFlag Whether the script should be run
* @returns The job step to run the script or undefined if not applicable
* If hasScriptFlag is boolean and false will return undefined
* If hasScriptFlag is string will always return a JobStep (for matrix strategy)
*/
getRunScriptStep(scriptName: string, stepName: string, hasScriptFlag: boolean | string): JobStep | undefined;
/**
* Step to deploy the workflow
* @returns JobStep
*/
get deploymentStep(): JobStep;
/**
* Step to run post deployment script in matrix strategy
* @returns JobStep
*/
get preDeploymentStepForMatrix(): JobStep;
/**
* Get the pre-deployment step for a specific environment
* @param hasPreDeployTaskFlag Whether the pre-deployment task should be run
* @param preDeploymentScript The script to run
* @returns The job step to run the pre-deployment script or undefined if not applicable
* If hasPreDeployTaskFlag is boolean and false will return undefined
* If hasPreDeployTaskFlag is string will always return a JobStep (for matrix strategy)
*/
getPreDeploymentStepForEnvironment(hasPreDeployTaskFlag: boolean | string, preDeploymentScript: string): JobStep | undefined;
/**
* Step to run post deployment script in matrix strategy
* @returns JobStep
*/
get postDeploymentStepForMatrix(): JobStep;
/**
* Get the post-deployment step for a specific environment
* @param hasPostDeployTaskFlag Whether the post-deployment task should be run
* @param postDeploymentScript The script to run
* @returns The job step to run the post-deployment script or undefined if not applicable
* If hasPostDeployTaskFlag is boolean and false will return undefined
* If hasPostDeployTaskFlag is string will always return a JobStep (for matrix strategy)
*/
getPostDeploymentStepForEnvironment(hasPostDeployTaskFlag: boolean | string, postDeploymentScript: string): JobStep | undefined;
/**
* Get all deployment jobs whether for matrix strategy or not
* @returns Record of jobs
*/
get deploymentJobs(): Record<string, Job>;
/**
* Get deployment jobs for matrix strategy
* @returns Record of jobs
*/
get deploymentJobsForMatrix(): Record<string, Job>;
/**
* Get the IDs of the jobs that must be completed before the specified environment's deployment job
* @param environmentName The name of the environment
* @returns An array of job IDs
*/
getDeploymentJobPrerequisiteJobIds(environmentName: string): string[];
/**
* Get deployment jobs for multi-job strategy
* @returns Record of jobs
*/
get deploymentJobsForMultiJob(): Record<string, Job>;
/**
* Get the job definition for a specific environment
* @param environmentOptions The environment options
* @param environmentVariableName The name of the environment variable to set with the environment name, if any
* @returns The job definition for the environment
*/
getJobForEnvironment(environmentOptions: EnvironmentOptions, environmentVariableName: string | undefined): Job;
/**
* Step to generate the diff output
* @returns JobStep
*/
get generateDiffStep(): JobStep;
/**
* Get the job to annotate the PR with the diff output for all environments
* @param dependentJobNames The names of the jobs that the annotation job depends on
* @returns The job definition for annotating the PR with the diff output
*/
getAnnotateDiffJob(dependentJobNames: string[]): Job;
/**
* Get the step to format the diff output into a GitHub annotation comment for a specific environment
* @param environment The environment to format the diff for
* @returns JobStep
*/
getFormattedDiffAnnotationCommentStepForEnvironment(environment: string): JobStep;
/**
* Get the deployment method argument for the deploy command
* @param environmentOptions The environment options
* @param environmentVariableName The name of the environment variable to set with the environment name, if any
* @returns The diff annotation job for the environment
*/
getDiffAnnotationJobForEnvironment(environmentOptions: EnvironmentOptions, environmentVariableName: string | undefined): Job;
/**
* Get diff annotation jobs for all environments
* @returns Record of jobs
*/
get diffAnnotationJobs(): Record<string, Job>;
}
/**
* Get the deploy job ID for a specific environment
* @param environmentName The name of the environment
* @returns The deploy job ID
*/
export declare function getDeployJobId(environmentName: string): string;
/**
* Get the diff annotation job ID for a specific environment
* @param environmentName The name of the environment
* @returns The diff annotation job ID
*/
export declare function getDiffAnnotationJobId(environmentName: string): string;