aws-cloudformation / cloudformation-cli-python-plugin

The CloudFormation Provider Development Toolkit Python Plugin allows you to autogenerate Python code based on an input schema.
Apache License 2.0
108 stars 47 forks source link

Updated lambda docker image is missing `git` #228

Closed skarimo closed 1 year ago

skarimo commented 1 year ago

Our Cloudformation resources pull in their dependencies from a common package by specifying the common packages git url in the requirements file.

git+https://github.com/<owner_name>/<repo_name>.git

Due to change made in the following pr https://github.com/aws-cloudformation/cloudformation-cli-python-plugin/pull/193, we cannot update our resources to use the new cloudformation-cli-python-plugin versions as git is not installed in the new base image. Hence, pip fails to clone the repo and install the requirements.

This fails in non-obvious ways as well:

[2022-11-22T21:58:19Z] DEBUG    - Caught downstream error
Traceback (most recent call last):
  File "/Users/<user>/Dev/datadog-cloudformation-resources/datadog-monitors-monitor-handler/.venv/lib/python3.10/site-packages/rpdk/python/codegen.py", line 306, in _docker_build
    logs = docker_client.containers.run(
  File "/Users/<user>/Dev/datadog-cloudformation-resources/datadog-monitors-monitor-handler/.venv/lib/python3.10/site-packages/docker/models/containers.py", line 876, in run
    raise ContainerError(
docker.errors.ContainerError: Command '/bin/bash -c "pip install --no-cache-dir --no-color --disable-pip-version-check --upgrade --requirement /project/requirements.txt --target /project/build"' in image 'public.ecr.aws/lambda/python:3.7' returned non-zero exit status 1

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/<user>/Dev/datadog-cloudformation-resources/datadog-monitors-monitor-handler/.venv/lib/python3.10/site-packages/rpdk/core/cli.py", line 100, in main
    args.command(args)
  File "/Users/<user>/Dev/datadog-cloudformation-resources/datadog-monitors-monitor-handler/.venv/lib/python3.10/site-packages/rpdk/core/submit.py", line 15, in submit
    project.submit(
  File "/Users/<user>/Dev/datadog-cloudformation-resources/datadog-monitors-monitor-handler/.venv/lib/python3.10/site-packages/rpdk/core/project.py", line 636, in submit
    self._add_resources_content_to_zip(zip_file)
  File "/Users/<user>/Dev/datadog-cloudformation-resources/datadog-monitors-monitor-handler/.venv/lib/python3.10/site-packages/rpdk/core/project.py", line 664, in _add_resources_content_to_zip
    self._plugin.package(self, zip_file)
  File "/Users/<user>/Dev/datadog-cloudformation-resources/datadog-monitors-monitor-handler/.venv/lib/python3.10/site-packages/rpdk/python/codegen.py", line 227, in package
    self._build(project.root)
  File "/Users/<user>/Dev/datadog-cloudformation-resources/datadog-monitors-monitor-handler/.venv/lib/python3.10/site-packages/rpdk/python/codegen.py", line 244, in _build
    self._docker_build(base_path)
  File "/Users/<user>/Dev/datadog-cloudformation-resources/datadog-monitors-monitor-handler/.venv/lib/python3.10/site-packages/rpdk/python/codegen.py", line 325, in _docker_build
    raise DownstreamError("Error running docker build") from e
rpdk.core.exceptions.DownstreamError: Error running docker build
mmaeng commented 1 year ago

Thanks for the report @skarimo ! Taking a look.

We are also available on AWS CloudFormation Discord!

skarimo commented 1 year ago

@mmaeng Thanks for making the changes!