aws-cdk: (codepipeline): Error: The 'account' property must be a concrete value (action: 'CodeBuild')

I have a CodePipeline pipeline with a GitHub source stage, a build stage which builds a Docker image using CodeBuild, and a deploy stage which deploys the image to ECS Fargate. I’ve been using the CDK to successfully construct quite a few of these similar pipelines recently however I’m now stuck on 1.99.0 as this error started happening in 1.100.0 and I’ve tried each release since then up to the most recent release (1.104.0) and they’re all not working. I’ve had a look at the release notes from 1.100.0 and have had a fiddle but have been unable to figure out what’s going wrong.

My code fails to validate. For example, when I run npx cdk diff --all, I get this error:

C:\path\to\my\project\node_modules\@aws-cdk\aws-codepipeline\lib\pipeline.ts:679
      // For every output artifact, get the producer
              ^
Error: The 'account' property must be a concrete value (action: 'CodeBuild')

Reproduction Steps

I’ve written a reusable function which takes props and creates a CodePipeline pipeline so I’m not sure exactly how to provide minimal reproduction code but here is the function. I’m using it to construct all my deployment pipelines in this project:

export interface BuildDeploymentPipelineProps {
  scope: cdk.Construct,
  id: string,
  envName: string,
  name: string,
  artifactBucket: s3.Bucket,
  gitHub: {
    owner: string,
    repo: string,
    branch: string,
    connectionArn: string,
  },
  codebuildProject: codebuild.Project,
  additionalBuildEnv?: { [name: string]: codebuild.BuildEnvironmentVariable },
  deploymentEcsServices: DeploymentEcsService[],
}

export interface DeploymentEcsService {
  name: string,
  service: ecs.FargateService
}

export const buildDeploymentPipeline = (props: BuildDeploymentPipelineProps): codepipeline.Pipeline => {
  const sourceOutput = new codepipeline.Artifact();
  const buildOutput = new codepipeline.Artifact();
  const deployActions: codepipeline.IAction[] = [];
  props.deploymentEcsServices.forEach((deployService) => {
    deployActions.push(
      new cpActions.EcsDeployAction({
        actionName: 'EcsDeploy' + deployService.name,
        service: deployService.service,
        input: buildOutput
      })
    )
  })
  return new codepipeline.Pipeline(props.scope, props.id, {
    pipelineName: naming.constructCodePipelinePipelineName(props.envName, props.name),
    artifactBucket: props.artifactBucket,
    restartExecutionOnUpdate: false,
    crossAccountKeys: false,
    stages: [
      {
        stageName: 'Source',
        actions: [
          new cpActions.CodeStarConnectionsSourceAction({
            actionName: 'GitHubSource',
            owner: props.gitHub.owner,
            repo: props.gitHub.repo,
            connectionArn: props.gitHub.connectionArn,
            output: sourceOutput,
            branch: props.gitHub.branch,
          })
        ]
      },
      {
        stageName: 'Build',
        actions: [
          new cpActions.CodeBuildAction({
            actionName: 'CodeBuild',
            project: codebuild.Project.fromProjectArn(props.scope, 'CodeBuildProject', props.codebuildProject.projectArn),
            input: sourceOutput,
            outputs: [buildOutput],
            environmentVariables: {
              ...props.additionalBuildEnv,
              IMAGE_TAG: {
                type:  codebuild.BuildEnvironmentVariableType.PLAINTEXT,
                value: props.gitHub.branch
              }
            },
          })
        ]
      },
      {
        stageName: 'Deploy',
        actions: deployActions
      }
    ]
  });
}

What did you expect to happen?

Exactly as I’m experiencing in 1.99.0, the pipeline is created.

What actually happened?

From 1.100.0 onwards, I’m getting the following error:

C:\path\to\my\project\node_modules\@aws-cdk\aws-codepipeline\lib\pipeline.ts:679
      // For every output artifact, get the producer
              ^
Error: The 'account' property must be a concrete value (action: 'CodeBuild')
    at Pipeline.getOtherStackIfActionIsCrossAccount (C:\Repositories\hiwaldo\infrastructure\node_modules\@aws-cdk\aws-codepipeline\lib\pipeline.ts:679:15)
    at Pipeline.getRoleFromActionPropsOrGenerateIfCrossAccount (C:\Repositories\hiwaldo\infrastructure\node_modules\@aws-cdk\aws-codepipeline\lib\pipeline.ts:637:36)
    at Pipeline.getRoleForAction (C:\Repositories\hiwaldo\infrastructure\node_modules\@aws-cdk\aws-codepipeline\lib\pipeline.ts:574:27)
    at Pipeline._attachActionToPipeline (C:\Repositories\hiwaldo\infrastructure\node_modules\@aws-cdk\aws-codepipeline\lib\pipeline.ts:405:29)
    at Stage.attachActionToPipeline (C:\Repositories\hiwaldo\infrastructure\node_modules\@aws-cdk\aws-codepipeline\lib\private\stage.ts:141:27)
    at Stage.addAction (C:\Repositories\hiwaldo\infrastructure\node_modules\@aws-cdk\aws-codepipeline\lib\private\stage.ts:91:29)
    at new Stage (C:\Repositories\hiwaldo\infrastructure\node_modules\@aws-cdk\aws-codepipeline\lib\private\stage.ts:38:12)
    at Pipeline.addStage (C:\Repositories\hiwaldo\infrastructure\node_modules\@aws-cdk\aws-codepipeline\lib\pipeline.ts:335:19)
    at new Pipeline (C:\Repositories\hiwaldo\infrastructure\node_modules\@aws-cdk\aws-codepipeline\lib\pipeline.ts:319:12)
    at Object.exports.buildDeploymentPipeline (C:\Repositories\hiwaldo\infrastructure\lib\services\services\buildDeploymentPipeline.ts:45:10)
Subprocess exited with error 1

Environment

  • CDK CLI Version : aws-cli/2.1.10
  • Framework Version : 1.100.0
  • Node.js Version: 14.15.3
  • OS : Windows 10 Pro
  • Language (Version): TypeScript (3.9.9)

Other


This is 🐛 Bug Report

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (22 by maintainers)

Most upvoted comments

You got it right again 🙂. The PR in #14224 fixed a bug (#14165), but it also accidentally surfaced this problem in your code.

But I would argue the code is actually correct now, and allowing the fromProjectArn to work was a mistake from the beginning.