private SSMParameter getParameter(string i_Name, bool i_TryFetchinFromSSM) { if (m_InvalidParameters.Contains(i_Name)) { throw new ArgumentException("Parameter name is invalid", i_Name); } SSMParameter resultParameter = null; if (m_Parameters.TryGetValue(i_Name, out resultParameter)) { if (resultParameter.LastFetched + MaxAge < DateTime.Now) { if (i_TryFetchinFromSSM) { getParametersFromSSM(m_Parameters.Keys); resultParameter = getParameter(i_Name, i_TryFetchinFromSSM: false); } else { resultParameter = getParameterFromEnvironment(i_Name); } } } else { resultParameter = getParameterFromEnvironment(i_Name); } return(resultParameter); }
private SSMParameter getParameterFromEnvironment(string i_Name) { SSMParameter resultParameter = null; string environmentVariableName = i_Name.Trim('/').Replace('/', '_'); if (!string.IsNullOrEmpty(environmentVariableName)) { string environmentVariableValue = Environment.GetEnvironmentVariable(environmentVariableName); if (!string.IsNullOrEmpty(environmentVariableValue)) { Parameter awsParameter = new Parameter { Name = i_Name, Value = environmentVariableValue, Type = ParameterType.String }; resultParameter = new SSMParameter(awsParameter); } } return(resultParameter); }