Skip to content
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

[WIP] Design for generic builder interface #88

Closed
wants to merge 2 commits into from

Conversation

sam-goodwin
Copy link

@sam-goodwin sam-goodwin commented Feb 22, 2019

Proposal to extend aws-lambda-builders to become a generic library for building all AWS projects.

Still more details to be worked out, esp. around the UX experience and implementation details. Looking forward to discussion from those with more context.

Supports: aws/aws-cdk#1435

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the extension to "ECS" but at this point it feels like a very high level requirement. What does that technically mean to build for ECS? Is it just building docker images? Unless we have a very concrete requirement, I would recommend to start with what we know (i.e. merge SAM CLI logic into Lambda Builders and provide a Docker-interface) and only at the second phase extend to ECS once requirements are clear. Alternatively, dive deep into the requirements.

--------------------
Tools like the [Cloud Development Kit (CDK) CLI](https://github.com/awslabs/aws-cdk) and the [Elastic Contianer Service (ECS) CLI](https://github.com/aws/amazon-ecs-cli) require a single library to encapsulate the logic of assembling a project's source code into an artifact deployable to AWS. Since the CDK covers the entire surface area of AWS, not just serverless use-cases like SAM, the scope of `aws-lambda-builders` must be extended to include non-lambda target environments such as Docker images for ECR. This also asks questions of branding, perhaps requiring a new project named `aws-builders`.

The logic for mapping a project's structure to a workflow (e.g. looking for `pom.xml` or `build.gradle` to determine the java project type) is currently bundled into SAM CLI instead of `aws-lambda-builders`, burdening and limiting consumers.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of "burdening and limiting" I would say "which makes it hard to reuse" or something in those lines

---------------------
Extract the automatic project inference from `sam cli` into this library and extend the RPC interface so that projects other than Lambda functions may also be built and packaged.

Rename or create a new package, `aws-builders`, to better represent the (now) wider-surface area.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"aws-build"?


Rename or create a new package, `aws-builders`, to better represent the (now) wider-surface area.

Publish Docker images bundling the CLI for various target language/platforms so that consumers need not depend on `pip install` to consume the CLI. Instead, the tool can be invoked with [`docker run`](https://docs.docker.com/engine/reference/commandline/run/), requiring only a single dependency on the Docker toolchain.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and inline with how SAM CLI is actually using lambda-builders today to ensure that native code is compiled to the correct platform


What is the problem?
--------------------
Tools like the [Cloud Development Kit (CDK) CLI](https://github.com/awslabs/aws-cdk) and the [Elastic Contianer Service (ECS) CLI](https://github.com/aws/amazon-ecs-cli) require a single library to encapsulate the logic of assembling a project's source code into an artifact deployable to AWS. Since the CDK covers the entire surface area of AWS, not just serverless use-cases like SAM, the scope of `aws-lambda-builders` must be extended to include non-lambda target environments such as Docker images for ECR. This also asks questions of branding, perhaps requiring a new project named `aws-builders`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change "must be extended" to "could be extended"

@eladb
Copy link

eladb commented Feb 24, 2019

Copy @clareliguori @SoManyHs @rix0rrr

For the CDK use-case, we wish to instantiate a language-specific function type and only have to point to the project's location:

```ts
const myFunction = new lambda.JavaFunction(stack, 'MyJavaFunction', {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we make use of the newly centralized build/language detection logic to get rid of the need of specifying Java here?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, strictly speaking, shouldn't this be called JvmFunction? :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a different APIs for defining the build project for different languages. Different way to specify dependencies/handlers/runtime versions. I like the strong typing.

1. Do we want to rename this project or create a new package encapsulating the generic functionality?
2. What to do about `pip install`? Is there a better way to expose the CLI for local installation or inclusion in a `Dockerfile`?
3. Which environments/configurations should we publish Docker containers for? E.g. one container for NPM, one for Java, one for Python, etc. etc.
4. Do we want to provide hooks for developers to customize a build when their use-case is not supported?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lack of customization hooks seems like a nonstarter. What if a project build requires additional installed tool dependencies, or private package repositories, or ANYTHING, really. Let's give people the ability to build what they need from the start, and add incremental sugar later.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

customization hooks are usually built into the language specific build system. Maven has like a million hooks, npm has hooks for pre-install post-install, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rix0rrr #4 is tracking passing arbitrary options to build tools. We didn't enable this from the beginning because we wanted builds to work out-of-box with majority of cases without additional work.

- \[x\] Send a Pull Request with this design document
- \[ \] Extract project inference from SAM CLI to `aws-lambda-builders`
- \[ \] Update RPC to support the higher-level use cases (project inference)
- \[ \] Publish a Docker image for each language we support (javascript, java, python, go mod, go dep)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build a pipeline for all images we vend!

@clareliguori
Copy link
Member

Agree with @eladb, I would start without targeting ecs-cli. I'm not actually sure it makes sense for ecs-cli to leverage this library: the ecs-cli is intended to fit into a user's existing docker-compose workflow, so they use docker-compose directly to assemble everything. In which case, the user does something like

docker-compose build
docker-compose push
ecs-cli -f my-compose-file.yml service up

For CDK + ECS, there is already a Docker "asset" type for building and pushing the Docker image.

@sam-goodwin
Copy link
Author

Preliminary work in the CDK can be seen here: aws/aws-cdk#1884

Would love your feedback @sanathkr

@jfuss jfuss closed this Mar 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants