Skip to content

Commit 138e006

Browse files
johncblandiiaknysh
authored andcommitted
DEVOPS-232: Add aws:elasticbeanstalk:cloudwatch:logs support (#59)
* Add aws:elasticbeanstalk:cloudwatch:logs support * Add support for Xray debugging * Update README and lint * Remove Xray for now This needs more consideration.
1 parent 085ec05 commit 138e006

File tree

4 files changed

+66
-15
lines changed

4 files changed

+66
-15
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ Available targets:
6969
| config_source | S3 source for config | string | `` | no |
7070
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no |
7171
| description | Short description of the Environment | string | `` | no |
72+
| 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 |
7273
| enable_managed_actions | Enable managed platform updates. When you set this to true, you must also specify a `PreferredStartTime` and `UpdateLevel` | string | `true` | no |
74+
| 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 |
7375
| env_default_key | Default ENV variable key for Elastic Beanstalk `aws:elasticbeanstalk:application:environment` setting | string | `DEFAULT_ENV_%d` | no |
7476
| env_default_value | Default ENV variable value for Elastic Beanstalk `aws:elasticbeanstalk:application:environment` setting | string | `UNSET` | no |
7577
| 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 | `<map>` | no |
@@ -86,6 +88,8 @@ Available targets:
8688
| loadbalancer_managed_security_group | Load balancer managed security group | string | `` | no |
8789
| loadbalancer_security_groups | Load balancer security groups | list | `<list>` | no |
8890
| loadbalancer_type | Load Balancer type, e.g. 'application' or 'classic' | string | `classic` | no |
91+
| 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 |
92+
| logs_retention_in_days | The number of days to keep log events before they expire. | string | `7` | no |
8993
| name | Solution name, e.g. 'app' or 'jenkins' | string | `app` | no |
9094
| namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | string | - | yes |
9195
| nodejs_version | Elastic Beanstalk NodeJS version to deploy | string | `` | no |

docs/terraform.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
| config_source | S3 source for config | string | `` | no |
2222
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no |
2323
| description | Short description of the Environment | string | `` | no |
24+
| 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 |
2425
| enable_managed_actions | Enable managed platform updates. When you set this to true, you must also specify a `PreferredStartTime` and `UpdateLevel` | string | `true` | no |
26+
| 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 |
2527
| env_default_key | Default ENV variable key for Elastic Beanstalk `aws:elasticbeanstalk:application:environment` setting | string | `DEFAULT_ENV_%d` | no |
2628
| env_default_value | Default ENV variable value for Elastic Beanstalk `aws:elasticbeanstalk:application:environment` setting | string | `UNSET` | no |
2729
| 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 | `<map>` | no |
@@ -38,6 +40,8 @@
3840
| loadbalancer_managed_security_group | Load balancer managed security group | string | `` | no |
3941
| loadbalancer_security_groups | Load balancer security groups | list | `<list>` | no |
4042
| loadbalancer_type | Load Balancer type, e.g. 'application' or 'classic' | string | `classic` | no |
43+
| 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 |
44+
| logs_retention_in_days | The number of days to keep log events before they expire. | string | `7` | no |
4145
| name | Solution name, e.g. 'app' or 'jenkins' | string | `app` | no |
4246
| namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | string | - | yes |
4347
| nodejs_version | Elastic Beanstalk NodeJS version to deploy | string | `` | no |

main.tf

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,44 @@ resource "aws_elastic_beanstalk_environment" "default" {
399399
value = "${var.updating_max_batch}"
400400
}
401401

402+
###=========================== Logging ========================== ###
403+
404+
setting {
405+
namespace = "aws:elasticbeanstalk:hostmanager"
406+
name = "LogPublicationControl"
407+
value = "${var.enable_log_publication_control ? "true" : "false"}"
408+
}
409+
setting {
410+
namespace = "aws:elasticbeanstalk:cloudwatch:logs"
411+
name = "StreamLogs"
412+
value = "${var.enable_stream_logs ? "true" : "false"}"
413+
}
414+
setting {
415+
namespace = "aws:elasticbeanstalk:cloudwatch:logs"
416+
name = "DeleteOnTerminate"
417+
value = "${var.logs_delete_on_terminate ? "true" : "false"}"
418+
}
419+
setting {
420+
namespace = "aws:elasticbeanstalk:cloudwatch:logs"
421+
name = "RetentionInDays"
422+
value = "${var.logs_retention_in_days}"
423+
}
424+
setting {
425+
namespace = "aws:elasticbeanstalk:cloudwatch:logs:health"
426+
name = "HealthStreamingEnabled"
427+
value = "${var.health_streaming_enabled ? "true" : "false"}"
428+
}
429+
setting {
430+
namespace = "aws:elasticbeanstalk:cloudwatch:logs:health"
431+
name = "DeleteOnTerminate"
432+
value = "${var.health_streaming_delete_on_terminate ? "true" : "false"}"
433+
}
434+
setting {
435+
namespace = "aws:elasticbeanstalk:cloudwatch:logs:health"
436+
name = "RetentionInDays"
437+
value = "${var.health_streaming_retention_in_days}"
438+
}
439+
402440
###=========================== Autoscale trigger ========================== ###
403441

404442
setting {
@@ -604,21 +642,6 @@ resource "aws_elastic_beanstalk_environment" "default" {
604642
name = "SSLCertificateArns"
605643
value = "${var.loadbalancer_certificate_arn}"
606644
}
607-
setting {
608-
namespace = "aws:elasticbeanstalk:cloudwatch:logs:health"
609-
name = "HealthStreamingEnabled"
610-
value = "${var.health_streaming_enabled ? "true" : "false"}"
611-
}
612-
setting {
613-
namespace = "aws:elasticbeanstalk:cloudwatch:logs:health"
614-
name = "DeleteOnTerminate"
615-
value = "${var.health_streaming_delete_on_terminate ? "true" : "false"}"
616-
}
617-
setting {
618-
namespace = "aws:elasticbeanstalk:cloudwatch:logs:health"
619-
name = "RetentionInDays"
620-
value = "${var.health_streaming_retention_in_days}"
621-
}
622645
setting {
623646
namespace = "aws:elasticbeanstalk:healthreporting:system"
624647
name = "ConfigDocument"

variables.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,26 @@ variable "notification_topic_name" {
7575
description = "Notification topic name"
7676
}
7777

78+
variable "enable_log_publication_control" {
79+
default = false
80+
description = "Copy the log files for your application's Amazon EC2 instances to the Amazon S3 bucket associated with your application."
81+
}
82+
83+
variable "enable_stream_logs" {
84+
default = false
85+
description = "Whether to create groups in CloudWatch Logs for proxy and deployment logs, and stream logs from each instance in your environment."
86+
}
87+
88+
variable "logs_delete_on_terminate" {
89+
default = false
90+
description = "Whether to delete the log groups when the environment is terminated. If false, the logs are kept RetentionInDays days."
91+
}
92+
93+
variable "logs_retention_in_days" {
94+
default = "7"
95+
description = "The number of days to keep log events before they expire."
96+
}
97+
7898
variable "loadbalancer_type" {
7999
default = "classic"
80100
description = "Load Balancer type, e.g. 'application' or 'classic'"

0 commit comments

Comments
 (0)