-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Creating a codepipeline.Pipeline with a codebuild.PipelineProject in a different stack results in a circular reference #3300
Comments
Hey @corymhall , I know this sounds weird, but can you try to ignore this error for now, and actually try to have Let me know! Thanks, |
@skinny85 I can't seem to find any documentation that shows how to specify two sets of credentials, is this currently possible? |
Sorry Cory, I missed your message. There's a few things you can do to have multiple account calls:
|
@skinny85 so the original issue that I raised was that there are dependencies between the two stacks. So in your example when I do the It seems like there needs to be a way of defining a profile per account, or a concept of providers like Terraform has. |
Or, you're right, sorry I forgot - use the |
@corymhall did you manage to get this working? Sorry for the bad experience on the CLI - we're actively thinking on how to make it better (#3401). |
I am having the same problem :(. When I use the same stack the problem is solved, but I want to be able to deploy two separate stacks to different accounts. |
You should be able to do that by using physical names (no cycles should happen). |
Thanks for the answer. However I don't know what part needs to be named. In the above example from corymhall the stacks are explicitly named |
@tijoer What is the error that you're getting? |
Getting the same error where I create the API Gateway in the base stack and pass it to the second stack to attach resources and lambda methods to it and it spits the similar cyclic references |
@wywarren seeing the full error, and some of your code, would be helpful (the error usually contains the exact paths of the resources that cause the cycle). |
@wywarren ping |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Is this issue just simply ignored? Or is it fixed? I'm getting the same problem and couldn't find any answer to it |
@mlh-anhl it is not being actively worked on, but you're right, it shouldn't have been closed. Reopening. What's the setup that's causing you problems? |
@skinny85 I have same issues with cdk 1.117.0
Issue -
|
@sarbajitdutta can you show more of your code? In particular, what is |
@skinny85 They are separate stacks. One for all the CodeBuild projects and one for the CodePipeline stack which uses the CodeBuild projects. I had separate stacks declared and with dependency of CodeBuild stack for CodePipeline expressed as -
As you can see The only option to circumvent the issue was to put both CodeBuild and CodePipeline in same stack like I did here - |
@skinny85 I think this is bug in the system and should be addressed. |
Can you please post a minimal reproduction that allows me to get the |
I have a very similar issue. I have created a Role in one stack and then create a Pipeline in a second stack. I get the circular dependency. I guess when adding the Role to the Pipeline it is trying to add some permission to the Role. |
CodePipeline: CodeBuildAppStack' depends on 'CodePipelineAppStack' cyclic reference
This Gives me an error:
The CodeBuildStacks works fine alone but once I pass this stack in CodePipelineStack the error pops up. CodePipeline.ts export class CodePipeline extends Stack {
public readonly SourceStage: codepipeline.IStage;
public readonly BuildStage: codepipeline.IStage;
public readonly DeployStage: codepipeline.IStage;
public readonly codePipelineRole: iam.Role;
constructor(scope: Construct, id: string, codeBuild: CodeBuildStack, props?: StackProps) {
super(scope, id, props)
this.codePipelineRole = new iam.Role(this, `CodePipelineRole`, {
roleName: `CodePipelineRole`,
assumedBy: new iam.ServicePrincipal('codebuild.amazonaws.com'),
managedPolicies: [
iam.ManagedPolicy.fromAwsManagedPolicyName(
'AmazonEC2ContainerRegistryPowerUser',
),
]
});
const pipeline = new codepipeline.Pipeline(this, `MyCodePipeline`, {
pipelineName: 'my-codepipeline',
role:this.codePipelineRole,
crossAccountKeys: false,
});
const sourceOutput = new codepipeline.Artifact();
this.SourceStage = pipeline.addStage({
stageName: 'Source',
actions: [
new codepipelineActions.CodeStarConnectionsSourceAction({
actionName: 'Source',
owner: `onwername`,
repo: 'reponame',
connectionArn:'my-arn',
triggerOnPush:true,
output: sourceOutput
})
],
})
this.BuildStage = pipeline.addStage({
stageName: 'Build',
placement: {
justAfter: this.SourceStage
},
actions: [
new codepipelineActions.CodeBuildAction({
actionName:'CodeBuild',
input:sourceOutput,
project: codeBuild.projectABC
})
]
})
}
} CDK CLI Version Framework Version Node.js Version OS Language |
@AreebSiddiqui can you show the entire message that you get? (Pretty sure you cut out the most important part 😛). |
@skinny85 Here it is :p
|
@AreebSiddiqui there are a few ways you can break this dependency. The simplest might be to move the CodePipeline's S3 Bucket to the same Stack as your CodeBuild Project: export class CodeBuildStack extends Stack {
public readonly projectABC: codebuild.IProject;
public readonly artifactBucket: s3.IBucket;
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
this.projectABC = new codebuild.PipelineProject(this, 'PipelineProject');
this.artifactBucket = new s3.Bucket(this, 'ArtifactBucket');
}
}
export class CodePipelineStack extends Stack {
public readonly SourceStage: codepipeline.IStage;
public readonly BuildStage: codepipeline.IStage;
public readonly DeployStage: codepipeline.IStage;
public readonly codePipelineRole: iam.Role;
constructor(scope: Construct, id: string, codeBuild: CodeBuildStack, props?: StackProps) {
super(scope, id, props)
this.codePipelineRole = new iam.Role(this, `CodePipelineRole`, {
roleName: `CodePipelineRole`,
assumedBy: new iam.ServicePrincipal('codebuild.amazonaws.com'),
managedPolicies: [
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonEC2ContainerRegistryPowerUser'),
],
});
const pipeline = new codepipeline.Pipeline(this, `MyCodePipeline`, {
pipelineName: 'my-codepipeline',
role: this.codePipelineRole,
crossAccountKeys: false,
artifactBucket: codeBuild.artifactBucket,
});
const sourceOutput = new codepipeline.Artifact();
this.SourceStage = pipeline.addStage({
stageName: 'Source',
actions: [
new codepipelineActions.CodeStarConnectionsSourceAction({
actionName: 'Source',
owner: `onwername`,
repo: 'reponame',
connectionArn:'my-arn',
triggerOnPush:true,
output: sourceOutput,
}),
],
});
this.BuildStage = pipeline.addStage({
stageName: 'Build',
actions: [
new codepipelineActions.CodeBuildAction({
actionName: 'CodeBuild',
input: sourceOutput,
project: codeBuild.projectABC,
}),
],
});
}
}
const app = new App();
const codebuildStack = new CodeBuildStack(app, 'CodeBuildAppStack');
new CodePipelineStack(app, 'CodePipelineAppStack', codebuildStack); |
(BTW, your pipeline Role is wrong - it trusts the CodeBuild service principal, instead of the CodePipeline one. I would suggest letting CDK manage it for you - just remove the |
@skinny85 This was a lifesaver, thank you so much. It's because of people like you that the aws community is ever going, keep up the good work really appreciate it. Thanks again! |
Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.
I'm submitting a ...
What is the current behavior?
If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce
I am trying to follow the example on this feature #1924 to create a codepipeline with codebuild actions that are created in a separate stack. When I do, I get this error:
Here is my sample code that I am working with
Based off the feature #1924, I would expect to be able to create a codepipeline in one stack and then add a codebuild project created in a separate stack as a stage. Currently I am trying everything within the same account.
The use case is to be able to create a codepipeline in one account with build/deploy actions
in a separate account. Most of the motivation is described in the feature #1924
Please tell us about your environment:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
Full error:
The text was updated successfully, but these errors were encountered: