fix(terraform): AWS changes compliance
[csit.git] / fdio.infra.terraform / terraform-aws-fdio-csit-dash-env / main.tf
1 data "vault_generic_secret" "fdio_docs" {
2   path = "kv/secret/data/etl/fdio_docs"
3 }
4
5 data "vault_aws_access_credentials" "creds" {
6   backend = "${var.vault_name}-path"
7   role    = "${var.vault_name}-role"
8 }
9
10 module "elastic_beanstalk_application" {
11   source = "../terraform-aws-elastic-beanstalk-application"
12
13   # application
14   application_description                    = "FD.io CDASH"
15   application_name                           = "fdio-csit-dash-app"
16   appversion_lifecycle_service_role_arn      = ""
17   appversion_lifecycle_max_count             = 2
18   appversion_lifecycle_delete_source_from_s3 = false
19 }
20
21 module "elastic_beanstalk_environment" {
22   source = "../terraform-aws-elastic-beanstalk-environment"
23
24   # vpc
25   vpc_cidr_block           = "192.168.0.0/24"
26   vpc_enable_dns_hostnames = true
27   vpc_enable_dns_support   = true
28   vpc_instance_tenancy     = "default"
29
30   # subnet
31   subnet_availability_zone = "eu-central-1a"
32
33   # environment
34   environment_application            = module.elastic_beanstalk_application.application_name
35   environment_description            = module.elastic_beanstalk_application.application_description
36   environment_name                   = "fdio-csit-dash-env"
37   environment_solution_stack_name    = "64bit Amazon Linux 2 v3.4.2 running Python 3.8"
38   environment_tier                   = "WebServer"
39   environment_wait_for_ready_timeout = "25m"
40   environment_version_label          = ""
41
42   # aws:ec2:instances
43   instances_instance_types = "t3a.large"
44
45   # aws:ec2:vpc
46   associate_public_ip_address = true
47   elb_scheme                  = "public"
48
49   # aws:elbv2:listener:default
50   default_listener_enabled = true
51
52   # aws:elasticbeanstalk:environment
53   environment_loadbalancer_type = "network"
54
55   # aws:elasticbeanstalk:environment:process:default
56   environment_process_default_healthcheck_interval      = 10
57   environment_process_default_healthy_threshold_count   = 3
58   environment_process_default_port                      = 5000
59   environment_process_default_unhealthy_threshold_count = 3
60
61   # aws:autoscaling:updatepolicy:rollingupdate
62   autoscaling_updatepolicy_rolling_update_enabled  = true
63   autoscaling_updatepolicy_rolling_update_type     = "Immutable"
64   autoscaling_updatepolicy_min_instance_in_service = 1
65
66   # aws:elasticbeanstalk:command
67   command_deployment_policy = "Rolling"
68
69   # aws:autoscaling:updatepolicy:rollingupdate
70   updatepolicy_max_batch_size = 1
71
72   # aws:elasticbeanstalk:healthreporting:system
73   healthreporting_system_type = "enhanced"
74
75   # aws:elasticbeanstalk:managedactions
76   managedactions_managed_actions_enabled = true
77   managedactions_preferred_start_time    = "Sun:10:00"
78
79   # aws:elasticbeanstalk:managedactions:platformupdate
80   managedactions_platformupdate_update_level             = "minor"
81   managedactions_platformupdate_instance_refresh_enabled = true
82
83   # aws:autoscaling:asg
84   autoscaling_asg_minsize = 1
85   autoscaling_asg_maxsize = 2
86
87   # aws:autoscaling:trigger
88   autoscaling_trigger_measure_name                 = "CPUUtilization"
89   autoscaling_trigger_statistic                    = "Average"
90   autoscaling_trigger_unit                         = "Percent"
91   autoscaling_trigger_lower_threshold              = 20
92   autoscaling_trigger_lower_breach_scale_increment = -1
93   autoscaling_trigger_upper_threshold              = 80
94   autoscaling_trigger_upper_breach_scale_increment = 1
95
96   # aws:elasticbeanstalk:hostmanager
97   hostmanager_log_publication_control = true
98
99   # aws:elasticbeanstalk:cloudwatch:logs
100   cloudwatch_logs_stream_logs         = true
101   cloudwatch_logs_delete_on_terminate = true
102   cloudwatch_logs_retention_in_days   = 3
103
104   # aws:elasticbeanstalk:cloudwatch:logs:health
105   cloudwatch_logs_health_health_streaming_enabled = true
106   cloudwatch_logs_health_delete_on_terminate      = true
107   cloudwatch_logs_health_retention_in_days        = 3
108
109   environment_type = "LoadBalanced"
110
111   # aws:elasticbeanstalk:application:environment
112   environment_variables = {
113     "AWS_ACCESS_KEY_ID"     = data.vault_generic_secret.fdio_docs.data["access_key"]
114     "AWS_SECRET_ACCESS_KEY" = data.vault_generic_secret.fdio_docs.data["secret_key"]
115     "AWS_DEFAULT_REGION"    = data.vault_generic_secret.fdio_docs.data["region"]
116   }
117 }