diff --git a/README.md b/README.md index 5763cde7..e8a6f616 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,9 @@ Available targets: | config_source | S3 source for config | string | `` | no | | delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no | | description | Short description of the Environment | string | `` | no | +| enable_log_publication_control | Copy the log files for your application's Amazon EC2 instances to the Amazon S3 bucket associated with your application. | string | `false` | no | | enable_managed_actions | Enable managed platform updates. When you set this to true, you must also specify a `PreferredStartTime` and `UpdateLevel` | string | `true` | no | +| enable_stream_logs | Whether to create groups in CloudWatch Logs for proxy and deployment logs, and stream logs from each instance in your environment. | string | `false` | no | | env_default_key | Default ENV variable key for Elastic Beanstalk `aws:elasticbeanstalk:application:environment` setting | string | `DEFAULT_ENV_%d` | no | | env_default_value | Default ENV variable value for Elastic Beanstalk `aws:elasticbeanstalk:application:environment` setting | string | `UNSET` | no | | env_vars | Map of custom ENV variables to be provided to the Jenkins application running on Elastic Beanstalk, e.g. `env_vars = { JENKINS_USER = 'admin' JENKINS_PASS = 'xxxxxx' }` | map | `` | no | @@ -86,6 +88,8 @@ Available targets: | loadbalancer_managed_security_group | Load balancer managed security group | string | `` | no | | loadbalancer_security_groups | Load balancer security groups | list | `` | no | | loadbalancer_type | Load Balancer type, e.g. 'application' or 'classic' | string | `classic` | no | +| logs_delete_on_terminate | Whether to delete the log groups when the environment is terminated. If false, the logs are kept RetentionInDays days. | string | `false` | no | +| logs_retention_in_days | The number of days to keep log events before they expire. | string | `7` | no | | name | Solution name, e.g. 'app' or 'jenkins' | string | `app` | no | | namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | string | - | yes | | nodejs_version | Elastic Beanstalk NodeJS version to deploy | string | `` | no | diff --git a/docs/terraform.md b/docs/terraform.md index fc21169d..b3c3a4ba 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -21,7 +21,9 @@ | config_source | S3 source for config | string | `` | no | | delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no | | description | Short description of the Environment | string | `` | no | +| enable_log_publication_control | Copy the log files for your application's Amazon EC2 instances to the Amazon S3 bucket associated with your application. | string | `false` | no | | enable_managed_actions | Enable managed platform updates. When you set this to true, you must also specify a `PreferredStartTime` and `UpdateLevel` | string | `true` | no | +| enable_stream_logs | Whether to create groups in CloudWatch Logs for proxy and deployment logs, and stream logs from each instance in your environment. | string | `false` | no | | env_default_key | Default ENV variable key for Elastic Beanstalk `aws:elasticbeanstalk:application:environment` setting | string | `DEFAULT_ENV_%d` | no | | env_default_value | Default ENV variable value for Elastic Beanstalk `aws:elasticbeanstalk:application:environment` setting | string | `UNSET` | no | | env_vars | Map of custom ENV variables to be provided to the Jenkins application running on Elastic Beanstalk, e.g. `env_vars = { JENKINS_USER = 'admin' JENKINS_PASS = 'xxxxxx' }` | map | `` | no | @@ -38,6 +40,8 @@ | loadbalancer_managed_security_group | Load balancer managed security group | string | `` | no | | loadbalancer_security_groups | Load balancer security groups | list | `` | no | | loadbalancer_type | Load Balancer type, e.g. 'application' or 'classic' | string | `classic` | no | +| logs_delete_on_terminate | Whether to delete the log groups when the environment is terminated. If false, the logs are kept RetentionInDays days. | string | `false` | no | +| logs_retention_in_days | The number of days to keep log events before they expire. | string | `7` | no | | name | Solution name, e.g. 'app' or 'jenkins' | string | `app` | no | | namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | string | - | yes | | nodejs_version | Elastic Beanstalk NodeJS version to deploy | string | `` | no | diff --git a/main.tf b/main.tf index e5b37352..b85d07e4 100644 --- a/main.tf +++ b/main.tf @@ -399,6 +399,44 @@ resource "aws_elastic_beanstalk_environment" "default" { value = "${var.updating_max_batch}" } + ###=========================== Logging ========================== ### + + setting { + namespace = "aws:elasticbeanstalk:hostmanager" + name = "LogPublicationControl" + value = "${var.enable_log_publication_control ? "true" : "false"}" + } + setting { + namespace = "aws:elasticbeanstalk:cloudwatch:logs" + name = "StreamLogs" + value = "${var.enable_stream_logs ? "true" : "false"}" + } + setting { + namespace = "aws:elasticbeanstalk:cloudwatch:logs" + name = "DeleteOnTerminate" + value = "${var.logs_delete_on_terminate ? "true" : "false"}" + } + setting { + namespace = "aws:elasticbeanstalk:cloudwatch:logs" + name = "RetentionInDays" + value = "${var.logs_retention_in_days}" + } + setting { + namespace = "aws:elasticbeanstalk:cloudwatch:logs:health" + name = "HealthStreamingEnabled" + value = "${var.health_streaming_enabled ? "true" : "false"}" + } + setting { + namespace = "aws:elasticbeanstalk:cloudwatch:logs:health" + name = "DeleteOnTerminate" + value = "${var.health_streaming_delete_on_terminate ? "true" : "false"}" + } + setting { + namespace = "aws:elasticbeanstalk:cloudwatch:logs:health" + name = "RetentionInDays" + value = "${var.health_streaming_retention_in_days}" + } + ###=========================== Autoscale trigger ========================== ### setting { @@ -604,21 +642,6 @@ resource "aws_elastic_beanstalk_environment" "default" { name = "SSLCertificateArns" value = "${var.loadbalancer_certificate_arn}" } - setting { - namespace = "aws:elasticbeanstalk:cloudwatch:logs:health" - name = "HealthStreamingEnabled" - value = "${var.health_streaming_enabled ? "true" : "false"}" - } - setting { - namespace = "aws:elasticbeanstalk:cloudwatch:logs:health" - name = "DeleteOnTerminate" - value = "${var.health_streaming_delete_on_terminate ? "true" : "false"}" - } - setting { - namespace = "aws:elasticbeanstalk:cloudwatch:logs:health" - name = "RetentionInDays" - value = "${var.health_streaming_retention_in_days}" - } setting { namespace = "aws:elasticbeanstalk:healthreporting:system" name = "ConfigDocument" diff --git a/variables.tf b/variables.tf index 741fa035..3018ffe1 100644 --- a/variables.tf +++ b/variables.tf @@ -75,6 +75,26 @@ variable "notification_topic_name" { description = "Notification topic name" } +variable "enable_log_publication_control" { + default = false + description = "Copy the log files for your application's Amazon EC2 instances to the Amazon S3 bucket associated with your application." +} + +variable "enable_stream_logs" { + default = false + description = "Whether to create groups in CloudWatch Logs for proxy and deployment logs, and stream logs from each instance in your environment." +} + +variable "logs_delete_on_terminate" { + default = false + description = "Whether to delete the log groups when the environment is terminated. If false, the logs are kept RetentionInDays days." +} + +variable "logs_retention_in_days" { + default = "7" + description = "The number of days to keep log events before they expire." +} + variable "loadbalancer_type" { default = "classic" description = "Load Balancer type, e.g. 'application' or 'classic'"