Skip to content

Commit 84b5e0a

Browse files
authored
Add ability to configure instance tenancy (#141)
1 parent 1bc0487 commit 84b5e0a

File tree

7 files changed

+25
-0
lines changed

7 files changed

+25
-0
lines changed

.github/workflows/validate-codeowners.yml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
steps:
1111
- name: "Checkout source code at current commit"
1212
uses: actions/checkout@v2
13+
# Leave pinned at 0.7.1 until https://github.com/mszostok/codeowners-validator/issues/173 is resolved
1314
- uses: mszostok/[email protected]
1415
if: github.event.pull_request.head.repo.full_name == github.repository
1516
name: "Full check of CODEOWNERS"

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ Available targets:
325325
| <a name="input_statistic_level"></a> [statistic\_level](#input\_statistic\_level) | The statistic to apply to the alarm's associated metric. Allowed values are: SampleCount, Average, Sum, Minimum, Maximum | `string` | `"Maximum"` | no |
326326
| <a name="input_subnet"></a> [subnet](#input\_subnet) | VPC Subnet ID the instance is launched in | `string` | n/a | yes |
327327
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
328+
| <a name="input_tenancy"></a> [tenancy](#input\_tenancy) | Tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of 'dedicated' runs on single-tenant hardware. The 'host' tenancy is not supported for the import-instance command. Valid values are 'default', 'dedicated', and 'host'. | `string` | `"default"` | no |
328329
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
329330
| <a name="input_user_data"></a> [user\_data](#input\_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 |
330331
| <a name="input_user_data_base64"></a> [user\_data\_base64](#input\_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 |

docs/terraform.md

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
| <a name="input_statistic_level"></a> [statistic\_level](#input\_statistic\_level) | The statistic to apply to the alarm's associated metric. Allowed values are: SampleCount, Average, Sum, Minimum, Maximum | `string` | `"Maximum"` | no |
129129
| <a name="input_subnet"></a> [subnet](#input\_subnet) | VPC Subnet ID the instance is launched in | `string` | n/a | yes |
130130
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
131+
| <a name="input_tenancy"></a> [tenancy](#input\_tenancy) | Tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of 'dedicated' runs on single-tenant hardware. The 'host' tenancy is not supported for the import-instance command. Valid values are 'default', 'dedicated', and 'host'. | `string` | `"default"` | no |
131132
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
132133
| <a name="input_user_data"></a> [user\_data](#input\_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 |
133134
| <a name="input_user_data_base64"></a> [user\_data\_base64](#input\_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 |

examples/complete/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ module "ec2_instance" {
8484
instance_type = var.instance_type
8585
security_group_rules = var.security_group_rules
8686
instance_profile = aws_iam_instance_profile.test.name
87+
tenancy = var.tenancy
8788

8889
context = module.this.context
8990
}

examples/complete/variables.tf

+10
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,13 @@ variable "security_group_rules" {
3636
To get more info see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule .
3737
EOT
3838
}
39+
40+
variable "tenancy" {
41+
type = string
42+
default = "default"
43+
description = "Tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of 'dedicated' runs on single-tenant hardware. The 'host' tenancy is not supported for the import-instance command. Valid values are 'default', 'dedicated', and 'host'."
44+
validation {
45+
condition = contains(["default", "dedicated", "host"], lower(var.tenancy))
46+
error_message = "Tenancy field can only be one of default, dedicated, host"
47+
}
48+
}

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ resource "aws_instance" "default" {
129129
source_dest_check = var.source_dest_check
130130
ipv6_address_count = var.ipv6_address_count < 0 ? null : var.ipv6_address_count
131131
ipv6_addresses = length(var.ipv6_addresses) == 0 ? null : var.ipv6_addresses
132+
tenancy = var.tenancy
132133

133134
vpc_security_group_ids = compact(
134135
concat(

variables.tf

+10
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,13 @@ variable "ssm_patch_manager_s3_log_bucket" {
368368
default = null
369369
description = "The name of the s3 bucket to export the patch log to"
370370
}
371+
372+
variable "tenancy" {
373+
type = string
374+
default = "default"
375+
description = "Tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of 'dedicated' runs on single-tenant hardware. The 'host' tenancy is not supported for the import-instance command. Valid values are 'default', 'dedicated', and 'host'."
376+
validation {
377+
condition = contains(["default", "dedicated", "host"], lower(var.tenancy))
378+
error_message = "Tenancy field can only be one of default, dedicated, host"
379+
}
380+
}

0 commit comments

Comments
 (0)