mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-05-31 13:56:13 -07:00
fix: pass Unity license secrets to AWS ECS container via RunTask overrides (#821)
* fix: pass Unity license secrets to AWS ECS container via RunTask overrides The AWS provider was not passing UNITY_EMAIL, UNITY_PASSWORD, and UNITY_SERIAL to the ECS container as environment variables. These secrets were only sent to CloudFormation Secrets Manager, but the template generation produced duplicate YAML Secrets keys (one per secret), causing only the last secret to survive. The activate.sh script requires all three to be present simultaneously. This fix merges secrets into the ECS RunTask containerOverrides environment array, matching how the docker and k8s providers already handle secrets. The CloudFormation Secrets Manager path is preserved as a secondary mechanism. Fixes license activation failure when using providerStrategy: aws. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Pin LocalStack to 4.4.0 (pre-auth-token requirement) As of 2026-03-23, localstack/localstack:latest requires an auth token even for community features. Pin to 4.4.0 (last community release before the single-image migration) to restore CI. See: https://blog.localstack.cloud/localstack-single-image-next-steps/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2
.github/workflows/orchestrator-integrity.yml
vendored
2
.github/workflows/orchestrator-integrity.yml
vendored
@@ -91,7 +91,7 @@ jobs:
|
||||
-e SERVICES=s3,cloudformation,ecs,kinesis,cloudwatch,logs,efs,ec2,iam,elasticfilesystem,secretsmanager,lambda,events,sts \
|
||||
-e DEBUG=0 \
|
||||
-e HOSTNAME_EXTERNAL=localstack-main \
|
||||
localstack/localstack:latest || true
|
||||
localstack/localstack:4.4.0 || true
|
||||
# Wait for LocalStack to be ready - check both health endpoint and S3 service
|
||||
echo "Waiting for LocalStack to be ready..."
|
||||
MAX_ATTEMPTS=60
|
||||
|
||||
11
dist/index.js
generated
vendored
11
dist/index.js
generated
vendored
@@ -3398,7 +3398,7 @@ class AWSTaskRunner {
|
||||
return { name: x.name, value };
|
||||
});
|
||||
}
|
||||
static async runTask(taskDef, environment, commands) {
|
||||
static async runTask(taskDef, environment, secrets, commands) {
|
||||
const cluster = taskDef.baseResources?.find((x) => x.LogicalResourceId === 'ECSCluster')?.PhysicalResourceId || '';
|
||||
const taskDefinition = taskDef.taskDefResources?.find((x) => x.LogicalResourceId === 'TaskDefinition')?.PhysicalResourceId || '';
|
||||
const SubnetOne = taskDef.baseResources?.find((x) => x.LogicalResourceId === 'PublicSubnetOne')?.PhysicalResourceId || '';
|
||||
@@ -3407,6 +3407,11 @@ class AWSTaskRunner {
|
||||
const streamName = taskDef.taskDefResources?.find((x) => x.LogicalResourceId === 'KinesisStream')?.PhysicalResourceId || '';
|
||||
// Transform localhost endpoints for container environment
|
||||
const transformedEnvironment = AWSTaskRunner.transformEndpointsForContainer(environment);
|
||||
// Merge secrets into environment as plain env vars, matching docker and k8s provider behavior.
|
||||
// This ensures UNITY_EMAIL, UNITY_PASSWORD, UNITY_SERIAL reach the container reliably
|
||||
// without depending on CloudFormation Secrets Manager resolution.
|
||||
const secretsAsEnvironment = secrets.map((s) => ({ name: s.EnvironmentVariable, value: s.ParameterValue }));
|
||||
const mergedEnvironment = [...transformedEnvironment, ...secretsAsEnvironment];
|
||||
const runParameters = {
|
||||
cluster,
|
||||
taskDefinition,
|
||||
@@ -3415,7 +3420,7 @@ class AWSTaskRunner {
|
||||
containerOverrides: [
|
||||
{
|
||||
name: taskDef.taskDefStackName,
|
||||
environment: transformedEnvironment,
|
||||
environment: mergedEnvironment,
|
||||
command: ['-c', command_hook_service_1.CommandHookService.ApplyHooksToCommands(commands, orchestrator_1.default.buildParameters)],
|
||||
},
|
||||
],
|
||||
@@ -4449,7 +4454,7 @@ class AWSBuildEnvironment {
|
||||
try {
|
||||
const postSetupStacksTimeMs = Date.now();
|
||||
orchestrator_logger_1.default.log(`Setup job time: ${Math.floor((postSetupStacksTimeMs - startTimeMs) / 1000)}s`);
|
||||
const { output, shouldCleanup } = await aws_task_runner_1.default.runTask(taskDef, environment, commands);
|
||||
const { output, shouldCleanup } = await aws_task_runner_1.default.runTask(taskDef, environment, secrets, commands);
|
||||
postRunTaskTimeMs = Date.now();
|
||||
orchestrator_logger_1.default.log(`Run job time: ${Math.floor((postRunTaskTimeMs - postSetupStacksTimeMs) / 1000)}s`);
|
||||
if (shouldCleanup) {
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -1,6 +1,7 @@
|
||||
import { DescribeTasksCommand, RunTaskCommand, waitUntilTasksRunning } from '@aws-sdk/client-ecs';
|
||||
import { DescribeStreamCommand, GetRecordsCommand, GetShardIteratorCommand } from '@aws-sdk/client-kinesis';
|
||||
import OrchestratorEnvironmentVariable from '../../options/orchestrator-environment-variable';
|
||||
import OrchestratorSecret from '../../options/orchestrator-secret';
|
||||
import * as core from '@actions/core';
|
||||
import OrchestratorAWSTaskDef from './orchestrator-aws-task-def';
|
||||
import * as zlib from 'node:zlib';
|
||||
@@ -56,6 +57,7 @@ class AWSTaskRunner {
|
||||
static async runTask(
|
||||
taskDef: OrchestratorAWSTaskDef,
|
||||
environment: OrchestratorEnvironmentVariable[],
|
||||
secrets: OrchestratorSecret[],
|
||||
commands: string,
|
||||
): Promise<{ output: string; shouldCleanup: boolean }> {
|
||||
const cluster = taskDef.baseResources?.find((x) => x.LogicalResourceId === 'ECSCluster')?.PhysicalResourceId || '';
|
||||
@@ -73,6 +75,12 @@ class AWSTaskRunner {
|
||||
// Transform localhost endpoints for container environment
|
||||
const transformedEnvironment = AWSTaskRunner.transformEndpointsForContainer(environment);
|
||||
|
||||
// Merge secrets into environment as plain env vars, matching docker and k8s provider behavior.
|
||||
// This ensures UNITY_EMAIL, UNITY_PASSWORD, UNITY_SERIAL reach the container reliably
|
||||
// without depending on CloudFormation Secrets Manager resolution.
|
||||
const secretsAsEnvironment = secrets.map((s) => ({ name: s.EnvironmentVariable, value: s.ParameterValue }));
|
||||
const mergedEnvironment = [...transformedEnvironment, ...secretsAsEnvironment];
|
||||
|
||||
const runParameters = {
|
||||
cluster,
|
||||
taskDefinition,
|
||||
@@ -81,7 +89,7 @@ class AWSTaskRunner {
|
||||
containerOverrides: [
|
||||
{
|
||||
name: taskDef.taskDefStackName,
|
||||
environment: transformedEnvironment,
|
||||
environment: mergedEnvironment,
|
||||
command: ['-c', CommandHookService.ApplyHooksToCommands(commands, Orchestrator.buildParameters)],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -125,7 +125,7 @@ class AWSBuildEnvironment implements ProviderInterface {
|
||||
try {
|
||||
const postSetupStacksTimeMs = Date.now();
|
||||
OrchestratorLogger.log(`Setup job time: ${Math.floor((postSetupStacksTimeMs - startTimeMs) / 1000)}s`);
|
||||
const { output, shouldCleanup } = await AwsTaskRunner.runTask(taskDef, environment, commands);
|
||||
const { output, shouldCleanup } = await AwsTaskRunner.runTask(taskDef, environment, secrets, commands);
|
||||
postRunTaskTimeMs = Date.now();
|
||||
OrchestratorLogger.log(`Run job time: ${Math.floor((postRunTaskTimeMs - postSetupStacksTimeMs) / 1000)}s`);
|
||||
if (shouldCleanup) {
|
||||
|
||||
Reference in New Issue
Block a user