我尝试使用python脚本中的以下调用在EC2实例上设置标记,我在其中传递变量subprocess.call('aws ec2 create-tags --resources $instanceId --tags "Key=somekey, Value=someval"')
作为添加标记的资源:
An error occurred (MissingParameter) when calling the CreateTags operation: The request must contain the parameter resourceIdSet
255
但是我收到了这个错误:
instanceId
然而,当我打印出<div [navPush]="cityPage" class="demo-card-square mdl-card mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-shadow--2dp" *ngFor="let item of cityinfo | async">
<figure class="mdl-card__media" (click)="showCityInfo(item)"> //CAN USE (tap) TOO.
<img src="{{ item.image }}" alt="" />
</figure>
{{ item.$key }}
</div>
时,我看到实例的正确id,所以我传递变量的方式一定有问题。对此有不同的约定吗?
答案 0 :(得分:1)
您的AWS CLI命令中的变量$instanceId
将最终成为shell变量,并且不会从您的Python代码中替换。
因此,如果$instanceId
是Python变量,您可能需要执行以下操作:
subprocess.call('aws ec2 create-tags --resources ' + $instanceId + ' --tags "Key=somekey, Value=someval"')
注意:我不是Python开发人员,所以这是一个黑暗中的刺刀。