Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const repository = new Repository(this, 'Repository', {
repositoryName: 'MyRepositoryName',
description: 'Some description.', // optional property
});
const sourceArtifact = new Artifact();
const sourceAction = new CodeCommitSourceAction({
actionName: 'CodeCommit',
repository,
output: sourceArtifact,
});
const project = new PipelineProject(this, 'MyProject');
const buildAction = new CodeBuildAction({
actionName: 'CodeBuild',
project,
input: sourceArtifact,
});
const slackBotToken = process.env.SLACK_BOT_TOKEN as string;
const slackSigningSecret = process.env.SLACK_SIGNING_SECRET as string;
const slackChannel = process.env.SLACK_CHANNEL as string;
const approvalAction = new SlackApprovalAction({
actionName: 'SlackApproval',
slackBotToken,
slackSigningSecret,
slackChannel,
externalEntityLink: 'http://cloudcomponents.org',
additionalInformation:
addTestStage(sourceOutputArtifact: Artifact) {
const integrationTestProject = new IntegrationTestProject(
this,
`IntegrationTests`,
{
stageName: StageName.stg
}
)
const integrationTestOutputArtifact = new Artifact()
const integrationTestAction = new CodeBuildAction({
actionName: 'integration_tests',
input: sourceOutputArtifact,
outputs: [integrationTestOutputArtifact],
project: integrationTestProject
})
const e2eTestProject = new E2ETestProject(this, `e2eTests`, {
stageName: StageName.stg
})
const e2eTestOutputArtifact = new Artifact()
const e2eTestAction = new CodeBuildAction({
actionName: 'e2e_tests',
input: sourceOutputArtifact,
outputs: [e2eTestOutputArtifact],
project: e2eTestProject
}/${
config.sourceRepoName
}.git $CODEBUILD_RESOLVED_SOURCE_VERSION`
]
}
},
artifacts: {
files: '**/*'
}
},
environment: defaultEnvironment,
role: resources.codeBuildRole
}
)
const checkChangesAction = new CodeBuildAction({
actionName: 'check-changes',
input: resources.sourceAction.output,
output: new Artifact(),
project: resources.checkChangesProject
})
resources.checkChangesAction = checkChangesAction
resources.pipeline.addStage({
name: 'check_changes',
actions: [checkChangesAction]
})
}
}
addDeployStage(
stageName: StageName,
orchestratorCodeBuildRole: Role,
sourceOutputArtifact: Artifact
) {
const orchestratorDeployStagingProject = new OrchestratorDeployProject(
this,
`${stageName}OrchestratorDeploy`,
{
stageName,
role: orchestratorCodeBuildRole
}
)
const deployOutputArtifact = new Artifact()
const deployAction = new CodeBuildAction({
actionName: stageName,
input: sourceOutputArtifact,
outputs: [deployOutputArtifact],
project: orchestratorDeployStagingProject
})
this.addStage({
stageName: `${stageName}Deploy`,
actions: [deployAction]
})
}
}
type: BuildEnvironmentVariableType.PLAINTEXT,
value: `${config.defaultRegions[stageName]}`
},
SLIC_STAGE: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: stageName
},
MODULE_NAME: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: moduleName
},
...projectEnvironmentVars
}
const moduleBuildOutputArtifact = new Artifact()
const moduleBuildAction = new CodeBuildAction({
actionName: 'Build',
input: sourceOutputArtifact,
outputs: [moduleBuildOutputArtifact],
project: moduleBuildProject,
role: pipelineRole,
environmentVariables: environmentVars
})
this.addStage({
stageName: 'Build',
actions: [moduleBuildAction]
})
const moduleDeployOutputArtifact = new Artifact()
const moduleDeployAction = new CodeBuildAction({
actionName: 'Deploy',
)
const integrationTestOutputArtifact = new Artifact()
const integrationTestAction = new CodeBuildAction({
actionName: 'integration_tests',
input: sourceOutputArtifact,
outputs: [integrationTestOutputArtifact],
project: integrationTestProject
})
const e2eTestProject = new E2ETestProject(this, `e2eTests`, {
stageName: StageName.stg
})
const e2eTestOutputArtifact = new Artifact()
const e2eTestAction = new CodeBuildAction({
actionName: 'e2e_tests',
input: sourceOutputArtifact,
outputs: [e2eTestOutputArtifact],
project: e2eTestProject
})
this.addStage({
stageName: 'Test',
actions: [integrationTestAction, e2eTestAction]
})
}
new ManualApprovalAction({
actionName: 'MoveToProduction'
})
]
})
this.addDeployStage(
StageName.prod,
orchestratorCodeBuildRole,
sourceOutputArtifact
)
this.addStage({
stageName: 'UpdateDeploymentState',
actions: [
new CodeBuildAction({
actionName: 'UpdateState',
input: sourceOutputArtifact,
project: new UpdateDeploymentStateProject(
this,
'updateDeploymentStateProject',
{
bucketName: this.artifactBucket.bucketName,
role: sourceCodeBuildRole
}
)
})
]
})
}