in code/csharp/pipelines-workshop/src/CdkWorkshop/PipelineStack.cs [13:57]
public WorkshopPipelineStack(Construct parent, string id, IStackProps props = null) : base(parent, id, props)
{
// Creates a CodeCommit repository called 'WorkshopRepo'
var repo = new Repository(this, "WorkshopRepo", new RepositoryProps
{
RepositoryName = "WorkshopRepo"
});
// The basic pipeline declaration. This sets the initial structure
// of our pipeline
var pipeline = new CodePipeline(this, "Pipeline", new CodePipelineProps
{
PipelineName = "WorkshopPipeline",
// Builds our source code outlined above into a cloud assembly artifact
Synth = new ShellStep("Synth", new ShellStepProps{
Input = CodePipelineSource.CodeCommit(repo, "master"), // Where to get source code to build
Commands = new string[] {
"npm install -g aws-cdk",
"sudo apt-get install -y dotnet-sdk-3.1", // Language-specific install cmd
"dotnet build", // Language-specific build cmd
"npx cdk synth"
}
}),
});
var deploy = new WorkshopPipelineStage(this, "Deploy");
var deployStage = pipeline.AddStage(deploy);
deployStage.AddPost(new ShellStep("TestViewerEndpoint", new ShellStepProps{
EnvFromCfnOutputs = new Dictionary<string, CfnOutput> {
{ "ENDPOINT_URL", deploy.HCViewerUrl }
},
Commands = new string[] { "curl -Ssf $ENDPOINT_URL" }
}));
deployStage.AddPost(new ShellStep("TestAPIGatewayEndpoint", new ShellStepProps{
EnvFromCfnOutputs = new Dictionary<string, CfnOutput> {
{ "ENDPOINT_URL", deploy.HCEndpoint }
},
Commands = new string[] {
"curl -Ssf $ENDPOINT_URL/",
"curl -Ssf $ENDPOINT_URL/hello",
"curl -Ssf $ENDPOINT_URL/test"
}
}));
}