Skip to content

Asset support in CI/CD pipelines #1312

@phstc

Description

@phstc

Hi

I'm trying to follow these steps CodePipeline Actions for CloudFormation for building with CFN, but I'm have a hard time to make templatePath work.

CodeBuild calls cdk synth (and outputs template.yaml) then I set as the templatePath as follows:

const project = new codebuild.PipelineProject(this, 'Project', {
  environment: {
    buildImage: codebuild.LinuxBuildImage.UBUNTU_14_04_NODEJS_10_1_0
  },
  buildSpec: {
    version: '0.2',
    phases: {
      install: {
        commands: [
          '...'
        ]
      },
      build: {
        commands: [
          'cdk synth > ../template.yaml'
        ]
      }
    },
    artifacts: {
      files: ['template.yaml']
    }
  }
})

// ...

const pipeline = new codepipeline.Pipeline(this, 'CodePipeline', {})

const build = new codebuild.PipelineBuildAction(this, 'CodeBuild', {
  stage: pipeline.addStage('Build'),
  project,
  outputArtifactName: 'Build'
})

new cfn.PipelineCreateReplaceChangeSetAction(prodStage, 'PrepareChanges', {
  stage: prodStage,
  stackName,
  changeSetName,
  adminPermissions: true,
  templatePath: build.outputArtifact.atPath('template.yaml')
})

But I keep getting this error on the PrepareChanges stage:

image

I checked the artifact generated in the build stage and the template.yaml is in there.

Just as a random attempt, I've also tried to commit the template.yaml and use directly from source instead of build:

new codepipeline.GitHubSourceAction(this, 'GitHubSource', {
  stage: pipeline.addStage('Source'),
  owner: 'project',
  repo: 'repo',
  branch: 'master',
  oauthToken: new Secret(oauth.value),
  outputArtifactName: 'Source'
})

new cfn.PipelineCreateReplaceChangeSetAction(prodStage, 'PrepareChanges', {
  stage: prodStage,
  stackName,
  changeSetName,
  adminPermissions: true,
  templatePath: source.outputArtifact.atPath('template.yaml')
})

But it didn't work, I got the same error.

Any ideas?

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-codepipelineRelated to AWS CodePipelineeffort/largeLarge work item – several weeks of effortfeature-requestA feature should be added or improved.in-progressThis issue is being actively worked on.package/toolsRelated to AWS CDK Tools or CLI

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions