【问题标题】:Set Newrelic APP name from ELB env variable on deploy在部署时从 ELB env 变量设置 Newrelic APP 名称
【发布时间】:2018-09-23 01:27:12
【问题描述】:

我需要将相同的 PHP 代码部署到 AWS Elastic beanstalk 上的 3 个环境。这些环境将在 New relic 上向不同的应用程序名称报告。

newrelic 许可证密钥无法部署到存储库。

请就实现这一目标的策略提出建议。

【问题讨论】:

    标签: php apache amazon-ec2 amazon-elastic-beanstalk newrelic


    【解决方案1】:

    对于 AWS Elastic Beanstalk 中的 PHP,您的步骤如下:

    在 Elastic BeanStalk 应用程序内的 .ebextensions 文件夹中, 创建一个名为 newrelic.config 的新文件。将以下内容添加到 文件:

    packages:
      yum:
        newrelic-php5: []
      rpm:
        newrelic: INSERT_LINK_TO_AGENT
    commands:
      configure_new_relic:
        command: newrelic-install install
        env:
          NR_INSTALL_SILENT: true
          NR_INSTALL_KEY: INSERT_LICENSE_KEY
    

    发件人:https://docs.newrelic.com/docs/agents/php-agent/frameworks-libraries/aws-elastic-beanstalk-installation-php

    如果您使用密码保险库,那么您将遵循他们的最佳做法。如果不是,那么您可能需要创建一个 shell 脚本来替换安全 S3 存储桶中的许可证密钥。

    将您的许可证密钥放入安全的 S3 存储桶中。然后使用类似于以下内容的 Bash 脚本:

    #!/bin/bash
    password=$(aws ssm get-parameters --region us-east-1 --names MySecureLicenseKey --with-decryption --query Parameters[0].Value)
    # code to replace INSERT_LICENSE_KEY - need to update the path to where you have it land
    sed 's/INSERT_LICENSE_KEY/$password/g' /etc/newrelic/newrelic.config
    

    灵感来自:https://aws.amazon.com/blogs/mt/use-parameter-store-to-securely-access-secrets-and-config-data-in-aws-codedeploy/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-02
      • 1970-01-01
      • 2018-06-14
      • 2016-07-30
      • 2021-01-26
      • 2023-03-28
      • 2018-09-05
      • 2019-11-21
      相关资源
      最近更新 更多