【问题标题】:Configure Different Web.config for local and AWS elastic beanstalk为本地和 AWS 弹性 beanstalk 配置不同的 Web.config
【发布时间】:2019-01-25 11:47:15
【问题描述】:

我正在使用 AWS 来设置一个 Elastic Beanstalk,我将在其中运行一个 .Net (Umbraco CMS) 应用程序。我面临的问题是,该应用程序在 Web.config 上有秘密和连接字符串。另外,现在,该配置已添加到 repo 中,该 repo 被推送到 codeCommit,如果一切正常,我想设置管道以将我的推送部署到 beanstalk。

所以,我想知道创建单独文件的最佳方式,这样当我推送本地更改时,我不会覆盖 aws 上的 web.config。

我想到了一些解决方案,但我不知道如何执行它们:

1) 设置环境变量并以某种方式转换 web.config 值。

2)在服务器中创建单独的文件(不知道如何),并忽略本地web.config。我不知道这是否是一个好的解决方案。

3) 创建一些构建过程来转换 web.config。

可能有更好的方法。请帮忙!

【问题讨论】:

    标签: asp.net amazon-web-services web-config umbraco amazon-elastic-beanstalk


    【解决方案1】:

    执行此操作的一个好方法是通过锁定的 S3 存储桶。 Here is an example 来自 Elastic Beanstalk 文档。您将创建一个 .ebextensions 配置文件来告诉 EB 在部署时检索您的机密。

    例子:

    Resources:
      AWSEBAutoScalingGroup:
        Metadata:
          AWS::CloudFormation::Authentication:
            S3Auth:
              type: "s3"
              buckets: ["my-secret-bucket-123456789012"]
              roleName: "aws-elasticbeanstalk-ec2-role"
    
    files:
      "/tmp/beanstalk-database.json" :
        mode: "000644"
        owner: root
        group: root
        authentication: "S3Auth"
        source: https://s3-us-west-2.amazonaws.com/my-secret-bucket-123456789012/beanstalk-database.json
    

    有多种语言的指南描述了如何在 EB 中构建数据库连接,including .NET

    【讨论】:

      猜你喜欢
      • 2020-08-08
      • 2014-12-17
      • 2019-07-05
      • 1970-01-01
      • 2016-08-31
      • 2015-10-16
      • 1970-01-01
      • 2018-02-09
      • 2021-06-15
      相关资源
      最近更新 更多