Skip to content

Commit

Permalink
DEVOPS-232: Add aws:elasticbeanstalk:cloudwatch:logs support (#59)
Browse files Browse the repository at this point in the history
* Add aws:elasticbeanstalk:cloudwatch:logs support

* Add support for Xray debugging

* Update README and lint

* Remove Xray for now

This needs more consideration.
  • Loading branch information
johncblandii authored and aknysh committed Nov 1, 2018
1 parent 085ec05 commit 138e006
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 15 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | `<map>` | no |
Expand All @@ -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 | `<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 |
Expand Down
4 changes: 4 additions & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | `<map>` | no |
Expand All @@ -38,6 +40,8 @@
| loadbalancer_managed_security_group | Load balancer managed security group | string | `` | no |
| loadbalancer_security_groups | Load balancer security groups | list | `<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 |
Expand Down
53 changes: 38 additions & 15 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
Expand Down
20 changes: 20 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down

0 comments on commit 138e006

Please sign in to comment.