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
已提問 1 年前檢視次數 247 次
1 個回答
0
已接受的答案

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
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南