Aws-cdk: ecs.ContainerImage.from_asset broken in 1.33 - file parameter missing causing unrecoverable error

Created on 18 Apr 2020  路  2Comments  路  Source: aws/aws-cdk


On ContainerImage class from_asset method in Python CDK the file parameter name is missing which makes it impossible to use this method.

more info here

Reproduction Steps

Just use ContainerImage.from_asset(file='../Dockerfile', target='webserver') and that will throw a SyntaxError: invalid syntax error.

Error Log

$ cdk diff
Traceback (most recent call last):
File "app.py", line 6, in
from airflow.airflow_stack import AirflowStack
File "/Users/msilva/Projects/airflow/airflow/airflow_stack.py", line 3, in
from aws_cdk.aws_ecs import Cluster
File "/Users/msilva/Projects/airflow/.env/lib/python3.7/site-packages/aws_cdk/aws_ecs/__init__.py", line 7214
: typing.Optional[str]=None, repository_name: typing.Optional[str]=None, target: typing.Optional[str]=None, extra_hash: typing.Optional[str]=None, exclude: typing.Optional[typing.List[str]]=None, follow: typing.Optional[aws_cdk.assets.FollowMode]=None) -> "AssetImage":
^
SyntaxError: invalid syntax
Subprocess exited with error 1

Environment

  • CLI Version : 1.33.0
  • Framework Version: 1.33.0
  • OS : macOS 10.15.4
  • Language : Python

Other


This is :bug: Bug Report

bug guidance response-requested

Most helpful comment

Thanks @MrArnoldPalmer after posting this I've done a bit more debugging and reinstalled all the pip packages and now seems to be working. Sorry about this looks my IDE messed the lib packages up.

Closing it as is a non-bug.

All 2 comments

hey @mjsilva, the argument list for ContainerImage.fromAsset requires the positional argument directory. This is the directory used for the context of the docker build command. The keyword arg file is only required when using a dockerfile with a name other than Dockerfile. So you may be looking to call the function like so

ecs.ContainerImage.from_asset("path", file="Dockerfile.custom")

I tested this with cdk v1.33.0.

Thanks @MrArnoldPalmer after posting this I've done a bit more debugging and reinstalled all the pip packages and now seems to be working. Sorry about this looks my IDE messed the lib packages up.

Closing it as is a non-bug.

Was this page helpful?
0 / 5 - 0 ratings