-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
documentationThis is a problem with documentation.This is a problem with documentation.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp1
Description
General Issue
I am trying to get my CI/CD working using an AWS CDK pipeline with the modern API. What I desire is somewhat simple :
- I want my infra as code in CDK
- I want a CI/CD pipeline that triggers either on an update on the CDK repository or on my Lambda function code repository (they are two separate repositories)
- I want the pipeline to take care of the build of my Lambda function code
The Question
So far, this is what I have got, trying to get something working :
import * as cdk from 'aws-cdk-lib';
import * as codepipeline_actions from 'aws-cdk-lib/aws-codepipeline-actions';
import * as codepipeline from 'aws-cdk-lib/aws-codepipeline'
import * as codebuild from 'aws-cdk-lib/aws-codebuild'
import { Construct } from 'constructs';
import { CodePipeline, CodePipelineSource, ShellStep, CodeBuildStep } from 'aws-cdk-lib/pipelines';
export class CdkPipelineStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// parameters
const ConnectionArn = 'arn:aws:codestar-connections:region:account:connection/xxx-yyyy'
// Source
const cdkCodeStarConnection = CodePipelineSource.connection('owner/cdk-repo', 'master', {
connectionArn: ConnectionArn
})
const lambdaCodeStarConnection = CodePipelineSource.connection('owner/lambda-repo', 'master', {
connectionArn: ConnectionArn
})
// Building Lambda
const lambdaBuildStep = new CodeBuildStep('BuildLambda', {
input: lambdaCodeStarConnection,
commands: [''],
partialBuildSpec: codebuild.BuildSpec.fromSourceFilename('buildspec.yaml'),// this is store in the Lambda repo
buildEnvironment: {
buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_3
}
})
const pipeline = new CodePipeline(this, 'Pipeline', {
pipelineName: 'Pipeline',
synth: new ShellStep('Synth', {
input: cdkCodeStarConnection,
commands: ['npm ci', 'npm run build', 'npx cdk synth'],
additionalInputs: {'lambda' : lambdaBuildStep}
})
});
}
}With this, when I synth I receive the following message :
\shell-step.ts:81
throw new Error(`'${id}': additionalInput for directory '${directory}' should be a step that produces a file set, got ${step}`);so the criminal is clearly this line :
additionalInputs: {'lambda' : lambdaBuildStep}but I don't understand why because given the documentation, CodeBuildStep implements IFileSetProducer and should therefore be accepted given that this page states that an IFileSetProducer is Any class that produces, or is itself, a FileSet.
What am I doing wrong ?
CDK CLI Version
2.8.0
Framework Version
No response
Node.js Version
No response
OS
Windows
Language
Typescript
Language Version
TypeScript (4.5.4)
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationThis is a problem with documentation.This is a problem with documentation.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp1