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

[aws-codepipeline-actions] codebuild cross-region build actions #10279

Closed
1 of 2 tasks
amhammett opened this issue Sep 10, 2020 · 2 comments
Closed
1 of 2 tasks

[aws-codepipeline-actions] codebuild cross-region build actions #10279

amhammett opened this issue Sep 10, 2020 · 2 comments
Assignees
Labels
@aws-cdk/aws-codepipeline-actions closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@amhammett
Copy link

AWS CodePipeline Now Supports Cross-Region Actions and the CDK has been updated to allow cross-region support for cloudformation but has not been added for CodeBuild.

In https://docs.aws.amazon.com/cdk/api/latest/docs/aws-codepipeline-readme.html CloudFormationCreateUpdateStackAction is referenced as a cross-region action but attempting to use the same implementation for a CodeBuild project results in

Object literal may only specify known properties, and 'region' does not exist

Use Case

I would like to be able to provision CodePipelines in CDK that utilizes cross-region CodeBuild projects. I have my primary CodeCommit repository in RegionA but have some build actions that can only be run in RegionB due to network connectivity/latency.

This capability is available via the console and CloudFormation but hasn't been introduced to CDK.

Proposed Solution

I have a PR in waiting that, making a similar change as was implemented in #49 allowing for CodeBuildAction to support the region attribute.

Other

Below is an example stack that shows current and proposed functionality.

import {Construct, Stack, StackProps} from '@aws-cdk/core'
import {PipelineProject} from '@aws-cdk/aws-codebuild'
import {Repository} from '@aws-cdk/aws-codecommit'
import {Artifact, Pipeline} from '@aws-cdk/aws-codepipeline'
import {CodeBuildAction, CodeCommitSourceAction} from '@aws-cdk/aws-codepipeline-actions'
import {Bucket, IBucket} from '@aws-cdk/aws-s3'

export class PipelineStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props)

    const appName = this.node.tryGetContext('appName')
    const regionSecondary = this.node.tryGetContext('regionSecondary')

    const artifactBucket = new Bucket(this, 'PipelineBucket', {
      bucketName: `${appName}-${this.region}-${this.account}`,
    })

    const crossRegionBuckets: {[key: string]: IBucket} = {}

    crossRegionBuckets[this.region] = artifactBucket
    crossRegionBuckets[regionSecondary] = Bucket.fromBucketName(this, 'CrossRegionBucket',
      `${appName}-${regionSecondary}-${this.account}`,
    )

    const sourceArtifact = new Artifact('CodeCommitSource')
    const sourceAction = new CodeCommitSourceAction({
      actionName: 'CodeCommit',
      repository: Repository.fromRepositoryArn(this, 'CodeRepository',
        this.node.tryGetContext('existingRepositoryArn'),
      ),
      output: sourceArtifact,
    })

    // this is valid
    const sameRegionBuildAction = new CodeBuildAction({
      actionName: 'CodeBuild',
      project: new PipelineProject(this, 'SameRegionBuildProject'),
      input: sourceArtifact,
    })

    // this is not invalid
    const crossRegionBuildAction = new CodeBuildAction({
      actionName: 'CodeBuild',
      project: PipelineProject.fromProjectName(this, 'CrossRegionBuildProject',
        this.node.tryGetContext('crossRegionBuildProjectArn'),
      ),
      input: sourceArtifact,
      region: regionSecondary,
    })

    new Pipeline(this, 'CodePipeline', {
      crossRegionReplicationBuckets: crossRegionBuckets,
      stages: [
        {stageName: 'Source', actions: [sourceAction]},
        {stageName: 'Build', actions: [sameRegionBuildAction, crossRegionBuildAction]},
      ],
    })
  }
}
  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@amhammett amhammett added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Sep 10, 2020
amhammett added a commit to amhammett/aws-cdk that referenced this issue Sep 10, 2020
@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Sep 10, 2020
@skinny85 skinny85 added effort/small Small work item – less than a day of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Sep 11, 2020
@skinny85
Copy link
Contributor

Hello @amhammett ,

the CDK supports this capability natively. Just pass a CodeBuild Project that's from a different region into a CodeBuildAction, and everything will work!

Thanks,
Adam

@skinny85 skinny85 added guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p1 labels Oct 22, 2020
@github-actions
Copy link

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.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Oct 29, 2020
@github-actions github-actions bot closed this as completed Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codepipeline-actions closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
3 participants