Skip to content

Commit e012092

Browse files
florian0410korenyonicloudpossebot
authored
Feat/add nlb (#182)
* Feat/add nlb compatibilty * Add example for NLB * Fix example, add scheduled actions Add suggestion using new security group Co-authored-by: Yonatan Koren <[email protected]> * Auto Format * Add configs to fixture Co-authored-by: Yonatan Koren <[email protected]> * syntax clean * Auto Format Co-authored-by: Yonatan Koren <[email protected]> Co-authored-by: cloudpossebot <[email protected]>
1 parent efd196b commit e012092

14 files changed

+818
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ Available targets:
361361
| <a name="input_scheduled_actions"></a> [scheduled\_actions](#input\_scheduled\_actions) | Define a list of scheduled actions | <pre>list(object({<br> name = string<br> minsize = string<br> maxsize = string<br> desiredcapacity = string<br> starttime = string<br> endtime = string<br> recurrence = string<br> suspend = bool<br> }))</pre> | `[]` | no |
362362
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | The Security Group description. | `string` | `"Elastic Beanstalk environment Security Group"` | no |
363363
| <a name="input_security_group_enabled"></a> [security\_group\_enabled](#input\_security\_group\_enabled) | Whether to create Security Group. | `bool` | `true` | no |
364-
| <a name="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules) | A list of maps of Security Group rules. <br>The values of map is fully complated with `aws_security_group_rule` resource. <br>To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule . | `list(any)` | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "description": "Allow all outbound traffic",<br> "from_port": 0,<br> "protocol": "-1",<br> "to_port": 65535,<br> "type": "egress"<br> }<br>]</pre> | no |
364+
| <a name="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules) | A list of maps of Security Group rules.<br>The values of map is fully complated with `aws_security_group_rule` resource.<br>To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule . | `list(any)` | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "description": "Allow all outbound traffic",<br> "from_port": 0,<br> "protocol": "-1",<br> "to_port": 65535,<br> "type": "egress"<br> }<br>]</pre> | no |
365365
| <a name="input_security_group_use_name_prefix"></a> [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Whether to create a default Security Group with unique name beginning with the normalized prefix. | `bool` | `false` | no |
366366
| <a name="input_security_groups"></a> [security\_groups](#input\_security\_groups) | A list of Security Group IDs to associate with EC2 instances. | `list(string)` | `[]` | no |
367367
| <a name="input_solution_stack_name"></a> [solution\_stack\_name](#input\_solution\_stack\_name) | Elastic Beanstalk stack, e.g. Docker, Go, Node, Java, IIS. For more info, see https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html | `string` | n/a | yes |

README.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,4 @@ contributors:
207207
- name: "Chris Green"
208208
github: "DirectRoot"
209209
- name: "Vladimir Syromyatnikov"
210-
github: "SweetOps"
210+
github: "SweetOps"

docs/terraform.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
| <a name="input_scheduled_actions"></a> [scheduled\_actions](#input\_scheduled\_actions) | Define a list of scheduled actions | <pre>list(object({<br> name = string<br> minsize = string<br> maxsize = string<br> desiredcapacity = string<br> starttime = string<br> endtime = string<br> recurrence = string<br> suspend = bool<br> }))</pre> | `[]` | no |
129129
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | The Security Group description. | `string` | `"Elastic Beanstalk environment Security Group"` | no |
130130
| <a name="input_security_group_enabled"></a> [security\_group\_enabled](#input\_security\_group\_enabled) | Whether to create Security Group. | `bool` | `true` | no |
131-
| <a name="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules) | A list of maps of Security Group rules. <br>The values of map is fully complated with `aws_security_group_rule` resource. <br>To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule . | `list(any)` | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "description": "Allow all outbound traffic",<br> "from_port": 0,<br> "protocol": "-1",<br> "to_port": 65535,<br> "type": "egress"<br> }<br>]</pre> | no |
131+
| <a name="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules) | A list of maps of Security Group rules.<br>The values of map is fully complated with `aws_security_group_rule` resource.<br>To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule . | `list(any)` | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "description": "Allow all outbound traffic",<br> "from_port": 0,<br> "protocol": "-1",<br> "to_port": 65535,<br> "type": "egress"<br> }<br>]</pre> | no |
132132
| <a name="input_security_group_use_name_prefix"></a> [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Whether to create a default Security Group with unique name beginning with the normalized prefix. | `bool` | `false` | no |
133133
| <a name="input_security_groups"></a> [security\_groups](#input\_security\_groups) | A list of Security Group IDs to associate with EC2 instances. | `list(string)` | `[]` | no |
134134
| <a name="input_solution_stack_name"></a> [solution\_stack\_name](#input\_solution\_stack\_name) | Elastic Beanstalk stack, e.g. Docker, Go, Node, Java, IIS. For more info, see https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html | `string` | n/a | yes |

examples/nlb/context.tf

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
#
2+
# ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label
3+
# All other instances of this file should be a copy of that one
4+
#
5+
#
6+
# Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf
7+
# and then place it in your Terraform module to automatically get
8+
# Cloud Posse's standard configuration inputs suitable for passing
9+
# to Cloud Posse modules.
10+
#
11+
# Modules should access the whole context as `module.this.context`
12+
# to get the input variables with nulls for defaults,
13+
# for example `context = module.this.context`,
14+
# and access individual variables as `module.this.<var>`,
15+
# with final values filled in.
16+
#
17+
# For example, when using defaults, `module.this.context.delimiter`
18+
# will be null, and `module.this.delimiter` will be `-` (hyphen).
19+
#
20+
21+
module "this" {
22+
source = "cloudposse/label/null"
23+
version = "0.24.1" # requires Terraform >= 0.13.0
24+
25+
enabled = var.enabled
26+
namespace = var.namespace
27+
environment = var.environment
28+
stage = var.stage
29+
name = var.name
30+
delimiter = var.delimiter
31+
attributes = var.attributes
32+
tags = var.tags
33+
additional_tag_map = var.additional_tag_map
34+
label_order = var.label_order
35+
regex_replace_chars = var.regex_replace_chars
36+
id_length_limit = var.id_length_limit
37+
label_key_case = var.label_key_case
38+
label_value_case = var.label_value_case
39+
40+
context = var.context
41+
}
42+
43+
# Copy contents of cloudposse/terraform-null-label/variables.tf here
44+
45+
variable "context" {
46+
type = any
47+
default = {
48+
enabled = true
49+
namespace = null
50+
environment = null
51+
stage = null
52+
name = null
53+
delimiter = null
54+
attributes = []
55+
tags = {}
56+
additional_tag_map = {}
57+
regex_replace_chars = null
58+
label_order = []
59+
id_length_limit = null
60+
label_key_case = null
61+
label_value_case = null
62+
}
63+
description = <<-EOT
64+
Single object for setting entire context at once.
65+
See description of individual variables for details.
66+
Leave string and numeric variables as `null` to use default value.
67+
Individual variable settings (non-null) override settings in context object,
68+
except for attributes, tags, and additional_tag_map, which are merged.
69+
EOT
70+
71+
validation {
72+
condition = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"])
73+
error_message = "Allowed values: `lower`, `title`, `upper`."
74+
}
75+
76+
validation {
77+
condition = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"])
78+
error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
79+
}
80+
}
81+
82+
variable "enabled" {
83+
type = bool
84+
default = null
85+
description = "Set to false to prevent the module from creating any resources"
86+
}
87+
88+
variable "namespace" {
89+
type = string
90+
default = null
91+
description = "Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'"
92+
}
93+
94+
variable "environment" {
95+
type = string
96+
default = null
97+
description = "Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT'"
98+
}
99+
100+
variable "stage" {
101+
type = string
102+
default = null
103+
description = "Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release'"
104+
}
105+
106+
variable "name" {
107+
type = string
108+
default = null
109+
description = "Solution name, e.g. 'app' or 'jenkins'"
110+
}
111+
112+
variable "delimiter" {
113+
type = string
114+
default = null
115+
description = <<-EOT
116+
Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.
117+
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all.
118+
EOT
119+
}
120+
121+
variable "attributes" {
122+
type = list(string)
123+
default = []
124+
description = "Additional attributes (e.g. `1`)"
125+
}
126+
127+
variable "tags" {
128+
type = map(string)
129+
default = {}
130+
description = "Additional tags (e.g. `map('BusinessUnit','XYZ')`"
131+
}
132+
133+
variable "additional_tag_map" {
134+
type = map(string)
135+
default = {}
136+
description = "Additional tags for appending to tags_as_list_of_maps. Not added to `tags`."
137+
}
138+
139+
variable "label_order" {
140+
type = list(string)
141+
default = null
142+
description = <<-EOT
143+
The naming order of the id output and Name tag.
144+
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
145+
You can omit any of the 5 elements, but at least one must be present.
146+
EOT
147+
}
148+
149+
variable "regex_replace_chars" {
150+
type = string
151+
default = null
152+
description = <<-EOT
153+
Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
154+
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits.
155+
EOT
156+
}
157+
158+
variable "id_length_limit" {
159+
type = number
160+
default = null
161+
description = <<-EOT
162+
Limit `id` to this many characters (minimum 6).
163+
Set to `0` for unlimited length.
164+
Set to `null` for default, which is `0`.
165+
Does not affect `id_full`.
166+
EOT
167+
validation {
168+
condition = var.id_length_limit == null ? true : var.id_length_limit >= 6 || var.id_length_limit == 0
169+
error_message = "The id_length_limit must be >= 6 if supplied (not null), or 0 for unlimited length."
170+
}
171+
}
172+
173+
variable "label_key_case" {
174+
type = string
175+
default = null
176+
description = <<-EOT
177+
The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.
178+
Possible values: `lower`, `title`, `upper`.
179+
Default value: `title`.
180+
EOT
181+
182+
validation {
183+
condition = var.label_key_case == null ? true : contains(["lower", "title", "upper"], var.label_key_case)
184+
error_message = "Allowed values: `lower`, `title`, `upper`."
185+
}
186+
}
187+
188+
variable "label_value_case" {
189+
type = string
190+
default = null
191+
description = <<-EOT
192+
The letter case of output label values (also used in `tags` and `id`).
193+
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
194+
Default value: `lower`.
195+
EOT
196+
197+
validation {
198+
condition = var.label_value_case == null ? true : contains(["lower", "title", "upper", "none"], var.label_value_case)
199+
error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
200+
}
201+
}
202+
#### End of copy of cloudposse/terraform-null-label/variables.tf
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
region = "us-east-2"
2+
3+
availability_zones = ["us-east-2a", "us-east-2b"]
4+
5+
namespace = "eg"
6+
7+
stage = "test"
8+
9+
name = "elastic-beanstalk-env"
10+
11+
description = "Test elastic-beanstalk-environment"
12+
13+
tier = "WebServer"
14+
15+
environment_type = "LoadBalanced"
16+
17+
loadbalancer_type = "network"
18+
19+
availability_zone_selector = "Any 2"
20+
21+
instance_type = "t3.micro"
22+
23+
autoscale_min = 1
24+
25+
autoscale_max = 2
26+
27+
wait_for_ready_timeout = "20m"
28+
29+
force_destroy = true
30+
31+
rolling_update_enabled = true
32+
33+
rolling_update_type = "Health"
34+
35+
updating_min_in_service = 0
36+
37+
updating_max_batch = 1
38+
39+
application_port = 80
40+
41+
root_volume_size = 8
42+
43+
root_volume_type = "gp2"
44+
45+
autoscale_measure_name = "CPUUtilization"
46+
47+
autoscale_statistic = "Average"
48+
49+
autoscale_unit = "Percent"
50+
51+
autoscale_lower_bound = 20
52+
53+
autoscale_lower_increment = -1
54+
55+
autoscale_upper_bound = 80
56+
57+
autoscale_upper_increment = 1
58+
59+
elb_scheme = "public"
60+
61+
// https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html
62+
// https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.docker
63+
solution_stack_name = "64bit Amazon Linux 2018.03 v2.12.17 running Docker 18.06.1-ce"
64+
65+
version_label = ""
66+
67+
dns_zone_id = "Z3SO0TKDDQ0RGG"
68+
69+
// https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html
70+
additional_settings = [
71+
{
72+
namespace = "aws:elasticbeanstalk:managedactions"
73+
name = "ManagedActionsEnabled"
74+
value = "false"
75+
}
76+
]
77+
78+
env_vars = {
79+
"DB_HOST" = "xxxxxxxxxxxxxx"
80+
"DB_USERNAME" = "yyyyyyyyyyyyy"
81+
"DB_PASSWORD" = "zzzzzzzzzzzzzzzzzzz"
82+
"ANOTHER_ENV_VAR" = "123456789"
83+
}
84+
85+
// https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-autoscaling-scheduledactions.html
86+
scheduled_actions = [
87+
{
88+
name = "Refreshinstances"
89+
minsize = "1"
90+
maxsize = "2"
91+
desiredcapacity = "2"
92+
starttime = "2015-05-14T07:00:00Z"
93+
endtime = "2016-01-12T07:00:00Z"
94+
recurrence = "*/20 * * * *"
95+
suspend = false
96+
}
97+
]

0 commit comments

Comments
 (0)