https://prefect.io logo
m

Mattias Petter Johansson

09/14/2023, 5:30 PM
@Marvin This part of the script: - prefect.deployments.steps.run_shell_script: id: login-for-aws-ecr script: aws ecr get-login-password --region eu-north-1 | docker login --username AWS --password-stdin 199214789681.dkr.ecr.eu-north-1.amazonaws.com stream_output: true gives an error because of Unknown options: |,docker,login,--username,AWS,--password-stdin,199214789681.dkr.ecr.eu-north-1.amazonaws.com Do I need to escape the script value or add quotes or something?
m

Marvin

09/14/2023, 5:31 PM
Ah, the joys of scripting. It's like trying to communicate with a particularly stubborn and literal-minded alien species, isn't it? The error message you're seeing suggests that the shell is having trouble parsing the command. The pipe character (
|
) is used in shell scripts to pass the output of one command as the input to another. However, it seems like the shell is interpreting it as a part of the
aws ecr get-login-password
command, which it isn't. You might want to try enclosing the entire command in quotes. Here's how you could adjust your script:
Copy code
yaml
- prefect.deployments.steps.run_shell_script:
    id: login-for-aws-ecr
    script: "aws ecr get-login-password --region eu-north-1 | docker login --username AWS --password-stdin <http://199214789681.dkr.ecr.eu-north-1.amazonaws.com|199214789681.dkr.ecr.eu-north-1.amazonaws.com>"
    stream_output: true
This should ensure that the shell interprets the pipe character correctly. If this doesn't work, you might be dealing with a more complex issue. But let's cross that bridge when we come to it, shall we?
m

Mattias Petter Johansson

09/14/2023, 5:38 PM
@Marvin nope same error
m

Marvin

09/14/2023, 5:39 PM
Ah, the universe's infinite capacity for throwing up obstacles. It's almost inspiring, in a deeply depressing sort of way. The issue might be related to how the shell script is being executed within the context of the Prefect task. It's possible that the command isn't being interpreted by a shell, but instead is being split into parts and passed directly to an exec function. In this case, the pipe character and the redirection wouldn't be recognized. Here's a workaround that might help. You could try wrapping the command in a shell - like bash - and executing it as a single string. Here's how you could adjust your script:
Copy code
yaml
- prefect.deployments.steps.run_shell_script:
    id: login-for-aws-ecr
    script: "/bin/bash -c 'aws ecr get-login-password --region eu-north-1 | docker login --username AWS --password-stdin <http://199214789681.dkr.ecr.eu-north-1.amazonaws.com|199214789681.dkr.ecr.eu-north-1.amazonaws.com>'"
    stream_output: true
This should force the command to be interpreted by a shell, which should understand the pipe character and the redirection. If this doesn't work, well, we'll just have to come up with another plan. It's not like I have anything better to do.