cloud-init / userdata approach for GameLift?

0

Use Case

Initialize system environment variables for an instance so that OpenTelemetry Collector configuration can use these values. These values will be unique per instance (based on instance ID and other instance specific settings)

Problem

I didn't see any way to set UserData in a build or access anything similar to cloud-init -- basically a way to inject first boot code before other services are initialized.

Question

Is there another solution for GameLift servers, specifically Amazon Linux 2 in my case? Presumably it is something I would do in my install.sh script.

EDIT: I'm looking into doing a systemd hack. Maybe I can accomplish it with a service that the Collector service depends on where it sets the environment and then just perpetually sleeps in a loop. If this works, it will do, but it would be better to have something that wasn't hacked.

mjans71
preguntada hace un año247 visualizaciones
1 Respuesta
0
Respuesta aceptada

I accomplished this by creating a oneshot systemd service that just ran a simple bash script. Before=otelcol-sumo.service in the service unit file to force it to run before the Collector service. I added a simple file existence test at the beginning and then touch'ed that file after to cause it to only run on first boot. Probably not necessary since I'm not sure that GameLift servers reboot, but put it in for completeness. The process was also idempotent so it's doubly safe.

mjans71
respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas