question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(aws-cdk/pipelines): allow use of custom role for CodePipeline

See original GitHub issue

What is the problem?

When creating pipelines.CodePipeline with a synth pipelines.CodeBuild and even passing in role=role.without_policy_updates() parameter to the CodeBuildStep, the resulting Cfn template is generated with a PipelineRoleDefaultPolicy that exceeds the allowable size. According to other issues and to the docs regarding opting out of policy updates the policy is still being updated.

Reproduction Steps

install_commands = ['npm install -g aws-cdk', 'pip install -r requirements.txt', 'cdk synth']
        role = iam.Role(
            self,
            "Role",
            assumed_by=iam.CompositePrincipal(
                iam.ServicePrincipal("codepipeline.amazonaws.com"),
                iam.ServicePrincipal("codebuild.amazonaws.com"),
            ),
            description="My Custom Role"
        )

        policy_statement = iam.PolicyStatement(
            actions=[
                "s3:GetObject*",
                "s3:GetBucket*",
                "s3:List*",
                "s3:DeleteObject*",
                "s3:PutObject",
                "s3:Abort*",
            ],
            effect=iam.Effect.ALLOW,
            resources=[
                "*"
            ],
        )

        role.add_to_policy(
            policy_statement,
        )

        synth = pipelines.CodeBuildStep(
            "Synth",
            role=role.without_policy_updates(),
            commands=install_commands,
            input=pipelines.CodePipelineSource.connection(
                "blah/blahblah",
                "master",
                connection_arn=connection_arn,
            ),
        )

        pipeline = pipelines.CodePipeline(
            self,
            "Pipeline",
            synth=synth,
        )

What did you expect to happen?

the passed in role should not be updated

What actually happened?

policy for passed in role is updated to include individual assets for resources. It’s also possible that the roles between the CodeBuildStep and the pipelines.CodePipeline are completely separate in which case I would expect that the pipelines.CodePipelines to allow for a role parameter but this does not appear to be the case.

CDK CLI Version

1.137.0

Framework Version

No response

Node.js Version

v14.18.1

OS

Linux/Ubuntu 20.04

Language

Python

Language Version

3.8.10

Other information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
saltman424commented, Jan 31, 2022

This is the PR for this issue: #18293

0reactions
github-actions[bot]commented, Aug 1, 2022

⚠️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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CodePipeline: when providing custom Pipeline Role, cross ...
Explicitly passing in an IAM role to the constructor of my Pipelines will allow me to avoid the maximum IAM policy size bugs,...
Read more >
Create the CodePipeline service role - AWS Documentation
You can use the CodePipeline console or the AWS CLI to create a CodePipeline service role. A service role is required to create...
Read more >
Continuous Delivery with AWS CDK Pipelines - Luminis
Step by step we will create CI/CD pipeline using AWS CDK, CodeCommit and CodePipeline which is fully defined in TypeScript. At the end...
Read more >
AWS CDK pipelines cross account source with codestar ...
Looking to setup the source for my pipeline to be triggered from a codestar connection on a different AWS account. How can I...
Read more >
@aws-cdk/pipelines - npm
Start using @aws-cdk/pipelines in your project by running `npm i ... You can customize the role permissions used by the CodeBuild project so ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found