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

Region config for S3DeployAction #7012

Closed
2 tasks
handk85 opened this issue Mar 25, 2020 · 10 comments · Fixed by #8280
Closed
2 tasks

Region config for S3DeployAction #7012

handk85 opened this issue Mar 25, 2020 · 10 comments · Fixed by #8280
Assignees
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline @aws-cdk/core Related to core CDK functionality effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on.

Comments

@handk85
Copy link

handk85 commented Mar 25, 2020

Please add region configuration in S3DeployAction for cross-region deployment.

Use Case

I have a pipeline that supports cross-region deployment in us-west-2. A deployment stage of my pipeline looks like:

*Pipeline is in us-west-2
...
Deploy stage:
CF                 CF
(us-east-1)    (us-west-2)
 |
S3
(us-east-1)
...

I can set region for CloudFormationCreateUpdateStackAction, so it can support cross region deployment. However, S3DeployAction does not have region config in S3DeployActionProps. The target S3 bucket is created by the us-east-1 CF action above and the bucket is located in us-east-1. Therefore, S3DeployAction fails with the below message in console:

Invalid action configuration
The bucket named [BUCKET_NAME] is not located in the us-west-2 AWS region

I manually changed the region of the action in the console to resolve the problem.

Proposed Solution

It would be great if you can add region to S3DeployActionProps and support cross-region deployment for S3DeployAction.

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@handk85 handk85 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Mar 25, 2020
@skinny85
Copy link
Contributor

skinny85 commented Mar 25, 2020

Hey @handk85 ,

how are you referencing this bucket created by the CF action and used in S3DeployAction? Are you using a method like Bucket.fromBucketName() to do it?

@skinny85 skinny85 self-assigned this Mar 25, 2020
@handk85
Copy link
Author

handk85 commented Mar 25, 2020

Yes, I am using Bucket.fromBucketName() and provide it to bucket property of S3DeployActoin.

@skinny85
Copy link
Contributor

Then you need to import the Bucket with fromBucketName into a Stack that is in the region you want (in your case, us-east-1). When that happens, the CodePipeline construct will recognize that situation, and correctly fill the configuration of the action so that it points to us-east-1.

@skinny85 skinny85 added effort/medium Medium work item – several days of effort @aws-cdk/core Related to core CDK functionality @aws-cdk/aws-codepipeline Related to AWS CodePipeline and removed needs-triage This issue or PR still needs to be triaged. labels Mar 30, 2020
@Gtofig
Copy link
Contributor

Gtofig commented Apr 20, 2020

Any progress on this one?

@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Jun 1, 2020
@adrian-hincu
Copy link

Any updates on this? :) I would also like to specify the bucket region, cause my pipeline is in eu-west-2 and my bucket is in us-east-1. Since it can be done manually from the GUI, I'm guessing there's a way to be done from CDK as well.

@skinny85
Copy link
Contributor

@adrian-hincu yes. We're very close to finalizing this in #8280 . Then, you would be able to do:

const myBucket = s3.Bucket.fromBucketAttributes(this, 'Bucket', {
  bucketName: 'my-bucket',
  region: 'my-region',
});

And when you used that Bucket in the deploy Action, it would correctly set its region to 'my-region'.

@mergify mergify bot closed this as completed in #8280 Aug 19, 2020
mergify bot pushed a commit that referenced this issue Aug 19, 2020
Add the `account` and `region` properties to the `IResource` interface and `Resource` class.
By default, these are equal to the account and region of the Stack the resource belongs to;
however, they can be set to different values in resources that are imported.

Use those new properties in two places:
* In CodePipeline, to determine whether a given action is cross-account
  (with support for specifying the account and region in S3's `BucketAttributes`,
  as a first use case).
* IAM's `addToPrincipalOrResource()`, to correctly know when to modify the receiver's resource policy.
  This is aided by adding an optional `principalAccount` property to `IPrincipal`,
as a way to compare to the account present in the passed `IResource` instance.

Fixes #2807
Fixes #5740
Fixes #7012

----

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

@skinny85, was this just released in 1.61.0? :)

@skinny85
Copy link
Contributor

In 1.60.0 actually 🙂

@DimitriosKay
Copy link

Trying to pass fromBucketAttributes retrieved bucket to codepipeline.Pipeline artifactBucket property, which still asks for a bucket in the same region.
Is it that codepipeline.Pipeline just does not accept an Artifacts bucket in a different region ?

@skinny85
Copy link
Contributor

Trying to pass fromBucketAttributes retrieved bucket to codepipeline.Pipeline artifactBucket property, which still asks for a bucket in the same region.
Is it that codepipeline.Pipeline just does not accept an Artifacts bucket in a different region ?

Yes. The Bucket for artifacts must be in the same region as the pipeline itself. This issue is about S3DeployAction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline @aws-cdk/core Related to core CDK functionality effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants