question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cdk-assets: extensibility

See original GitHub issue

Description

Before a stack is deployed, the provisioner will prepare all of the assets required by the stack. The types of assets currently supported are zip, file, container-image.

There are cases where other asset types would be useful, like existing container images (use case below). Leaving aside that CloudFormation can already handle that (use case below), this seems like a perfect use case for Plugin support.

Proposal

Allow plugins to contribute new asset types for preprocessing before stack deployment.

Use Case

I am using an internal container registry as the master repository for all of my Docker containers (used across all AWS Accounts). During the build, we already have the credentials for the internal (non-aws hosted) container registry and the URI to the particular container.

I then create two stacks, the first of which contains the ECS Cluster and Repository definitions. The second stack creates the task definition and requires the cluster and Repository as input parameters.

Before the second stack deploys, it would be great if we could issue some type of docker push command since the URI and repository are known at that time. I know this could be done with CloudFormation using SecretsManager. But push the container to the repository before the stack deploys feels a little cleaner to me…

Proposed Solution

Allow plugins to contribute new asset types.

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:11
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
benagricolacommented, Mar 16, 2020

Not sure if this is very helpful but I have a very similar use-case to this. I’d like to be able to run cdk inside a gitlab CI/CD process that does not have access to a local docker binary, or access to a docker.sock (for security reasons) to be able to build images.

I can build the images as part of the CI process (using kaniko for example) and these can then be outputted as a tar file or pushed to gitlab. Being able to hook the image build (in my case would be to no-op it) and the image push (to push the image from gitlab repo to the cdk-created ECR repo, probably using crane or something similar) would be amazing.

On language front - does this need to be defined? It might be a naïve suggestion but could you pass the path to an executable which handles the ‘build’ and ‘push’ part of the asset preparation?

At the moment the code calls docker build and push directly - could this functionality be moved into a ‘translation layer’ binary which is called by the cdk itself, and can be overridden if necessary?

It seems like there might be too many potential use cases there to take all of them into account with a single language choice imho.

2reactions
nmussycommented, Sep 26, 2019

Another use-case would be a lambda plugin that transpiles a TypeScript function into JavaScript. What I’ve also done in the past is tree-shake and transpile with webpack and @babel/typescript to trim down the dependencies, which could also be useful for plain JS functions.

Anyway, I think it’s a great idea 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Assets - AWS Cloud Development Kit (AWS CDK) v2
Assets are local files, directories, or Docker images that can be bundled into AWS CDK libraries and apps. For example, an asset might...
Read more >
GKE Cluster Setup with CDK for Terraform - HashiCorp
In this tutorial, I'll show you how to provision and manage a Google Kubernetes Engine (GKE) cluster using TypeScript via the CDK for...
Read more >
How to Create an Image Uploader Using AWS CDK
In this post, we'll create an image uploader using the AWS CDK. The project is serverless: we use services such as Lambda, S3,...
Read more >
cdk-assets - npm
cdk -assets requires an asset manifest file called assets.json , in a CDK CloudAssembly ( cdk.out/assets.json ). It will take the assets listed...
Read more >
AWS CDK for EKS — Kubernetes Manifest Handling - ITNEXT
In this post I will look at how CDK can handle Kubernetes YAML ... uses the CDK assets, installed in the CDKToolkit stack...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found