I created an EC2 instance in us-east-1 using the command line below. The instance does not have a public IP, although I requested one. It is not possible to add a public IP after creation time, except for elastic IPs, which carry additional cost.
When I try the same command with a CentOS 7 or Ubuntu 22.04 AMI, a public IP is allocated as expected.
Command line:
aws ec2 run-instances --image-id ami-06885bf4009501fc0 --count 1 --instance-type t2.micro --key-name MY-KEY-NAME-HERE --associate-public-ip-address
Note that with the other AMIs "--associate-public-ip-address" is not actually required. I have tried both with and without this option.
Here is the output of describe-instances:
{
"Groups": [],
"Instances": [
{
"AmiLaunchIndex": 0,
"ImageId": "ami-06885bf4009501fc0",
"InstanceId": "i-0dfddb45f03aa386e",
"InstanceType": "t2.micro",
"KeyName": "a3-demo-tinytest",
"LaunchTime": "2023-08-08T18:09:26+00:00",
"Monitoring": {
"State": "disabled"
},
"Placement": {
"AvailabilityZone": "us-east-1d",
"GroupName": "",
"Tenancy": "default"
},
"PrivateDnsName": "ip-172-31-92-173.ec2.internal",
"PrivateIpAddress": "172.31.92.173",
"ProductCodes": [],
"PublicDnsName": "",
"State": {
"Code": 0,
"Name": "pending"
},
"StateTransitionReason": "",
"SubnetId": "subnet-498eab67",
"VpcId": "vpc-945a30ee",
"Architecture": "x86_64",
"BlockDeviceMappings": [],
"ClientToken": "e8ef92dc-264b-4730-89bc-19570b8901d1",
"EbsOptimized": false,
"EnaSupport": true,
"Hypervisor": "xen",
"NetworkInterfaces": [
{
"Attachment": {
"AttachTime": "2023-08-08T18:09:26+00:00",
"AttachmentId": "eni-attach-032a657d6e940bf25",
"DeleteOnTermination": true,
"DeviceIndex": 0,
"Status": "attaching",
"NetworkCardIndex": 0
},
"Description": "",
"Groups": [
{
"GroupName": "default",
"GroupId": "sg-66c1293b"
}
],
"Ipv6Addresses": [],
"MacAddress": "12:5c:0d:9d:e9:a9",
"NetworkInterfaceId": "eni-0cdd6f909afc4ceb0",
"OwnerId": "108378846686",
"PrivateDnsName": "ip-172-31-92-173.ec2.internal",
"PrivateIpAddress": "172.31.92.173",
"PrivateIpAddresses": [
{
"Primary": true,
"PrivateDnsName": "ip-172-31-92-173.ec2.internal",
"PrivateIpAddress": "172.31.92.173"
}
],
"SourceDestCheck": true,
"Status": "in-use",
"SubnetId": "subnet-498eab67",
"VpcId": "vpc-945a30ee",
"InterfaceType": "interface"
}
],
"RootDeviceName": "/dev/xvda",
"RootDeviceType": "ebs",
"SecurityGroups": [
{
"GroupName": "default",
"GroupId": "sg-66c1293b"
}
],
"SourceDestCheck": true,
"StateReason": {
"Code": "pending",
"Message": "pending"
},
"VirtualizationType": "hvm",
"CpuOptions": {
"CoreCount": 1,
"ThreadsPerCore": 1
},
"CapacityReservationSpecification": {
"CapacityReservationPreference": "open"
},
"MetadataOptions": {
"State": "pending",
"HttpTokens": "optional",
"HttpPutResponseHopLimit": 1,
"HttpEndpoint": "enabled",
"HttpProtocolIpv6": "disabled",
"InstanceMetadataTags": "disabled"
},
"EnclaveOptions": {
"Enabled": false
},
"PrivateDnsNameOptions": {
"HostnameType": "ip-name",
"EnableResourceNameDnsARecord": false,
"EnableResourceNameDnsAAAARecord": false
},
"MaintenanceOptions": {
"AutoRecovery": "default"
},
"CurrentInstanceBootMode": "legacy-bios"
}
],
"OwnerId": "108378846686",
"ReservationId": "r-08e683eba05901300"
}
For now I've pivoted to using Ubuntu, but would love to bring this project back to Debian.
Let me know if I can provide any further information.
--
THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER
APOSTROPHECMS | apostrophecms.com | he/him/his