Skip to content

Commit adb9d97

Browse files
authored
Add user_data_base64 to inputs. Add arn to outputs (#71)
1 parent b1a5424 commit adb9d97

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ Available targets:
201201
| statistic\_level | The statistic to apply to the alarm's associated metric. Allowed values are: SampleCount, Average, Sum, Minimum, Maximum | `string` | `"Maximum"` | no |
202202
| subnet | VPC Subnet ID the instance is launched in | `string` | n/a | yes |
203203
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
204-
| user\_data | Instance user data. Do not pass gzip-compressed data via this argument | `string` | `""` | no |
204+
| user\_data | The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; use `user_data_base64` instead | `string` | `null` | no |
205+
| user\_data\_base64 | Can be used instead of `user_data` to pass base64-encoded binary data directly. Use this instead of `user_data` whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption | `string` | `null` | no |
205206
| vpc\_id | The ID of the VPC that the instance security group belongs to | `string` | n/a | yes |
206207
| welcome\_message | Welcome message | `string` | `""` | no |
207208

@@ -211,6 +212,7 @@ Available targets:
211212
|------|-------------|
212213
| additional\_eni\_ids | Map of ENI to EIP |
213214
| alarm | CloudWatch Alarm ID |
215+
| arn | ARN of the instance |
214216
| ebs\_ids | IDs of EBSs |
215217
| id | Disambiguated ID of the instance |
216218
| instance\_profile | Name of the instance's profile (either built or supplied) |

docs/terraform.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
| statistic\_level | The statistic to apply to the alarm's associated metric. Allowed values are: SampleCount, Average, Sum, Minimum, Maximum | `string` | `"Maximum"` | no |
7272
| subnet | VPC Subnet ID the instance is launched in | `string` | n/a | yes |
7373
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
74-
| user\_data | Instance user data. Do not pass gzip-compressed data via this argument | `string` | `""` | no |
74+
| user\_data | The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; use `user_data_base64` instead | `string` | `null` | no |
75+
| user\_data\_base64 | Can be used instead of `user_data` to pass base64-encoded binary data directly. Use this instead of `user_data` whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption | `string` | `null` | no |
7576
| vpc\_id | The ID of the VPC that the instance security group belongs to | `string` | n/a | yes |
7677
| welcome\_message | Welcome message | `string` | `""` | no |
7778

@@ -81,6 +82,7 @@
8182
|------|-------------|
8283
| additional\_eni\_ids | Map of ENI to EIP |
8384
| alarm | CloudWatch Alarm ID |
85+
| arn | ARN of the instance |
8486
| ebs\_ids | IDs of EBSs |
8587
| id | Disambiguated ID of the instance |
8688
| instance\_profile | Name of the instance's profile (either built or supplied) |

examples/complete/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ output "id" {
5858
value = module.ec2_instance.id
5959
}
6060

61+
output "arn" {
62+
description = "ARN of the instance"
63+
value = module.ec2_instance.arn
64+
}
65+
6166
output "name" {
6267
description = "Instance name"
6368
value = module.ec2_instance.name

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ resource "aws_instance" "default" {
9797
ebs_optimized = var.ebs_optimized
9898
disable_api_termination = var.disable_api_termination
9999
user_data = var.user_data
100+
user_data_base64 = var.user_data_base64
100101
iam_instance_profile = local.instance_profile
101102
associate_public_ip_address = var.associate_public_ip_address
102103
key_name = var.ssh_key_pair

outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ output "id" {
2323
value = join("", aws_instance.default.*.id)
2424
}
2525

26+
output "arn" {
27+
description = "ARN of the instance"
28+
value = join("", aws_instance.default.*.arn)
29+
}
30+
2631
output "name" {
2732
description = "Instance name"
2833
value = module.this.id

variables.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@ variable "assign_eip_address" {
1717

1818
variable "user_data" {
1919
type = string
20-
description = "Instance user data. Do not pass gzip-compressed data via this argument"
21-
default = ""
20+
description = "The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; use `user_data_base64` instead"
21+
default = null
22+
}
23+
24+
variable "user_data_base64" {
25+
type = string
26+
description = "Can be used instead of `user_data` to pass base64-encoded binary data directly. Use this instead of `user_data` whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption"
27+
default = null
2228
}
2329

2430
variable "instance_type" {

0 commit comments

Comments
 (0)