In order, through the CLI:
- I create the vpc {10.1.0.0/16}
- I create two subnetworks {10.1.0.0/24, 10.1.1.0/24}
- I create the EC2 instance with the default NIC in the 10.1.0.0/24 subnet
aws ec2 run-instances --image-id $AWS_IMAGE --count 1 --instance-type $AWS_INSTANCE_TYPE --key-name $AWS_KEY_NAME --security-group-ids "$SG_ID" --subnet-id "$SUBNET_ID" --private-ip-address $AWS_GATEWAY_IP
- I create a new NIC with the 10.1.1.0/24 subnet
aws ec2 create-network-interface --subnet-id $SEC_SUBNET_ID --groups $SG_ID --private-ip-address $AWS_GATEWAY_SEC_IP
- I attach the new NIC to the previously created EC2 instance
aws ec2 attach-network-interface --network-interface-id $SEC_NIC_ID --instance-id $AWS_GATEWAY_ID --device-index 1
When I access through ssh the EC2 instance the second NIC is DOWN, if I turn it UP manually it doesn't have its private IP address and I have to set it manually also.
How can I make the secondary NIC enabled by default?