-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Asset support in CI/CD pipelines #1312
Comments
I've asked some people more knowledgeable to take a look, but from the error message it looks like the project you're trying to deploy is using assets. This might not be supported yet. |
Hi @rix0rrr Thanks for the quick reply. WDYM by assets? This project has a static website and a lambda. const websiteBucket = new s3.Bucket(parent, 'bucket', {
websiteIndexDocument: 'index.html',
publicReadAccess: true
})
new s3deploy.BucketDeployment(parent, 'bucket-deployment', {
source: s3deploy.Source.asset('../web/build'),
destinationBucket: websiteBucket
})
const fn = new lambda.Function(parent, 'function', {
runtime: new lambda.Runtime('ruby2.5'),
handler: 'lambda.handler',
code: lambda.Code.asset('../app')
})
I'm wondering if the problem is with one of these |
Hi @phstc, This is what I mean by assets: new s3deploy.BucketDeployment(parent, 'bucket-deployment', {
source: s3deploy.Source.asset('../web/build'),
^^^^^ // this
destinationBucket: websiteBucket
})
const fn = new lambda.Function(parent, 'function', {
runtime: new lambda.Runtime('ruby2.5'),
handler: 'lambda.handler',
code: lambda.Code.asset('../app')
^^^^^ // and this
}) Any time you're referencing files on your local file system, we're referring to that as "assets". It seems my guess that there is no CI/CD asset support yet is true. One of my team members who knows more about this will chip in with more information shortly. |
Thanks again @rix0rrr Confirmed. When I remove my bucket and lambda |
Is the workaround to use inline lambda code for the time being? |
If anyone else runs into this, I used this as a workaround: new lambda.Function(this, 'function', {
runtime: lambda.Runtime.NodeJS810,
handler: 'index.handler',
code: lambda.Code.inline(this.localAsset(path.join(__dirname, 'index.js'))),
}); localAsset(path: string) {
return fs.readFileSync(path, 'utf8');
} |
So as far as I can tell this means any CDK project using decently large Lambdas can't be deployed through a proper CD pipeline? It has to be a full If there was a step between the lines here: https://github.com/aws/aws-cdk/blob/master/packages/aws-cdk/lib/api/deploy-stack.ts#L91 for creating a ChangeSet and Executing it, I belive it could work. Everything would have been uploaded and parameters would be set, but it wouldn't be released until the Execute step. Which could be manual, CodePipeline or CLI. |
@joshrp we're using |
I hadn't see the If I have to rely on Ideally |
I'm running into the same issue, just found the issue now |
Please see #3437 for details on how we plan to support this |
This only handles the Lambda. Is there currently a workaround for the BucketDeployment asset? |
This PR includes the RFC for supporting CI/CD for CDK apps of any complexity. It also includes the RFC for cdk-assets which is a tool for publishing CDK assets, and is part of the CI/CD solution. Tracking issue: aws/aws-cdk-rfcs#49 Addresses: #1312
Any updates on when this is expected to be supported? |
In a current project we're using this gist as workaround while waiting for native CDK support: https://gist.github.com/ottokruse/41694de3831d6bfe9080743b352aa2fe It's a script to publish CDK assets (e.g. Lambda function code) to S3 and generate parameter files, so you can combine cdk synth with CloudFormation deployments. This is essentially the equivalent of 'sam package' but then for CDK. |
@BDQ How do you handle cdk permissions within codebuild? |
@mikestopcontinues we add the required permissions codebuild job's Role policy: const deploy = new codebuild.PipelineProject(stack, "dply", {...})
deploy.addToRolePolicy(
new iam.PolicyStatement({
resources: [...],
actions: [...]
})
) |
@BDQ Thanks! |
This has been implemented as CDK Pipelines. |
@rix0rrr Are there plans to support report groups in pipelines? It's why I haven't switched to them. |
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 outputstemplate.yaml
) then I set as thetemplatePath
as follows:But I keep getting this error on the
PrepareChanges
stage: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 fromsource
instead ofbuild
:But it didn't work, I got the same error.
Any ideas?
The text was updated successfully, but these errors were encountered: