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
asked a year ago243 views
1 Answer
0
Accepted Answer

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
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions