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
질문됨 일 년 전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
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠