File tree Expand file tree Collapse file tree 4 files changed +17
-4
lines changed Expand file tree Collapse file tree 4 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 7
7
availability_zone = " ${ var . availability_zone != " " ? var . availability_zone : data . aws_subnet . default . availability_zone } "
8
8
ami = " ${ var . ami != " " ? var . ami : data . aws_ami . default . image_id } "
9
9
root_volume_type = " ${ var . root_volume_type != " " ? var . root_volume_type : data . aws_ami . info . root_device_type } "
10
+ user_data = " ${ length (var. custom_user_data ) > 0 ? var . custom_user_data : data . template_file . user_data . rendered } "
10
11
}
11
12
12
13
data "aws_caller_identity" "default" {}
@@ -99,7 +100,7 @@ resource "aws_instance" "default" {
99
100
instance_type = " ${ var . instance_type } "
100
101
ebs_optimized = " ${ var . ebs_optimized } "
101
102
disable_api_termination = " ${ var . disable_api_termination } "
102
- user_data = " ${ data . template_file . user_data . rendered } "
103
+ user_data = " ${ local . user_data } "
103
104
iam_instance_profile = " ${ aws_iam_instance_profile . default . name } "
104
105
associate_public_ip_address = " ${ var . associate_public_ip_address } "
105
106
key_name = " ${ var . ssh_key_pair } "
@@ -134,7 +135,7 @@ resource "null_resource" "eip" {
134
135
count = " ${ var . associate_public_ip_address && var . instance_enabled ? 1 : 0 } "
135
136
136
137
triggers {
137
- public_dns = " ec2-${ replace (aws_eip. default . public_ip , " ." , " -" )} .${ local . region == " us-east-1" ? " compute-1" : " ${ local . region } .compute" } .amazonaws.com"
138
+ public_dns = " ec2-${ replace (aws_eip. default . public_ip , " ." , " -" )} .${ local . region == " us-east-1" ? " compute-1" : ${local.region}. compute } .amazonaws.com"
138
139
}
139
140
}
140
141
Original file line number Diff line number Diff line change @@ -43,11 +43,16 @@ output "alarm" {
43
43
value = " ${ join (" " , aws_cloudwatch_metric_alarm. default . * . id )} "
44
44
}
45
45
46
- output "additional_eni_ids " {
47
- description = " Map of ENI with EIP "
46
+ output "additional_eni_public " {
47
+ description = " Map IDs of ENI with public IPs "
48
48
value = " ${ zipmap (aws_network_interface. additional . * . id , aws_eip. additional . * . public_ip )} "
49
49
}
50
50
51
+ output "additional_eni_private" {
52
+ description = " Map IDs of ENI with private IPs"
53
+ value = " ${ zipmap (aws_network_interface. additional . * . id , aws_eip. additional . * . private_ip )} "
54
+ }
55
+
51
56
output "ebs_ids" {
52
57
description = " ID of EBSs"
53
58
value = " ${ aws_ebs_volume . default . * . id } "
Original file line number Diff line number Diff line change 1
1
data "template_file" "user_data" {
2
+ count = " ${ local . instance_count && length (var. custom_user_data ) == 0 ? 1 : 0 } "
2
3
template = " ${ file (" ${ path . module } /user-data/user_data.sh" )} "
3
4
4
5
vars {
Original file line number Diff line number Diff line change @@ -110,6 +110,12 @@ variable "user_data" {
110
110
default = []
111
111
}
112
112
113
+ variable "custom_user_data" {
114
+ description = " User data to provide when launching the instance"
115
+ type = " list"
116
+ default = []
117
+ }
118
+
113
119
variable "private_ip" {
114
120
description = " Private IP address to associate with the instance in a VPC"
115
121
default = " "
You can’t perform that action at this time.
0 commit comments