Skip to content

Commit ef2ee3a

Browse files
committed
revamp codepipeline
1 parent 2305deb commit ef2ee3a

File tree

1 file changed

+98
-71
lines changed

1 file changed

+98
-71
lines changed

src/content/docs/aws/services/codepipeline.md

Lines changed: 98 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
title: CodePipeline
3-
linkTitle: CodePipeline
4-
description: >
5-
Get started with CodePipeline on LocalStack
3+
description: Get started with CodePipeline on LocalStack
64
tags: ["Ultimate"]
75
---
86

@@ -13,7 +11,7 @@ CodePipeline can be used to create automated pipelines that handle the build, te
1311

1412
LocalStack comes with a bespoke execution engine that can be used to create, manage, and execute pipelines.
1513
It supports a variety of actions that integrate with S3, CodeBuild, CodeConnections, and more.
16-
The available operations can be found on the [API coverage]({{< ref "coverage_codepipeline" >}}) page.
14+
The available operations can be found on the [API coverage]() page.
1715

1816
## Getting started
1917

@@ -26,38 +24,32 @@ Start LocalStack using your preferred method.
2624

2725
Begin by creating the S3 buckets that will serve as the source and target.
2826

29-
{{< command >}}
30-
$ awslocal s3 mb s3://source-bucket
31-
$ awslocal s3 mb s3://target-bucket
32-
{{< / command >}}
27+
```bash
28+
awslocal s3 mb s3://source-bucket
29+
awslocal s3 mb s3://target-bucket
30+
```
3331

3432
It is important to note the CodePipeline requires source S3 buckets to have versioning enabled.
3533
This can be done using the S3 [`PutBucketVersioning`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketVersioning.html) operation.
3634

37-
{{< command >}}
38-
$ awslocal s3api put-bucket-versioning \
35+
```bash
36+
awslocal s3api put-bucket-versioning \
3937
--bucket source-bucket \
4038
--versioning-configuration Status=Enabled
41-
{{< /command >}}
39+
```
4240

4341
Now create a placeholder file that will flow through the pipeline and upload it to the source bucket.
4442

45-
{{< command >}}
46-
$ echo "Hello LocalStack!" > file
47-
{{< /command >}}
48-
49-
{{< command >}}
50-
$ awslocal s3 cp file s3://source-bucket
51-
<disable-copy>
52-
upload: ./file to s3://source-bucket/file
53-
</disable-copy>
54-
{{< /command >}}
43+
```bash
44+
echo "Hello LocalStack!" > file
45+
awslocal s3 cp file s3://source-bucket
46+
```
5547

5648
Pipelines also require an artifact store, which is also an S3 bucket that is used as intermediate storage.
5749

58-
{{< command >}}
59-
$ awslocal s3 mb s3://artifact-store-bucket
60-
{{< / command >}}
50+
```bash
51+
awslocal s3 mb s3://artifact-store-bucket
52+
```
6153

6254
### Configure IAM
6355

@@ -83,12 +75,11 @@ Create the role and make note of the role ARN:
8375
}
8476
```
8577

86-
{{< command >}}
87-
$ awslocal iam create-role --role-name role --assume-role-policy-document file://role.json | jq .Role.Arn
88-
<disable-copy>
89-
"arn:aws:iam::000000000000:role/role"
90-
</disable-copy>
91-
{{< /command >}}
78+
Create the role with the following command:
79+
80+
```bash
81+
awslocal iam create-role --role-name role --assume-role-policy-document file://role.json | jq .Role.Arn
82+
```
9283

9384
Now add a permissions policy to this role that permits read and write access to S3.
9485

@@ -111,9 +102,9 @@ Now add a permissions policy to this role that permits read and write access to
111102
The permissions in the above example policy are relatively broad.
112103
You might want to use a more focused policy for better security on production systems.
113104

114-
{{< command >}}
115-
$ awslocal iam put-role-policy --role-name role --policy-name policy --policy-document file://policy.json
116-
{{< /command >}}
105+
```bash
106+
awslocal iam put-role-policy --role-name role --policy-name policy --policy-document file://policy.json
107+
```
117108

118109
### Create pipeline
119110

@@ -199,9 +190,9 @@ These correspond to the resources we created earlier.
199190

200191
Create the pipeline using the following command:
201192

202-
{{< command >}}
203-
$ awslocal codepipeline create-pipeline --pipeline file://./declaration.json
204-
{{< /command >}}
193+
```bash
194+
awslocal codepipeline create-pipeline --pipeline file://./declaration.json
195+
```
205196

206197
### Verify pipeline execution
207198

@@ -210,9 +201,13 @@ A 'pipeline execution' is an instance of a pipeline in a running or finished sta
210201
The [`CreatePipeline`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_CreatePipeline.html) operation we ran earlier started a pipeline execution.
211202
This can be confirmed using:
212203

213-
{{< command >}}
214-
$ awslocal codepipeline list-pipeline-executions --pipeline-name pipeline
215-
<disable-copy>
204+
```bash
205+
awslocal codepipeline list-pipeline-executions --pipeline-name pipeline
206+
```
207+
208+
The output will be similar to the following:
209+
210+
```json
216211
{
217212
"pipelineExecutionSummaries": [
218213
{
@@ -227,39 +222,42 @@ $ awslocal codepipeline list-pipeline-executions --pipeline-name pipeline
227222
}
228223
]
229224
}
230-
</disable-copy>
231-
{{< /command >}}
225+
```
232226

233227
Note the `trigger.triggerType` field specifies what initiated the pipeline execution.
234228
Currently in LocalStack, only two triggers are implemented: `CreatePipeline` and `StartPipelineExecution`.
235229

236230
The above pipeline execution was successful.
237231
This means that we can retrieve the `output-file` object from the `target-bucket` S3 bucket.
238232

239-
{{< command >}}
240-
$ awslocal s3 cp s3://target-bucket/output-file output-file
241-
<disable-copy>
242-
download: s3://target-bucket/output-file to ./output-file
243-
</disable-copy>
244-
{{< /command >}}
233+
```bash
234+
awslocal s3 cp s3://target-bucket/output-file output-file
235+
```
245236

246237
To verify that it is the same file as the original input:
247238

248-
{{< command >}}
249-
$ cat output-file
250-
<disable-copy>
239+
```bash
240+
cat output-file
241+
```
242+
243+
The output will be:
244+
245+
```text
251246
Hello LocalStack!
252-
</disable-copy>
253-
{{< /command >}}
247+
```
254248

255249
### Examine action executions
256250

257251
Using the [`ListActionExecutions`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_ListPipelineExecutions.html), detailed information about each action execution such as inputs and outputs can be retrieved.
258252
This is useful when debugging the pipeline.
259253

260-
{{< command >}}
261-
$ awslocal codepipeline list-action-executions --pipeline-name pipeline
262-
<disable-copy>
254+
```bash
255+
awslocal codepipeline list-action-executions --pipeline-name pipeline
256+
```
257+
258+
The output will be similar to the following:
259+
260+
```json
263261
{
264262
"actionExecutionDetails": [
265263
{
@@ -315,27 +313,31 @@ $ awslocal codepipeline list-action-executions --pipeline-name pipeline
315313
"stageName": "stage1",
316314
"actionName": "action1",
317315
...
318-
</disable-copy>
319-
{{< /command >}}
316+
```
320317

321-
{{< callout >}}
318+
:::note
322319
LocalStack does not use the same logic to generate external execution IDs as AWS so there may be minor discrepancies.
323320
The same is true for status and error messages produced by actions.
324-
{{< /callout >}}
321+
:::
325322

326323
## Pipelines
327324

328-
The operations [CreatePipeline](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_CreatePipeline.html), [GetPipeline](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_GetPipeline.html), [UpdatePipeline](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_UpdatePipeline.html), [ListPipelines](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_ListPipelines.html), [DeletePipeline](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_DeletePipeline.html) are used to manage pipeline declarations.
325+
The operations [`CreatePipeline`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_CreatePipeline.html), [`GetPipeline`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_GetPipeline.html), [`UpdatePipeline`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_UpdatePipeline.html), [`ListPipelines`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_ListPipelines.html), [`DeletePipeline`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_DeletePipeline.html) are used to manage pipeline declarations.
329326

330327
LocalStack supports emulation for V1 pipelines.
331328
V2 pipelines are only created as mocks.
332329

333-
{{< callout "tip" >}}
330+
:::note
334331
Emulation for V2 pipelines is not supported.
335332
Make sure that the pipeline type is explicitly set in the declaration.
336-
{{< /callout >}}
333+
:::
337334

338-
Pipeline executions can be managed with [`StartPipelineExecution`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_StartPipelineExecution.html), [`GetPipelineExecution`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_GetPipelineExecution.html), [`ListPipelineExecutions`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_ListPipelineExecutions.html) and [`StopPipelineExecutions`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_StopPipelineExecution.html).
335+
Pipeline executions can be managed with:
336+
337+
- [`StartPipelineExecution`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_StartPipelineExecution.html)
338+
- [`GetPipelineExecution`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_GetPipelineExecution.html)
339+
- [`ListPipelineExecutions`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_ListPipelineExecutions.html)
340+
- [`StopPipelineExecutions`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_StopPipelineExecution.html)
339341

340342
When stopping pipeline executions with `StopPipelineExecution`, the stop and abandon method is not supported.
341343
Setting the `abandon` flag will have no impact.
@@ -345,15 +347,26 @@ Action executions can be inspected using the [`ListActionExecutions`](https://do
345347

346348
### Tagging pipelines
347349

348-
Pipelines resources can be [tagged](https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-tag.html) using the [`TagResource`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_TagResource.html), [`UntagResource`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_UntagResource.html) and [`ListTagsForResource`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_ListTagsForResource.html) operations.
350+
Pipelines resources can be [tagged](https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-tag.html) using the following operations:
351+
352+
- [`TagResource`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_TagResource.html)
353+
- [`UntagResource`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_UntagResource.html)
354+
- [`ListTagsForResource`](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_ListTagsForResource.html)
355+
356+
Tag the pipeline with the following command:
349357

350-
{{< command >}}
351-
$ awslocal codepipeline tag-resource \
358+
```bash
359+
awslocal codepipeline tag-resource \
352360
--resource-arn arn:aws:codepipeline:eu-central-1:000000000000:pipeline \
353361
--tags key=purpose,value=tutorial
354362

355-
$ awslocal codepipeline list-tags-for-resource \
363+
awslocal codepipeline list-tags-for-resource \
356364
--resource-arn arn:aws:codepipeline:eu-central-1:000000000000:pipeline
365+
```
366+
367+
The output will be similar to the following:
368+
369+
```json
357370
{
358371
"tags": [
359372
{
@@ -362,11 +375,15 @@ $ awslocal codepipeline list-tags-for-resource \
362375
}
363376
]
364377
}
378+
```
365379

366-
$ awslocal codepipeline untag-resource \
380+
Untag the pipeline with the following command:
381+
382+
```bash
383+
awslocal codepipeline untag-resource \
367384
--resource-arn arn:aws:codepipeline:eu-central-1:000000000000:pipeline \
368385
--tag-keys purpose
369-
{{< /command >}}
386+
```
370387

371388
## Variables
372389

@@ -375,9 +392,9 @@ CodePipeline on LocalStack supports [variables](https://docs.aws.amazon.com/code
375392
Actions produce output variables which can be referenced in the configuration of subsequent actions.
376393
Make note that only when the action defines a namespace, its output variables are availabe to downstream actions.
377394

378-
{{< callout "tip" >}}
395+
:::note
379396
If an action does not use a namespace, its output variables are not available to downstream actions.
380-
{{< /callout >}}
397+
:::
381398

382399
CodePipeline's variable placeholder syntax is as follows:
383400

@@ -395,6 +412,11 @@ The supported actions in LocalStack CodePipeline are listed below.
395412
Using an unsupported action will make the pipeline fail.
396413
If you would like support for more actions, please [raise a feature request](https://github.com/localstack/localstack/issues/new/choose).
397414

415+
### CloudFormation Deploy
416+
417+
The [CloudFormation Deploy](https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CloudFormation.html) action executes a CloudFormation stack.
418+
It supports the following modes: `CREATE_UPDATE`, `CHANGE_SET_REPLACE`, `CHANGE_SET_EXECUTE`
419+
398420
### CodeBuild Source and Test
399421

400422
The [CodeBuild Source and Test](https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CodeBuild.html) action can be used to start a CodeBuild container and run the given buildspec.
@@ -421,6 +443,10 @@ It will only update the running ECS service with a new task definition and wait
421443

422444
The [ECS Deploy](https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-ECS.html) action creates a revision of a task definition based on an already deployed ECS service.
423445

446+
### Lambda Invoke
447+
448+
The [Lambda Invoke](https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-Lambda.html) action is used to execute a Lambda function in a pipeline.
449+
424450
### Manual Approval
425451

426452
The Manual Approval action can be included in the pipeline declaration but it will only function as a no-op.
@@ -438,6 +464,7 @@ The [S3 Source](https://docs.aws.amazon.com/codepipeline/latest/userguide/action
438464
- Emulation for [V2 pipeline types](https://docs.aws.amazon.com/codepipeline/latest/userguide/pipeline-types-planning.html) is not supported.
439465
They will be created as mocks only.
440466
- [Rollbacks and stage retries](https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-stages.html) are not available.
467+
- [Custom actions](https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-create-custom-action.html) and associated operations (AcknowledgeJob, GetJobDetails, PollForJobs, etc.) are not supported.
441468
- [Triggers](https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-triggers.html) are not implemented.
442469
Pipelines are executed only when [CreatePipeline](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_CreatePipeline.html) and [StartPipelineExecution](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_StartPipelineExecution.html) are invoked.
443470
- [Execution mode behaviours](https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts-how-it-works.html#concepts-how-it-works-executions) are not implemented.

0 commit comments

Comments
 (0)