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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ