Complete the code to launch an EC2 instance using AWS CLI.
aws ec2 run-instances --image-id [1] --count 1 --instance-type t2.micro
The --image-id option requires a valid AMI ID like ami-0abcdef1234567890 to launch an EC2 instance.
Complete the code to specify the instance type when launching an EC2 instance.
aws ec2 run-instances --image-id ami-0abcdef1234567890 --count 1 --instance-type [1]
The --instance-type option defines the hardware configuration. t2.micro is a common small instance type.
Fix the error in the command to add a key pair for SSH access.
aws ec2 run-instances --image-id ami-0abcdef1234567890 --count 1 --instance-type t2.micro --key-name [1]
The --key-name option requires the name of an existing key pair like my-key-pair to enable SSH access.
Fill both blanks to create a security group rule allowing SSH access on port 22.
aws ec2 authorize-security-group-ingress --group-id [1] --protocol [2] --port 22 --cidr 0.0.0.0/0
The --group-id specifies the security group ID like sg-0123456789abcdef0. The --protocol for SSH is tcp.
Fill all three blanks to tag an EC2 instance with Name and Environment tags.
aws ec2 create-tags --resources [1] --tags Key=Name,Value=[2] Key=Environment,Value=[3]
The --resources option needs the instance ID like i-0abcdef1234567890. The Name tag is set to WebServer and the Environment tag to Production.