Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Using AWS Parameter Store #10441


User avatar
0
maharatha created

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version? - 10.3
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .net core

If issue related with ABP Framework

  • What is ABP Framework version? Whatever comes with 10.3

    I am trying to use AWS Parameter store as an alternative to store my appsettings. Below is the change I made in Program.cs :

  return new WebHostBuilder()
                .UseKestrel(opt =>
                {
                    opt.AddServerHeader = false;
                    opt.Limits.MaxRequestLineSize = 16 * 1024;
                })
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIIS()
                .UseIISIntegration()
                .ConfigureAppConfiguration(builder =>
                {
                    builder.AddJsonFile("appsettings.json");
                    builder.AddEnvironmentVariables();

                    var environmentName = (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development").ToLower();
                    var platformName = "capspayone";                
                    var awsParameterProcessor = new AWSParameterProcessor();

                    builder.AddSystemsManager((source) =>
                    {
                        source.Path = $"/cnc/{platformName}/{environmentName}";
                        //source.AwsOptions = awsOptions;
                        source.ParameterProcessor = awsParameterProcessor;
                    });
                    
                })
                .UseStartup<Startup>();
        }

public class AWSParameterProcessor : IParameterProcessor
    {
        public virtual bool IncludeParameter(Parameter parameter, string path) => true;

        public virtual string GetKey(Parameter parameter, string path)
        {
            var res = parameter.Name.Substring(path.Length).TrimStart('/').Replace("--", ConfigurationPath.KeyDelimiter);
            return res;
        }

        public virtual string GetValue(Parameter parameter, string path) => parameter.Value;
    }

I am unable to get the settings from AWS. Am I doing anything wrong ?

Also I tried[https://aws.amazon.com/blogs/developer/net-core-configuration-provider-for-aws-systems-manager/]

Please help.


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @maharatha

    Could you try this with an empty ASP.NET Core project and see if it works ?