@@ -9,6 +9,10 @@ import (
99 "fmt"
1010 "io"
1111 "sync"
12+ "time"
13+
14+ "github.com/google/uuid"
15+ "github.com/aws/aws-lambda-runtime-interface-emulator/internal/lmds"
1216
1317 "github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/appctx"
1418 "github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/core"
@@ -52,7 +56,7 @@ type Sandbox struct {
5256//
5357// - Contexts & Data:
5458// - ctx is used to gracefully terminate Runtime API HTTP Server on exit
55- func Start (ctx context.Context , s * Sandbox ) (interop.RapidContext , interop.InternalStateGetter , string ) {
59+ func Start (ctx context.Context , s * Sandbox ) (interop.RapidContext , interop.InternalStateGetter , string , string ) {
5660 // Initialize internal state objects required by Rapid handlers
5761 appCtx := appctx .NewApplicationContext ()
5862 initFlow := core .NewInitFlowSynchronization ()
@@ -63,7 +67,18 @@ func Start(ctx context.Context, s *Sandbox) (interop.RapidContext, interop.Inter
6367
6468 appctx .StoreInitType (appCtx , s .InitCachingEnabled )
6569
66- server := rapi .NewServer (s .RuntimeAPIHost , s .RuntimeAPIPort , appCtx , registrationService , renderingService , s .EnableTelemetryAPI , s .LogsSubscriptionAPI , s .TelemetrySubscriptionAPI , credentialsService )
70+ // Create metadata service with hardcoded AZ ID for RIE
71+ metadataToken := uuid .NewString ()
72+ metadataService := lmds .NewService (metadataToken )
73+
74+ // Set hardcoded metadata for RIE (use1-az1 per design)
75+ metadataConfig := lmds.MetadataConfig {
76+ Data : []byte (`{"AvailabilityZoneID":"use1-az1"}` ),
77+ MaxAge : 12 * time .Hour ,
78+ }
79+ metadataService .UpdateMetadata (metadataConfig )
80+
81+ server := rapi .NewServer (s .RuntimeAPIHost , s .RuntimeAPIPort , appCtx , registrationService , renderingService , s .EnableTelemetryAPI , s .LogsSubscriptionAPI , s .TelemetrySubscriptionAPI , credentialsService , metadataService )
6782 runtimeAPIAddr := fmt .Sprintf ("%s:%d" , server .Host (), server .Port ())
6883
6984 // TODO: pass this directly down to HTTP servers and handlers, instead of using
@@ -105,7 +120,7 @@ func Start(ctx context.Context, s *Sandbox) (interop.RapidContext, interop.Inter
105120
106121 go startRuntimeAPI (ctx , execCtx )
107122
108- return execCtx , registrationService .GetInternalStateDescriptor (appCtx ), runtimeAPIAddr
123+ return execCtx , registrationService .GetInternalStateDescriptor (appCtx ), runtimeAPIAddr , metadataToken
109124}
110125
111126func (r * rapidContext ) HandleInit (init * interop.Init , initSuccessResponseChan chan <- interop.InitSuccess , initFailureResponseChan chan <- interop.InitFailure ) {
0 commit comments