Hey Team, I'm trying to use secrets in shell task...
# ask-the-community
g
Hey Team, I'm trying to use secrets in shell tasks. Mostly referencing this discussion with @Ketan (kumare3) https://discuss.flyte.org/t/1031/hey-all-i-m-having-trouble-using-a-shelltask-with-secrets-in My ShellTask looks like this:
Copy code
SECRET_GROUP='arn:aws:secretsmanager:region:id:secret:'
SECRET_KEY='secret-name:random5'
updater_cmd = ShellTask(
    name="task_3",
    debug=True,
    
    inputs=kwtypes(
        tenant_id=str, 
        redirect_url=str ,scope=str , 
        list_id=str ,site_id=str ,
        calendar_user=str, calendar_id=str, 
        update_sharepoint=str, update_calendar=str, 
        send_emails=str),
    script="""
    env;
    echo "test123";
    export CLIENT_ID={ctx.secrets.get('arn:aws:secretsmanager:region:id:secret:', 'secret-name:random5')};
    exit -1;
    """,
    secret_requests=[
        Secret(
            group=SECRET_GROUP,
            key=SECRET_KEY,
            mount_requirement=Secret.MountType.ENV_VAR
        ),
    ]
)
But when I try to run it, I get this error:
Copy code
[3/3] currentAttempt done. Last Error: SYSTEM::Traceback (most recent call last):

      File "/opt/venv/lib/python3.8/site-packages/flytekit/exceptions/scopes.py", line 178, in system_entry_point
        return wrapped(*args, **kwargs)
      File "/opt/venv/lib/python3.8/site-packages/flytekit/core/base_task.py", line 675, in dispatch_execute
        native_outputs = self.execute(**native_inputs)
      File "/opt/venv/lib/python3.8/site-packages/flytekit/extras/tasks/shell.py", line 314, in execute
        gen_script = self._interpolizer.interpolate(self._script, inputs=kwargs, outputs=outputs)
      File "/opt/venv/lib/python3.8/site-packages/flytekit/extras/tasks/shell.py", line 155, in interpolate
        return self._Formatter().format(tmpl, **consolidated_args)
      File "/usr/local/lib/python3.8/string.py", line 163, in format
        return self.vformat(format_string, args, kwargs)
      File "/usr/local/lib/python3.8/string.py", line 167, in vformat
        result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
      File "/usr/local/lib/python3.8/string.py", line 220, in _vformat
        result.append(self.format_field(obj, format_spec))
      File "/opt/venv/lib/python3.8/site-packages/flytekit/extras/tasks/shell.py", line 133, in format_field
        return super().format_field(value, format_spec)
      File "/usr/local/lib/python3.8/string.py", line 237, in format_field
        return format(value, format_spec)

Message:

    TypeError: unsupported format string passed to _GroupSecrets.__format__

SYSTEM ERROR! Contact platform administrators.
What am I missing? Thank you kindly.
s
looks like it isn't supported yet: https://discuss.flyte.org/t/1031/hey-all-i-m-having-trouble-using-a-shelltask-with-secrets-in#02d282ad-bcb4-4a98-bedb-c47e2a27c576. the syntax specified in this PR description should work, though. would you mind creating an issue?
g