Skip to content
This repository was archived by the owner on Nov 4, 2022. It is now read-only.

Commit b6a00b1

Browse files
committed
Adding expand elements on each CDK page
1 parent ba32aae commit b6a00b1

File tree

4 files changed

+94
-4
lines changed

4 files changed

+94
-4
lines changed

workshop/content/buildpipe/pipeascode/bucket/_index.en.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ Every Code Pipeline needs an artifacts bucket, also known as Artifact Store. Cod
88

99
Let's get started and write the code for creating this bucket:
1010

11-
**Make sure you are editing the file with _.ts_ extension**
11+
**Make sure you are editing the pipeline-stack file with _.ts_ extension**
1212

1313
```js
1414
// lib/pipeline-stack.ts
1515

1616
import * as cdk from '@aws-cdk/core';
1717
import s3 = require('@aws-cdk/aws-s3');
18+
import codecommit = require('@aws-cdk/aws-codecommit');
19+
import codepipeline = require('@aws-cdk/aws-codepipeline');
20+
import codepipeline_actions = require('@aws-cdk/aws-codepipeline-actions');
21+
import codebuild = require('@aws-cdk/aws-codebuild');
1822

1923
export class PipelineStack extends cdk.Stack {
2024
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {

workshop/content/buildpipe/pipeascode/build/_index.en.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,37 @@ AWS CodeBuild is a great option because you only pay for the time where your bui
1212

1313
### Add the build stage
1414

15-
Let's go ahead and add a Build stage to our pipeline:
15+
Let's go ahead and add a Build stage to you pipeline-stack.ts:
1616

17+
```js
18+
// Declare build output as artifacts
19+
const buildOutput = new codepipeline.Artifact();
20+
21+
// Declare a new CodeBuild project
22+
const buildProject = new codebuild.PipelineProject(this, 'Build', {
23+
environment: { buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_2 },
24+
environmentVariables: {
25+
'PACKAGE_BUCKET': {
26+
value: artifactsBucket.bucketName
27+
}
28+
}
29+
});
30+
31+
// Add the build stage to our pipeline
32+
pipeline.addStage({
33+
stageName: 'Build',
34+
actions: [
35+
new codepipeline_actions.CodeBuildAction({
36+
actionName: 'Build',
37+
project: buildProject,
38+
input: sourceOutput,
39+
outputs: [buildOutput],
40+
}),
41+
],
42+
});
43+
```
44+
45+
{{%expand "Click here to see how the entire file should look like" %}}
1746
```js
1847
// lib/pipeline-stack.ts
1948

@@ -87,6 +116,7 @@ export class PipelineStack extends cdk.Stack {
87116
}
88117
}
89118
```
119+
{{% /expand%}}
90120

91121
### Deploy the pipeline
92122

workshop/content/buildpipe/pipeascode/deploy/_index.en.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,32 @@ weight = 40
66

77
The **Deploy Stage** is where your SAM application and all its resources are created an in an AWS account. The most common way to do this is by using CloudFormation ChangeSets to deploy. This means that this stage will have 2 actions: the _CreateChangeSet_ and the _ExecuteChangeSet_.
88

9-
Add the Deploy stage to your pipeline:
9+
Add the Deploy stage to your pipeline-stack.ts:
1010

11+
```js
12+
// Deploy stage
13+
pipeline.addStage({
14+
stageName: 'Dev',
15+
actions: [
16+
new codepipeline_actions.CloudFormationCreateReplaceChangeSetAction({
17+
actionName: 'CreateChangeSet',
18+
templatePath: buildOutput.atPath("packaged.yaml"),
19+
stackName: 'sam-app',
20+
adminPermissions: true,
21+
changeSetName: 'sam-app-dev-changeset',
22+
runOrder: 1
23+
}),
24+
new codepipeline_actions.CloudFormationExecuteChangeSetAction({
25+
actionName: 'Deploy',
26+
stackName: 'sam-app',
27+
changeSetName: 'sam-app-dev-changeset',
28+
runOrder: 2
29+
}),
30+
],
31+
});
32+
```
33+
34+
{{%expand "Click here to see how the entire file should look like" %}}
1135
```js
1236
// lib/pipeline-stack.ts
1337

@@ -102,6 +126,7 @@ export class PipelineStack extends cdk.Stack {
102126
}
103127
}
104128
```
129+
{{% /expand%}}
105130

106131
### Deploy the pipeline
107132

workshop/content/buildpipe/pipeascode/source/_index.en.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,38 @@ weight = 15
66

77
The **Source Stage** is the first step of any CI/CD pipeline and it represents your source code. This stage is in charge of triggering the pipeline based on new code changes (i.e. git push or pull requests). In this workshop, we will be using AWS CodeCommit as the source provider, but CodePipeline also supports S3, GitHub and Amazon ECR as source providers.
88

9-
Let's go ahead and add a Source provider to our pipeline:
9+
Append the following code snippet after your bucket definition in the **pipeline-stack.ts** file:
1010

11+
```js
12+
// Import existing CodeCommit sam-app repository
13+
const codeRepo = codecommit.Repository.fromRepositoryName(
14+
this,
15+
'AppRepository', // Logical name within CloudFormation
16+
'sam-app' // Repository name
17+
);
18+
19+
// Pipeline creation starts
20+
const pipeline = new codepipeline.Pipeline(this, 'Pipeline', {
21+
artifactBucket: artifactsBucket
22+
});
23+
24+
// Declare source code as an artifact
25+
const sourceOutput = new codepipeline.Artifact();
26+
27+
// Add source stage to pipeline
28+
pipeline.addStage({
29+
stageName: 'Source',
30+
actions: [
31+
new codepipeline_actions.CodeCommitSourceAction({
32+
actionName: 'CodeCommit_Source',
33+
repository: codeRepo,
34+
output: sourceOutput,
35+
}),
36+
],
37+
});
38+
```
39+
40+
{{%expand "Click here to see how the entire file should look like" %}}
1141
```js
1242
// lib/pipeline-stack.ts
1343

@@ -53,6 +83,7 @@ export class PipelineStack extends cdk.Stack {
5383
}
5484
}
5585
```
86+
{{% /expand%}}
5687

5788
Since we already have the CodeCommit repository, we don't need to create a new one, we just need to import it using the repository name.
5889

0 commit comments

Comments
 (0)