public static IConfigurationBuilder AddAppConfigUsingLambdaExtension()

in src/Amazon.Extensions.Configuration.SystemsManager/AppConfig/AppConfigForLambdaExtensions.cs [99:127]


        public static IConfigurationBuilder AddAppConfigUsingLambdaExtension(this IConfigurationBuilder builder, AppConfigConfigurationSource source)
        {
            if (source == null) throw new ArgumentNullException(nameof(source));
            if (source.ApplicationId == null) throw new ArgumentNullException(nameof(source.ApplicationId));
            if (source.EnvironmentId == null) throw new ArgumentNullException(nameof(source.EnvironmentId));
            if (source.ConfigProfileId == null) throw new ArgumentNullException(nameof(source.ConfigProfileId));

            // Create a specific instance of AmazonAppConfigClient that is configured to make calls to the endpoint setup by the AppConfig Lambda layer.
            source.UseLambdaExtension = true;

            if(!source.ReloadAfter.HasValue)
            {
                // default polling duration is 45 seconds https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-integration-lambda-extensions.html
                var reloadAfter = 45;

                // Since the user is using Lambda extension which automatically refreshes the data default to the configuration provider defaulting
                // to reload at the rate the extension reloads plus 5 second buffer.
                var reloadAfterStr = Environment.GetEnvironmentVariable("AWS_APPCONFIG_EXTENSION_POLL_INTERVAL_SECONDS");
                if (reloadAfterStr != null && !int.TryParse(reloadAfterStr, out reloadAfter))
                {
                    throw new ArgumentException("Environment variable AWS_APPCONFIG_EXTENSION_POLL_INTERVAL_SECONDS used for computing ReloadAfter is not set to a valid integer");
                }

                reloadAfter += 5;
                source.ReloadAfter = TimeSpan.FromSeconds(reloadAfter);
            }

            return builder.Add(source);
        }