[英]An error occurred (RequestExpired) when calling the DescribeInstances operation: Request has expired when I run the commend on AWS cloud9
When I run the following shell script which can allow user to use port80 in aws, errors orruc:当我运行以下 shell 脚本时,该脚本允许用户在 aws 中使用端口 80,出现错误或 ruc:
MY_INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id) # Get the ID of the instance for the environment, and store it temporarily.
MY_SECURITY_GROUP_ID=$(aws ec2 describe-instances --instance-id $MY_INSTANCE_ID --query 'Reservations[].Instances[0].SecurityGroups[0].GroupId' --output text) # Get the ID of the security group associated with the instance, and store it temporarily.
aws ec2 authorize-security-group-ingress --group-id $MY_SECURITY_GROUP_ID --protocol tcp --cidr 0.0.0.0/0 --port 80 # Add an inbound rule to the security group to allow all incoming IPv4-based traffic over port 80.
aws ec2 authorize-security-group-ingress --group-id $MY_SECURITY_GROUP_ID --ip-permissions IpProtocol=tcp,Ipv6Ranges='[{CidrIpv6=::/0}]',FromPort=80,ToPort=80 # Add an inbound rule to the security group to allow all incoming IPv6-based traffic over port 80.
MY_SUBNET_ID=$(aws ec2 describe-instances --instance-id $MY_INSTANCE_ID --query 'Reservations[].Instances[0].SubnetId' --output text) # Get the ID of the subnet associated with the instance, and store it temporarily.
MY_NETWORK_ACL_ID=$(aws ec2 describe-network-acls --filters Name=association.subnet-id,Values=$MY_SUBNET_ID --query 'NetworkAcls[].Associations[0].NetworkAclId' --output text) # Get the ID of the network ACL associated with the subnet, and store it temporarily.
aws ec2 create-network-acl-entry --network-acl-id $MY_NETWORK_ACL_ID --ingress --protocol tcp --rule-action allow --rule-number 10000 --cidr-block 0.0.0.0/0 --port-range From=80,To=80 # Add an inbound rule to the network ACL to allow all IPv4-based traffic over port 80. Advanced users: change this suggested rule number as desired.
aws ec2 create-network-acl-entry --network-acl-id $MY_NETWORK_ACL_ID --ingress --protocol tcp --rule-action allow --rule-number 10100 --ipv6-cidr-block ::/0 --port-range From=80,To=80 # Add an inbound rule to the network ACL to allow all IPv6-based traffic over port 80. Advanced users: change this suggested rule number as desired.
The error message is:错误信息是:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 19 100 19 0 0 1266 0 --:--:-- --:--:-- --:--:-- 1266
hello
An error occurred (RequestExpired) when calling the DescribeInstances operation: Request has expired.
hello
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument --group-id: expected one argument
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument --group-id: expected one argument
An error occurred (RequestExpired) when calling the DescribeInstances operation: Request has expired.
An error occurred (RequestExpired) when calling the DescribeNetworkAcls operation: Request has expired.
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument --network-acl-id: expected one argument
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument --network-acl-id: expected one argument
Process exited with code: 2
Pane is dead
I have try the code in a new environment, there is no any problem with it, what's wrong in my system?我已经在新环境中尝试了代码,没有任何问题,我的系统有什么问题吗? How can fix it?如何修复它?
If you are using different profiles, you would have to specify the profile in your command like shown below.如果您使用不同的配置文件,则必须在命令中指定配置文件,如下所示。
aws --profile <my-profile> ec2 describe-instances ...
Recommend checking first if AWS managed temporary credentials is disabled.建议首先检查 AWS 托管临时凭证是否已禁用。 Then use named profiles然后使用命名配置文件
Probably the AWS session was expired.可能 AWS session 已过期。 High possibility in enterprise environments due to IT policies.由于 IT 策略,企业环境中的可能性很高。
Try updating the credentials information by creating a fresh session.尝试通过创建一个新的 session 来更新凭据信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.