Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cdk-pipelines] CDK Pipeline Application deployment stage uses backslashes for Template URL on Windows #11405

Closed
Pettles opened this issue Nov 11, 2020 · 3 comments · Fixed by #11464
Assignees
Labels
@aws-cdk/pipelines CDK Pipelines library bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@Pettles
Copy link

Pettles commented Nov 11, 2020

Adding an application deployment stage to a CDK Pipeline from Windows uses a backslash separator in the Template URL of the CloudFormation CHANGE_SET_REPLACE step, resulting in an 'Action Execution Failure'.

Reproduction Steps

Deployed a CDK Pipeline Stack with the following code:

class MySourceStack(cdk.Stack):
    def __init__(self, scope: cdk.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)
        code_commit_role = iam.Role(self, 'CodeCommitRole', assumed_by=iam.AccountRootPrincipal())


class MyStage(cdk.Stage):
    def __init__(self, scope: cdk.Construct, id: str, **kwargs):
        super().__init__(scope, id, **kwargs)
        MySourceStack(self, 'IAMRole')


class MyStack(cdk.Stack):
    def __init__(self, scope: cdk.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        source_artifact = codepipeline.Artifact()
        cloud_assembly_artifact = codepipeline.Artifact()

        source_repository = codecommit.Repository.from_repository_arn(
            self, 'Source_Repository',
            # .. Source Repo
        )

        # Create the Pipeline with the Source and Synth actions
        pipeline = CdkPipeline(self, "Pipeline",
            cloud_assembly_artifact=cloud_assembly_artifact,
            source_action=codepipeline_actions.CodeCommitSourceAction(
                action_name='CodeCommit',
                output=source_artifact,
                repository=source_repository,
                branch='master'
            ),
            synth_action=SimpleSynthAction(
                source_artifact=source_artifact,
                cloud_assembly_artifact=cloud_assembly_artifact,
                # Does installation and build for python
                install_commands=["npm install -g aws-cdk"],
                build_commands=["pip install -r requirements.txt"],
                synth_command="cdk synth"
            ),
        )
        # Create the Application deployment actions
        pipeline.add_application_stage(MyStage(self, 'PreProd'))

Upon running the pipeline, the execution fails at the 'PreProd' CloudFormation CHANGE_SET_REPLACE action with the error:

Action execution failed
File [assembly-myproject-PreProd\myprojectPreProdIAMRole470A8317.template.json] does not exist in artifact [Artifact_Build_Synth]

Manually editing the Pipeline CHANGE_SET_REPLACE action and changing the backslash in the template URL to a forward slash allows the pipeline to execute successfully.

What did you expect to happen?

CDK Pipeline deployment to use forward-slashes in order to join directory names when creating the template URL to provide to the CHANGE_SET_REPLACE action.

What actually happened?

The Template URL provided to the CHANGE_SET_REPLACE step used backslashes to join the directory names, resulting in an error.

Environment

  • CDK CLI Version : 1.72.0 (build c2f38e8)
  • Framework Version: 1.72.0
  • Node.js Version: v12.19.0
  • OS : Windows 10
  • Language (Version): Python 3.8.6

Other

Deployed using PowerShell as a Terminal from PyCharm.


This is 🐛 Bug Report

@Pettles Pettles added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 11, 2020
@Pettles
Copy link
Author

Pettles commented Nov 11, 2020

Hey team,
I assume the root cause of this issue is similar to that identified in: #11359

@Pettles
Copy link
Author

Pettles commented Nov 11, 2020

Hey team,
Testing this further, I've found a simple workaround is to enable self_mutation on the CDK Pipeline, as this detects the change in the Template URL created by the synth action, and updates the pipeline to resolve the issue itself.
It does still mean that the initial deployment, and any deployment with self mutation disabled, is still encountering this issue.

@SomayaB SomayaB changed the title [aws_cdk.pipelines] CDK Pipeline Application deployment stage uses backslashes for Template URL on Windows [cdk-pipelines] CDK Pipeline Application deployment stage uses backslashes for Template URL on Windows Nov 13, 2020
@github-actions github-actions bot added the @aws-cdk/pipelines CDK Pipelines library label Nov 13, 2020
@mergify mergify bot closed this as completed in #11464 Nov 15, 2020
mergify bot pushed a commit that referenced this issue Nov 15, 2020
Pipelines generates path references based on the local system's
file tree, and uses `path.join()` (etc) to build those.

On a Windows machine, those would use a `\\` as a path separator,
but the path separator for CodePipeline and the Linux CodeBuild image
we use should be a `/`.

Translate them.

Fixes #11359, fixes #11405, fixes #11424.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/pipelines CDK Pipelines library bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants