AMI IDs are region-specific. Select an AMI appropriate for your region (for example, Ubuntu 22.04 LTS) from the EC2 console or query the AWS CLI. See the EC2 console’s Launch Instance workflow for the image’s AMI ID.
ami field of the code above.

Run pulumi up to preview and apply the changes. The preview shows the planned resources:
ubuntu:
By default, the security group attached to a new EC2 instance may not allow SSH from the internet. If you cannot connect, check the instance’s Security Group inbound rules and ensure SSH (port 22) is allowed from your IP (or an appropriate CIDR). Restrict access to your IP rather than opening SSH to 0.0.0.0/0 whenever possible.
- Verify the AMI ID is valid in your AWS region.
- Confirm your key pair name matches an existing key pair and you have the corresponding PEM file.
- Inspect the instance’s public IP in Pulumi outputs or the EC2 console.
- Check Security Group inbound rules to allow SSH from your IP.
- Ensure the instance was launched in a subnet that provides/associates a public IP or explicitly set associate_public_ip_address if needed.
- Pulumi AWS provider: https://www.pulumi.com/docs/reference/pkg/aws/
- EC2 documentation: https://docs.aws.amazon.com/ec2/
- Finding AMIs in the AWS Console: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html
