我目前正在尝试在输出如下内容的变量中找到一个字符串:
一二三
我的代码:
echo "please enter one,two or three)
read var
var1=one,two,threee
if [[ "$var" == $var1 ]]; then
echo "$var is in the list"
else
echo "$var is not in the list"
fi
Run Code Online (Sandbox Code Playgroud)
编辑2:
我试过这个,但仍然不匹配。你是正确的,因为它匹配部分匹配,所以它不匹配先前答案中的确切字符串。
groups="$(aws iam list-groups --output text | awk '{print tolower($5)}' | sed '$!s/$/,/' | tr -d '\n')"
echo "please enter data"
read "var"
if [ ",${var}," = *",${groups},"* ]; then
echo "$var is in the list"
else
echo "$var is not in the list"
fi …Run Code Online (Sandbox Code Playgroud) 使用 terraform 我试图使用 count.index 在我的资源名称中包含计数,但无法显示计数。我基本上是想将计数添加到资源名称中,以便可以找到资源,否则资源是未知的。
count = 3
autoscaling_group_name = "${aws_autoscaling_group.exampleautoscaling-("count.index")-example.name}"
Run Code Online (Sandbox Code Playgroud)
错误
resource variables must be three parts: TYPE.NAME.ATTR in:
expected is : exampleautoscaling-1-example.name,exampleautoscaling-2-example.name,exampleautoscaling-3-example.name
Run Code Online (Sandbox Code Playgroud) 我目前在一个组织内使用多个 AWS 账户。我设置了多个具有代入角色的提供商。
有没有办法让资源在所有提供程序中滚动,以确保安装了我在 Terraform 模块中定义的所有内容?我试图避免每个提供程序都有一个资源,并且有一个资源可以使用每个提供程序。
希望有人可以对此提供帮助或有这样的用例。
TIA