简体   繁体   English

AWS CLI:如何使用变量过滤 EFS

[英]AWS CLI: How to use variable to filter EFS

I want to use the value of the DOMAIN_ID variable to filter the EFS to get a FileSystemId.我想使用DOMAIN_ID变量的值来过滤 EFS 以获取 FileSystemId。 I used the commands below.我使用了下面的命令。 The first command works and it stores the domain ID.第一个命令有效,它存储域 ID。 The second one returns an empty list, even though the DOMAIN_ID variable is present.第二个返回一个空列表,即使存在DOMAIN_ID变量。

DOMAIN_ID=$(aws sagemaker list-domains --query 'Domains[0].DomainId')
aws efs describe-file-systems --query 'FileSystems[?CreationToken==`$DOMAIN_ID`].FileSystemId'

Output:输出:

[]

Expected output:预期输出:

<Some EFS identifier>

This works (escaping backticks) -这有效(转义反引号) -

aws efs describe-file-systems --query "FileSystems[?CreationToken==\`$DOMAIN_ID\`].FileSystemId"

You can also use describe-domain command instead -您也可以改用 describe-domain 命令 -

$ DOMAIN_ID=$(aws sagemaker list-domains --query 'Domains[0].DomainId' | tr -d '"')
$ aws sagemaker describe-domain --domain-id $DOMAIN_ID --query 'HomeEfsFileSystemId'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM