aws / aws/aws-cdk

pipelines: Codepipeline.add_wave does not keep the stages sperated

Open
#31,023 3 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/pipelines bug effort/small p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the bug

I added an wave to my pipeline to deploy multiple stages in paralell. Every Stage has its own Approval step in pre of it. But if i approve an single Stage the stage dont gets deployed

### Expected Behavior

I expect if i press on the manual approval of the stage, to deploy the stage

### Current Behavior

![Bildschirmfoto 2024-08-05 um 11 23 16](https://github.com/user-attachments/assets/93dd9d65-1513-4313-bcb3-1d1d5b5031d0)

I pressed the manual approval of an Stage and the deployment does not continue

### Reproduction Steps

```python
from typing import Literal

import aws_cdk
import aws_cdk.aws_codebuild as codebuild
from aws_cdk import aws_codecommit as codecommit, aws_iam as iam, pipelines
from constructs import Construct

ACCOUNT_ID = ""
REPO_ARN = ""
PIPELINE_NAME = ""

class Services(aws_cdk.Stage):
def __init__(
self,
scope: aws_cdk.Stack, # object of type Pipeline
id_: str,
branch: str,
env: aws_cdk.Environment,
):
super().__init__(scope=scope, id=id_, env=env)
self.branch = branch
aws_cdk.Stack(
scope=self,
id="EmptyTestStack",
)

class PipelineStack(aws_cdk.Stack):
def __init__(self, scope: Construct, id: str, branch: str, **kwargs):
super().__init__(scope, id, **kwargs)
self.branch = branch
pipeline = self._create_pipeline(branch=branch)
self._add_stages(pipeline=pipeline, id_suffix="Lab", branch=branch)

def _add_stages(
self,
pipeline: pipelines.CodePipeline,
id_suffix: Literal["Lab"],
branch: str,
) -> None:
wave = pipeline.add_wave(
f"TestStage-{id_suffix}",
)

deployments = [
{"account": ACCOUNT_ID, "region": "eu-central-1"},
{"account": ACCOUNT_ID, "region": "us-east-1"},
]

for deployment in deployments:
services = Services(
self,
f"Services-{id_suffix}-{deployment['account']}--{deployment['region']}",
branch,
env=aws_cdk.Environment(
account=deployment["account"], region=deployment["region"]
),
)
wave.add_stage(
stage=services,
pre=[
pipelines.ManualApprovalStep(
f'Approve-Services-{deployment["account"]}-{deployment["region"]}'
)
],
)

def _create_pipeline(self, branch: str) -> pipelines.CodePipeline:
repository = codecommit.Repository.from_repository_arn(
scope=self,
id="TestRepo",
repository_arn=(REPO_ARN),
)
self.synth_input = pipelines.CodePipelineSource.code_commit(
repository=repository,
branch=branch,
)
synth = pipelines.CodeBuildStep(
id="Synth",
build_environment=codebuild.BuildEnvironment(
build_image=codebuild.LinuxBuildImage.STANDARD_7_0, privileged=True
),
input=self.synth_input,
partial_build_spec=codebuild.BuildSpec.from_object(
{
"version": "0.2",
"phases": {
"install": {
"runtime-versions": {"python": "3.11"},
}
},
}
),
install_commands=[],
commands=["cdk synth"],
role_policy_statements=[
iam.PolicyStatement(
effect=iam.Effect.ALLOW,
resources=["*"],
actions=[
"codeartifact:GetAuthorizationToken",
"codeartifact:GetRepositoryEndpoint",
"codeartifact:PublishPackageVersion",
"codeartifact:PutPackageMetadata",
"codeartifact:ReadFromRepository",
"codeartifact:ListPackageVersions",
"ssm:*",
"ecr:*",
],
),
iam.PolicyStatement(
effect=iam.Effect.ALLOW,
resources=["*"],
actions=["sts:GetServiceBearerToken"],
conditions={
"StringEquals": {
"sts:AWSServiceName": "codeartifact.amazonaws.com"
}
},
),
],
primary_output_directory="cdk.out",
)
return pipelines.CodePipeline(
scope=self,
id="Pipeline",
pipeline_name=PIPELINE_NAME,
synth=synth,
cross_account_keys=True,
docker_enabled_for_synth=True,
self_mutation=True,
)

```

### Possible Solution

Every Stage should be kept seperate

### Additional Information/Context

_No response_

### CDK CLI Version

2.142.1 (build ed4e152)

### Framework Version

_No response_

### Node.js Version

v22.3.0

### OS

Mac OS Sonoma 14.5 (23F79)

### Language

Python

### Language Version

3.12

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start from the pipelines.CodePipeline.add_wave and wave.add_stage calls in the Python reproduction, then inspect how the generated AWS CodePipeline represents parallel stages and their ManualApprovalStep entries. Reproduce the approval behavior and confirm that approving one stage allows that stage to deploy independently while the other stage remains separate.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
ci-cd, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.