简体   繁体   中英

Enable CloudWatch logs for Beanstalk env from Terraform

I am creating a new AWS Beanstalk environment with Terrraform.

AWS Console gives you the ability to turn on CloudWatch logs streaming for Beanstalk environments in the config (see image below), however looking at the provider I cannot find terraform currently allowing to do that.

I find this feature quite useful, has anyone stumbled upon this before?

在此处输入图像描述

I believe you would just create your own cloudwatch log streams via the provider for cloudwatch.

This feature could just be using the cloudwatch API in order to create these, but present the option in the Elastic beanstalk interface for ease of use.

You need to use option settings for Elastic Beanstalk [1]:

resource "aws_elastic_beanstalk_environment" "some_env" {
  name                = "some-env-name"
  application         = aws_elastic_beanstalk_application.app.name
  solution_stack_name = "64bit Amazon Linux 2015.03 v2.0.3 running Go 1.4"

  setting {
    namespace = "aws:elasticbeanstalk:cloudwatch:logs"
    name      = "StreamLogs"
    value     = "true"
  }

  setting {
    namespace = "aws:elasticbeanstalk:cloudwatch:logs"
    name      = "RetentionInDays"
    value     = "7"
  }

  setting {
    namespace = "aws:elasticbeanstalk:cloudwatch:logs"
    name      = "DeleteOnTerminate"
    value     = "false"
  }

}

Note that I have given an example for the name , application and solution_stack_name as you have not provided any code in your question. Additionally, keep in mind that DeleteOnTerminate will keep the logs for the RetentionInDays .


[1] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-cloudwatchlogs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM