1

In one of the cells of Sagemaker notebook, I've set a variable

region="us-west-2"

In subsequent cell, I run following 2 shell commands

!echo $region

Output

us-west-2

However, unable to run aws shell command using this variable

!aws ecr get-login-password --region $region

$ variable-name doesn't help inside jupyter cell ! shell command

2 Answers 2

1

As answered here: https://stackoverflow.com/a/19674648/5157515

There's no direct way to access python variables with ! command.

But with magic command %%bash it is possible

%%bash  -s "$region"
aws ecr get-login-password --region $1
Sign up to request clarification or add additional context in comments.

Comments

1

You can now do this using brackets:

region = 'us-east-2'
!echo {region}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.