canonical / canonical/cloud-init
Network configuration not getting applied when launching AWS EC2 from Ubuntu
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
# Bug report
Network configuration not getting applied when launching AWS EC2 from Ubuntu.
## Steps to reproduce the problem
Launch EC2 instance from latest Canonical Ubuntu AMI and check cloud-init logs. A message like
```
No network config applied. Neither a new instance nor datasource network update allowed
```
will be issued instead of the expected
```
Applying network configuration from system_cfg bringup=True:
```
## Environment details
- Cloud-init version: 25.4
- Operating System Distribution: Ubuntu
- Cloud provider, platform or installer type: AWS
## cloud-init logs
Using latest Ubuntu 26 (resolute) AMI id ami-0d07100df1e046a78, launch an AWS EC2 (no user-data needed) and connect to it. Cloud-init network event type defaults to boot-new-instance; network renderer and activator is set to netplan by default in all Ubuntus.
We shall expect network configuration to be rendered and applied during the first boot. During Local stage it is in fact correctly rendered and not applied (network shouldn't be touched in this stage). But during Network stage network configuration exits with the following message:
```
2026-01-12 13:21:31,976 - stages.py[DEBUG]: Allowed events: {: {, }}
2026-01-12 13:21:31,976 - stages.py[DEBUG]: Event Denied: scopes=['network'] EventType=boot-legacy
2026-01-12 13:21:31,976 - stages.py[DEBUG]: No network config applied. Neither a new instance nor datasource network update allowed
```
This is due to datasource having been initialized already in the Local stage, retrieving the instance id and updating previous_iid (too early maybe ???). Then, in the Network stage of the first boot, cloud-init decides it's not a new instance.
Comparing to Amazon Linux 2023, we see Amazon solving it by disabling Local stage. Datasource is initialized during Network stage, retrieving metadata, generating and applying network configuration in a single step.
And corresponding logs:
```
2026-01-11 15:42:54,495 - util.py[DEBUG]: Cloud-init v. 22.2.2 running 'init' at Sun, 11 Jan 2026 15:42:54 +0000. Up 6.14 seconds.
...
2026-01-11 15:42:54,723 - stages.py[DEBUG]: previous iid found to be NO_PREVIOUS_INSTANCE_ID
...
2026-01-11 15:42:54,745 - stages.py[INFO]: Applying network configuration from ds bringup=True: {'version': 2, 'ethernets': {'ens5': {'dhcp4': True, 'dhcp6': False, 'match': {'macaddress': '0a:ff:e4:13:5b:9b'}, 'set-name': 'ens5'}}}
```
Is there a way to do the same and disable Local stage in Ubuntu ?
I'm aware that setting network event type to boot-legacy works as a workaround. But disabling Local stage seems the correct solution in my opinion.
Contributor guide
Research direction
Start by tracing cloud-init's Local and Network stages, including datasource initialization, previous_iid handling, and the boot-new-instance event shown in the logs. Compare the Ubuntu behavior with the Amazon Linux example; done means the first boot applies the rendered network configuration without requiring the boot-legacy workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, ubuntu
- Domain
- cloud, devops, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100