Using cloud-init on AWS to Initialize vMX Instances
Starting with Junos
OS Release 17.2R1, when you create the vMX instance, you can use cloud-init
services on AWS to pass a valid Junos OS configuration
file as user data to initialize the vMX instance. The user-data file uses the standard Junos OS syntax to define all
the configuration details for your vMX instance. The user-data file
cannot exceed 16 KB. If your user-data file exceeds this limit, you
must compress the file using gzip and use the compressed file. For
example, the gzip junos.conf
command results in the junos.conf.gz file.
The configuration must be validated and include details for the fxp0 interface, login, and authentication. It must also have a default route for traffic on fxp0. This information must match the details of the AWS VPC and subnet into which the instance is launched. If any of this information is missing or incorrect, the instance is inaccessible and you must launch a new one.
The Junos OS configuration that is passed as user data is only imported at initial launch. If the instance is stopped and restarted, the user-data file is not imported again.
To create the user-data file:
This sample user-data file is the default file that is used when you do not specify a file. It uses the special tags in the configuration.
#junos-config groups { global { system { host-name HOSTNAME; services { ssh { root-login deny-password; } } login { user jnpr { uid 2000; class super-user; authentication { ssh-rsa "SSHRSAKEY"; ## SECRET-DATA } } } syslog { user * { any emergency; } file messages { any notice; authorization info; } file interactive-commands { interactive-commands any; } } } interfaces { fxp0 { unit 0 { family inet { address FXP0ADDR; } } } } routing-options { static { route 0.0.0.0/0 { next-hop GATEWAY; retain; no-readvertise; } } } } } apply-groups global;