aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.66k stars 3.92k forks source link

Codepipeline: Only one of artifact bucket and cross region replication buckets can be specified! #26164

Open makr11 opened 1 year ago

makr11 commented 1 year ago

Describe the feature

I couldn't find an explanation of this constraint. It would be extremely beneficial to be able to specify cross region replication bucket to be reused for all project pipelines which create cross region resources.

Use Case

Large amount of pipelines created with CDK creates a near limit amount of S3 Buckets, I would like to specify cross region replication bucket alongside artifact bucket.

Proposed Solution

No response

Other Information

No response

Acknowledgements

CDK version used

2.78.0

Environment details (OS name and version, etc.)

Ubuntu 22.04

pahud commented 1 year ago

What error messages did you see? Can you share more details about that?

makr11 commented 1 year ago

Hi pahud,

This is the full error log:

jsii.errors.JavaScriptError: Error: Only one of artifactBucket and crossRegionReplicationBuckets can be specified! at new Pipeline (/tmp/jsii-kernel-upQH8B/node_modules/aws-cdk-lib/aws-codepipeline/lib/pipeline.js:1:3732) at Kernel._create (/tmp/tmpb55dxvbx/lib/program.js:9964:29) at Kernel.create (/tmp/tmpb55dxvbx/lib/program.js:9693:29) at KernelHost.processRequest (/tmp/tmpb55dxvbx/lib/program.js:11544:36) at KernelHost.run (/tmp/tmpb55dxvbx/lib/program.js:11504:22) at Immediate._onImmediate (/tmp/tmpb55dxvbx/lib/program.js:11505:46) at process.processImmediate (node:internal/timers:476:21)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/esg/app.py", line 9, in Pipeline(app, f"Pipeline-{environment}", environment, env=cdk.Environment(account="xxxxxxx", region="xxxx")) File "/home/-esg/.venv/lib/python3.9/site-packages/jsii/_runtime.py", line 112, in call inst = super().call(*args, *kwargs) File "/home/-esg/infra/pipeline.py", line 40, in init pipeline = codepipeline.Pipeline(self, "BasePipeline", File "/home/esg/.venv/lib/python3.9/site-packages/jsii/_runtime.py", line 112, in call inst = super().call(args, **kwargs) File "/home/esg/.venv/lib/python3.9/site-packages/aws_cdk/aws_codepipeline/init.py", line 5937, in init jsii.create(self.class, self, [scope, id, props]) File "/home/esg/.venv/lib/python3.9/site-packages/jsii/_kernel/init.py", line 334, in create response = self.provider.create( File "/home/esg/.venv/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 363, in create return self._process.send(request, CreateResponse) File "/home/esg/.venv/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 340, in send raise RuntimeError(resp.error) from JavaScriptError(resp.stack) RuntimeError: Only one of artifactBucket and crossRegionReplicationBuckets can be specified!

makr11 commented 1 year ago

Hey, any update around this issue?

pahud commented 11 months ago

Hi @makr11

For cross-region and/or cross-account issues with codepipeline, we have a p1 issue for tracking at https://github.com/aws/aws-cdk/issues/24051 and please report to that issue instead.

If you are looking for a working sample for your reference, please check this out. https://github.com/aws/aws-cdk/issues/26557#issuecomment-1800968752

kareldonk commented 1 month ago

I am getting the same error. I would like to use a single bucket for artifacts and replication buckets because otherwise we reach the 100 bucket limit quickly. If a single bucket cannot be used, at least 2 buckets, one for artifacts and one for replication would also be good.

const artifactBucket = Bucket.fromBucketName(this, `ID`, 'existing_bucketname');

const pipeline = new CodePipeline(this, `ID`, {
    artifactBucket: artifactBucket,
    crossRegionReplicationBuckets: {
        'us-east-1': artifactBucket,
    },
   ...
};

Results in: Error: Only one of artifactBucket and crossRegionReplicationBuckets can be specified! when trying to do cdk synth.