Skip to content

Commit 72d1987

Browse files
DrFaust92antonbabenko
authored andcommitted
Add get_password_data (terraform-aws-modules#105)
1 parent 80e5422 commit 72d1987

File tree

6 files changed

+38
-19
lines changed

6 files changed

+38
-19
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
repos:
22
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.12.0
3+
rev: v1.16.0
44
hooks:
55
- id: terraform_fmt
6-
# - id: terraform_docs
6+
- id: terraform_docs
77
- repo: git://github.com/pre-commit/pre-commit-hooks
88
rev: v2.2.3
99
hooks:

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,34 +98,36 @@ data "aws_ami" "ubuntu-xenial" {
9898
| Name | Description | Type | Default | Required |
9999
|------|-------------|:----:|:-----:|:-----:|
100100
| ami | ID of AMI to use for the instance | string | n/a | yes |
101-
| associate\_public\_ip\_address | If true, the EC2 instance will have associated public IP address | string | `"false"` | no |
101+
| associate\_public\_ip\_address | If true, the EC2 instance will have associated public IP address | bool | `"false"` | no |
102102
| cpu\_credits | The credit option for CPU usage (unlimited or standard) | string | `"standard"` | no |
103-
| disable\_api\_termination | If true, enables EC2 Instance Termination Protection | string | `"false"` | no |
104-
| ebs\_block\_device | Additional EBS block devices to attach to the instance | list | `<list>` | no |
105-
| ebs\_optimized | If true, the launched EC2 instance will be EBS-optimized | string | `"false"` | no |
106-
| ephemeral\_block\_device | Customize Ephemeral (also known as Instance Store) volumes on the instance | list | `<list>` | no |
103+
| disable\_api\_termination | If true, enables EC2 Instance Termination Protection | bool | `"false"` | no |
104+
| ebs\_block\_device | Additional EBS block devices to attach to the instance | list(map(string)) | `[]` | no |
105+
| ebs\_optimized | If true, the launched EC2 instance will be EBS-optimized | bool | `"false"` | no |
106+
| ephemeral\_block\_device | Customize Ephemeral (also known as Instance Store) volumes on the instance | list(map(string)) | `[]` | no |
107+
| get\_password\_data | If true, wait for password data to become available and retrieve it. | bool | `"false"` | no |
107108
| iam\_instance\_profile | The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. | string | `""` | no |
108-
| instance\_count | Number of instances to launch | string | `"1"` | no |
109+
| instance\_count | Number of instances to launch | number | `"1"` | no |
109110
| instance\_initiated\_shutdown\_behavior | Shutdown behavior for the instance | string | `""` | no |
110111
| instance\_type | The type of instance to start | string | n/a | yes |
111-
| ipv6\_address\_count | A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet. | string | `"0"` | no |
112-
| ipv6\_addresses | Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface | list | `<list>` | no |
112+
| ipv6\_address\_count | A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet. | number | `"0"` | no |
113+
| ipv6\_addresses | Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface | list(string) | `[]` | no |
113114
| key\_name | The key name to use for the instance | string | `""` | no |
114-
| monitoring | If true, the launched EC2 instance will have detailed monitoring enabled | string | `"false"` | no |
115+
| monitoring | If true, the launched EC2 instance will have detailed monitoring enabled | bool | `"false"` | no |
115116
| name | Name to be used on all resources as prefix | string | n/a | yes |
116-
| network\_interface | Customize network interfaces to be attached at instance boot time | list | `<list>` | no |
117+
| network\_interface | Customize network interfaces to be attached at instance boot time | list(map(string)) | `[]` | no |
117118
| placement\_group | The Placement Group to start the instance in | string | `""` | no |
118119
| private\_ip | Private IP address to associate with the instance in a VPC | string | `""` | no |
119-
| root\_block\_device | Customize details about the root block device of the instance. See Block Devices below for details | list | `<list>` | no |
120-
| source\_dest\_check | Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. | string | `"true"` | no |
120+
| private\_ips | A list of private IP address to associate with the instance in a VPC. Should match the number of instances. | list(string) | `[]` | no |
121+
| root\_block\_device | Customize details about the root block device of the instance. See Block Devices below for details | list(map(string)) | `[]` | no |
122+
| source\_dest\_check | Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. | bool | `"true"` | no |
121123
| subnet\_id | The VPC Subnet ID to launch in | string | `""` | no |
122-
| subnet\_ids | A list of VPC Subnet IDs to launch in | list | `<list>` | no |
123-
| tags | A mapping of tags to assign to the resource | map | `<map>` | no |
124+
| subnet\_ids | A list of VPC Subnet IDs to launch in | list(string) | `[]` | no |
125+
| tags | A mapping of tags to assign to the resource | map(string) | `{}` | no |
124126
| tenancy | The tenancy of the instance (if the instance is running in a VPC). Available values: default, dedicated, host. | string | `"default"` | no |
125-
| use\_num\_suffix | Always append numerical suffix to instance name, even if instance_count is 1 | string | `"false"` | no |
127+
| use\_num\_suffix | Always append numerical suffix to instance name, even if instance_count is 1 | bool | `"false"` | no |
126128
| user\_data | The user data to provide when launching the instance | string | `""` | no |
127-
| volume\_tags | A mapping of tags to assign to the devices created by the instance at launch time | map | `<map>` | no |
128-
| vpc\_security\_group\_ids | A list of security group IDs to associate with | list | n/a | yes |
129+
| volume\_tags | A mapping of tags to assign to the devices created by the instance at launch time | map(string) | `{}` | no |
130+
| vpc\_security\_group\_ids | A list of security group IDs to associate with | list(string) | n/a | yes |
129131

130132
## Outputs
131133

@@ -135,6 +137,7 @@ data "aws_ami" "ubuntu-xenial" {
135137
| credit\_specification | List of credit specification of instances |
136138
| id | List of IDs of instances |
137139
| key\_name | List of key names of instances |
140+
| password\_data | List of Base-64 encoded encrypted password data for the instance |
138141
| placement\_group | List of placement groups of instances |
139142
| primary\_network\_interface\_id | List of IDs of the primary network interface of instances |
140143
| private\_dns | List of private DNS names assigned to the instances. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC |

examples/basic/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ Note that this example may create resources which can cost money. Run `terraform
2929
| ids\_t2 | List of IDs of t2-type instances |
3030
| instance\_id | EC2 instance ID |
3131
| instance\_public\_dns | Public DNS name assigned to the EC2 instance |
32+
| placement\_group | List of placement group |
3233
| public\_dns | List of public DNS names assigned to the instances |
34+
| t2\_instance\_id | EC2 instance ID |
3335
| tags | List of tags |
3436
| vpc\_security\_group\_ids | List of VPC security group ids assigned to the instances |
3537

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ resource "aws_instance" "this" {
2020
)
2121
key_name = var.key_name
2222
monitoring = var.monitoring
23+
get_password_data = var.get_password_data
2324
vpc_security_group_ids = var.vpc_security_group_ids
2425
iam_instance_profile = var.iam_instance_profile
2526

@@ -105,6 +106,7 @@ resource "aws_instance" "this_t2" {
105106
)
106107
key_name = var.key_name
107108
monitoring = var.monitoring
109+
get_password_data = var.get_password_data
108110
vpc_security_group_ids = var.vpc_security_group_ids
109111
iam_instance_profile = var.iam_instance_profile
110112

outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ locals {
1414
this_credit_specification = flatten(aws_instance.this_t2.*.credit_specification)
1515
this_tags = coalescelist(aws_instance.this.*.tags, aws_instance.this_t2.*.tags, [""])
1616
this_volume_tags = coalescelist(aws_instance.this.*.volume_tags, aws_instance.this_t2.*.volume_tags, [""])
17+
this_password_data = coalescelist(aws_instance.this.*.password_data, aws_instance.this_t2.*.password_data, [""])
1718
}
1819

1920
output "id" {
@@ -61,6 +62,11 @@ output "private_ip" {
6162
value = local.this_private_ip
6263
}
6364

65+
output "password_data" {
66+
description = "List of Base-64 encoded encrypted password data for the instance"
67+
value = local.this_password_data
68+
}
69+
6470
output "security_groups" {
6571
description = "List of associated security groups of instances"
6672
value = local.this_security_groups

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ variable "placement_group" {
2020
default = ""
2121
}
2222

23+
variable "get_password_data" {
24+
description = "If true, wait for password data to become available and retrieve it."
25+
type = bool
26+
default = false
27+
}
28+
2329
variable "tenancy" {
2430
description = "The tenancy of the instance (if the instance is running in a VPC). Available values: default, dedicated, host."
2531
type = string

0 commit comments

Comments
 (0)