如何在AWS上通过shell脚本在安全组中添加多个入口规则



我正试图通过在EC2实例上运行shell脚本,将100个IP的规则添加到一个安全组中。

aws ec2 authorize-security-group-ingress --protocol tcp --port 9997 --cidr ${fixed_ips} --group-id $group_ids

我得到以下错误,尽管我有管理员访问权限:

An error occurred (UnauthorizedOperation) when calling the AuthorizeSecurityGroupIngress operation: You are not authorized to perform this operation. Encoded authorization failure message:

错误写入:

You are not authorized

这意味着您没有执行authorize-security-group-ingress操作的权限。您必须仔细检查您的IAM用户/角色以及您可能受到的任何SCP,以确保您有权执行有问题的操作。这可能包括使用错误的区域。

更新:

如果代码在EC2实例上运行,则必须使用所需的权限设置实例角色。

最新更新